1 23 24 package org.xquark.jdbc.typing; 25 26 import org.xquark.util.AttributeTracker; 27 import org.xquark.util.SaxMapper; 28 import org.xquark.util.TagTracker; 29 30 33 public class DBMSInfoLoader extends SaxMapper 34 { 35 private static final String RCSRevision = "$Revision: 1.3 $"; 36 private static final String RCSName = "$Name: $"; 37 38 39 private DBMSInfo dbmsInfo; 40 private TypeMap.SQLType wType; 41 private SQLStatementCustomizer wStmtCustomizer; 42 private String wClause; 43 private boolean wIsPrincipal = false; 44 private String wCreateParams = null; 45 private boolean wUseGetString = false; 46 private boolean defaultUseGetString; 47 50 public TagTracker createTagTrackerNetwork() 51 { 52 TagTracker root = new TagTracker() { 54 public void onDeactivate() 55 { 56 dbmsInfo = new DBMSInfo(); 57 dbmsInfo.setTypeMap(new TypeMap()); 58 } 59 }; 60 61 root.track 63 ( 64 "/dbmsInfo/limits/systemCollectionsDataLength", 65 new TagTracker() { 66 public void onEnd( 67 String namespaceURI, 68 String localName, 69 Object actualValue) 70 { 71 dbmsInfo.setSystemCollectionsDataLength(((Number )actualValue).intValue()); 72 } 73 } 74 ); 75 76 root.track 78 ( 79 "/dbmsInfo/limits/userCollectionMaxDataLength", 80 new TagTracker() { 81 public void onEnd( 82 String namespaceURI, 83 String localName, 84 Object actualValue) 85 { 86 dbmsInfo.setMaxUserCollectionsDataLength(((Number )actualValue).intValue()); 87 } 88 } 89 ); 90 91 TagTracker lockHint = new TagTracker() { 93 public void onEnd( 94 String namespaceURI, 95 String localName, 96 Object actualValue) 97 { 98 dbmsInfo.setSelectLockStatement(new SQLStatementCustomizer((String )actualValue)); 99 } 100 }; 101 root.track("/dbmsInfo/SQLTokens/selectLockStatement", lockHint); 102 103 TagTracker tmpTableHint = new TagTracker() { 105 public void onEnd( 106 String namespaceURI, 107 String localName, 108 Object actualValue) 109 { 110 dbmsInfo.setTemporaryTableStatement(new SQLStatementCustomizer((String )actualValue)); 111 } 112 }; 113 root.track("/dbmsInfo/SQLTokens/temporaryTableSpecification", tmpTableHint); 114 115 TagTracker indexOrgHint = new TagTracker() { 117 public void onEnd( 118 String namespaceURI, 119 String localName, 120 Object actualValue) 121 { 122 dbmsInfo.setIndexOrganizedStatement(new SQLStatementCustomizer((String )actualValue)); 123 } 124 }; 125 root.track("/dbmsInfo/SQLTokens/indexOrganizationSpecification", indexOrgHint); 126 127 root.track 129 ( 130 "/dbmsInfo/SQLTokens/rowID", 131 new TagTracker() { 132 public void onEnd( 133 String namespaceURI, 134 String localName, 135 Object actualValue) 136 { 137 dbmsInfo.setRowId((String )actualValue); 138 } 139 } 140 ); 141 142 root.track 144 ( 145 "/dbmsInfo/SQLTokens/useDoubleQuotesToPreserveDDLNamesCase", 146 new TagTracker() { 147 public void onEnd( 148 String namespaceURI, 149 String localName, 150 Object actualValue) 151 { 152 dbmsInfo.setUseDoubleQuotes4DDLNames(((Boolean )actualValue).booleanValue()); 153 } 154 } 155 ); 156 157 root.trackAttribute( 159 "/dbmsInfo/typeMapping/@defaultUseGetString", 160 new AttributeTracker() { 161 public void onAttributeEncountered 162 ( 163 String namespaceURI, 164 String localName, 165 Object actualValue, 166 boolean isDefault 167 ) 168 { 169 defaultUseGetString =((Boolean )actualValue).booleanValue(); 170 } 171 } 172 ); 173 174 TagTracker type = new TagTracker() { 176 public void onStart( 177 String namespaceURI, 178 String localName) 179 { 180 wType = dbmsInfo.getTypeMap().createType(); 181 } 182 public void onEnd( 183 String namespaceURI, 184 String localName, 185 Object actualValue) 186 { 187 dbmsInfo.getTypeMap().addType(wType); 188 } 189 }; 190 root.track("/dbmsInfo/typeMapping/type", type); 191 192 type.trackAttribute( 194 "@name", 195 new AttributeTracker() { 196 public void onAttributeEncountered 197 ( 198 String namespaceURI, 199 String localName, 200 Object actualValue, 201 boolean isDefault 202 ) 203 { 204 wType.setNativeTypeName((String )actualValue); 205 } 206 } 207 ); 208 209 type.trackAttribute( 211 "@autoFill", 212 new AttributeTracker() { 213 public void onAttributeEncountered 214 ( 215 String namespaceURI, 216 String localName, 217 Object actualValue, 218 boolean isDefault 219 ) 220 { 221 wType.setAutoFill(((Boolean )actualValue).booleanValue()); 222 } 223 } 224 ); 225 226 TagTracker jdbcType = new TagTracker() { 228 public void onEnd( 229 String namespaceURI, 230 String localName, 231 Object actualValue) 232 { 233 wType.addJDBCType((String )actualValue, wCreateParams, wIsPrincipal, wUseGetString); 234 wIsPrincipal = false; 235 wCreateParams = null; 236 wUseGetString = defaultUseGetString; 237 } 238 }; 239 type.track("jdbcType", jdbcType); 240 241 jdbcType.trackAttribute( 243 "@principal", 244 new AttributeTracker() { 245 public void onAttributeEncountered 246 ( 247 String namespaceURI, 248 String localName, 249 Object actualValue, 250 boolean isDefault 251 ) 252 { 253 wIsPrincipal = ((Boolean )actualValue).booleanValue(); 254 } 255 } 256 ); 257 258 jdbcType.trackAttribute( 260 "@createParams", 261 new AttributeTracker() { 262 public void onAttributeEncountered 263 ( 264 String namespaceURI, 265 String localName, 266 Object actualValue, 267 boolean isDefault 268 ) 269 { 270 wCreateParams = (String )actualValue; 271 } 272 } 273 ); 274 275 jdbcType.trackAttribute( 277 "@useGetString", 278 new AttributeTracker() { 279 public void onAttributeEncountered 280 ( 281 String namespaceURI, 282 String localName, 283 Object actualValue, 284 boolean isDefault 285 ) 286 { 287 if (isDefault) wUseGetString = defaultUseGetString; 289 else 290 wUseGetString = ((Boolean )actualValue).booleanValue(); 291 } 292 } 293 ); 294 295 type.track( 297 "size", 298 new TagTracker() { 299 public void onEnd( 300 String namespaceURI, 301 String localName, 302 Object actualValue) 303 { 304 wType.setPrecision(((Number )actualValue).longValue()); 305 } 306 } 307 ); 308 309 type.track( 311 "precision", 312 new TagTracker() { 313 public void onEnd( 314 String namespaceURI, 315 String localName, 316 Object actualValue) 317 { 318 wType.setPrecision(((Number )actualValue).longValue()); 319 } 320 } 321 ); 322 323 type.track( 325 "unsigned", 326 new TagTracker() { 327 public void onEnd( 328 String namespaceURI, 329 String localName, 330 Object actualValue) 331 { 332 wType.setUnsigned(((Boolean )actualValue).booleanValue()); 333 } 334 } 335 ); 336 337 type.track( 339 "indexable", 340 new TagTracker() { 341 public void onEnd( 342 String namespaceURI, 343 String localName, 344 Object actualValue) 345 { 346 wType.setIndexable(((Boolean )actualValue).booleanValue()); 347 } 348 } 349 ); 350 351 type.track( 353 "storage", 354 new TagTracker() { 355 public void onEnd( 356 String namespaceURI, 357 String localName, 358 Object actualValue) 359 { 360 wType.setStorage(((Boolean )actualValue).booleanValue()); 361 } 362 } 363 ); 364 365 type.track( 367 "extraction", 368 new TagTracker() { 369 public void onEnd( 370 String namespaceURI, 371 String localName, 372 Object actualValue) 373 { 374 wType.setExtraction(((Boolean )actualValue).booleanValue()); 375 } 376 } 377 ); 378 379 return root; 380 } 381 382 385 public Object getMappedObject() 386 { 387 return dbmsInfo; 388 } 389 } 390 | Popular Tags |