1 10 11 package com.triactive.jdo.store; 12 13 import java.io.PrintWriter ; 14 import java.io.StringWriter ; 15 import java.sql.DatabaseMetaData ; 16 import java.sql.ResultSet ; 17 import java.sql.SQLException ; 18 import java.sql.Types ; 19 import javax.jdo.JDOFatalDataStoreException; 20 21 22 40 41 class ForeignKeyInfo 42 { 43 46 public String pkTableCat; 47 48 51 public String pkTableSchem; 52 53 56 public String pkTableName; 57 58 61 public String pkColumnName; 62 63 66 public String fkTableCat; 67 68 71 public String fkTableSchem; 72 73 76 public String fkTableName; 77 78 81 public String fkColumnName; 82 83 86 public short keySeq; 87 88 97 public short updateRule; 98 99 108 public short deleteRule; 109 110 113 public String fkName; 114 115 118 public String pkName; 119 120 128 public short deferrability; 129 130 private int hash = 0; 131 132 133 149 150 public ForeignKeyInfo(ResultSet rs) throws JDOFatalDataStoreException 151 { 152 try 153 { 154 pkTableCat = rs.getString(1); 155 pkTableSchem = rs.getString(2); 156 pkTableName = rs.getString(3); 157 pkColumnName = rs.getString(4); 158 fkTableCat = rs.getString(5); 159 fkTableSchem = rs.getString(6); 160 fkTableName = rs.getString(7); 161 fkColumnName = rs.getString(8); 162 keySeq = rs.getShort(9); 163 updateRule = rs.getShort(10); 164 deleteRule = rs.getShort(11); 165 fkName = rs.getString(12); 166 pkName = rs.getString(13); 167 deferrability = rs.getShort(14); 168 } 169 catch (SQLException e) 170 { 171 throw new JDOFatalDataStoreException("Can't read JDBC metadata from result set", e); 172 } 173 } 174 175 176 183 184 public ForeignKeyInfo(String pkTableCat, 185 String pkTableSchem, 186 String pkTableName, 187 String pkColumnName, 188 String fkTableCat, 189 String fkTableSchem, 190 String fkTableName, 191 String fkColumnName, 192 short keySeq, 193 short updateRule, 194 short deleteRule, 195 String fkName, 196 String pkName, 197 short deferrability) 198 { 199 this.pkTableCat = pkTableCat; 200 this.pkTableSchem = pkTableSchem; 201 this.pkTableName = pkTableName; 202 this.pkColumnName = pkColumnName; 203 this.fkTableCat = fkTableCat; 204 this.fkTableSchem = fkTableSchem; 205 this.fkTableName = fkTableName; 206 this.fkColumnName = fkColumnName; 207 this.keySeq = keySeq; 208 this.updateRule = updateRule; 209 this.deleteRule = deleteRule; 210 this.fkName = fkName; 211 this.pkName = pkName; 212 this.deferrability = deferrability; 213 } 214 215 216 227 228 public final boolean equals(Object obj) 229 { 230 if (obj == this) 231 return true; 232 233 if (!(obj instanceof ForeignKeyInfo)) 234 return false; 235 236 ForeignKeyInfo ci = (ForeignKeyInfo)obj; 237 238 return (pkTableCat == null ? ci.pkTableCat == null : pkTableCat.equals(ci.pkTableCat)) 239 && (pkTableSchem == null ? ci.pkTableSchem == null : pkTableSchem.equals(ci.pkTableSchem)) 240 && pkTableName.equals(ci.pkTableName) 241 && pkColumnName.equals(ci.pkColumnName) 242 && (fkTableCat == null ? ci.fkTableCat == null : fkTableCat.equals(ci.fkTableCat)) 243 && (fkTableSchem == null ? ci.fkTableSchem == null : fkTableSchem.equals(ci.fkTableSchem)) 244 && fkTableName.equals(ci.fkTableName) 245 && fkColumnName.equals(ci.fkColumnName); 246 } 247 248 249 254 255 public final int hashCode() 256 { 257 if (hash == 0) 258 { 259 hash = (pkTableCat == null ? 0 : pkTableCat.hashCode()) 260 ^ (pkTableSchem == null ? 0 : pkTableSchem.hashCode()) 261 ^ pkTableName.hashCode() 262 ^ pkColumnName.hashCode() 263 ^ (fkTableCat == null ? 0 : fkTableCat.hashCode()) 264 ^ (fkTableSchem == null ? 0 : fkTableSchem.hashCode()) 265 ^ fkTableName.hashCode() 266 ^ fkColumnName.hashCode(); 267 } 268 269 return hash; 270 } 271 272 273 278 279 public String toString() 280 { 281 StringWriter sw = new StringWriter (); 282 PrintWriter pw = new PrintWriter (sw); 283 284 pw.println(this.getClass().getName()); 285 pw.print(" pkTableCat = "); pw.println(pkTableCat); 286 pw.print(" pkTableSchem = "); pw.println(pkTableSchem); 287 pw.print(" pkTableName = "); pw.println(pkTableName); 288 pw.print(" pkColumnName = "); pw.println(pkColumnName); 289 pw.print(" fkTableCat = "); pw.println(fkTableCat); 290 pw.print(" fkTableSchem = "); pw.println(fkTableSchem); 291 pw.print(" fkTableName = "); pw.println(fkTableName); 292 pw.print(" fkColumnName = "); pw.println(fkColumnName); 293 pw.print(" keySeq = "); pw.println(keySeq); 294 pw.print(" updateRule = "); pw.println(updateRule); 295 pw.print(" deleteRule = "); pw.println(deleteRule); 296 pw.print(" fkName = "); pw.println(fkName); 297 pw.print(" pkName = "); pw.println(pkName); 298 pw.print(" deferrability = "); pw.println(deferrability); 299 pw.close(); 300 301 return sw.toString(); 302 } 303 } 304 | Popular Tags |