1 package org.apache.ojb.broker.metadata; 2 3 17 18 import org.apache.ojb.broker.util.DoubleHashtable; 19 import org.apache.ojb.broker.util.logging.LoggerFactory; 20 import org.apache.ojb.broker.util.pooling.PoolConfiguration; 21 22 37 public class RepositoryTags implements RepositoryElements 38 { 39 42 private DoubleHashtable table; 43 44 47 private static RepositoryTags instance = new RepositoryTags(); 48 49 53 private RepositoryTags() 54 { 55 table = new DoubleHashtable(); 57 table.put("descriptor-repository", new Integer (MAPPING_REPOSITORY)); 58 table.put("version", new Integer (REPOSITORY_VERSION)); 59 table.put("isolation-level", new Integer (ISOLATION_LEVEL)); 60 table.put("jdbc-connection-descriptor", new Integer (JDBC_CONNECTION_DESCRIPTOR)); 61 table.put("platform", new Integer (DBMS_NAME)); 62 table.put("schema", new Integer (SCHEMA_NAME)); 63 table.put("jcd-alias", new Integer (JCD_ALIAS)); 64 table.put("default-connection", new Integer (DEFAULT_CONNECTION)); 65 table.put("driver", new Integer (DRIVER_NAME)); 66 table.put("protocol", new Integer (URL_PROTOCOL)); 67 table.put("subprotocol", new Integer (URL_SUBPROTOCOL)); 68 table.put("dbalias", new Integer (URL_DBALIAS)); 69 table.put("username", new Integer (USER_NAME)); 70 table.put("password", new Integer (USER_PASSWD)); 71 table.put("eager-release", new Integer (EAGER_RELEASE)); 72 table.put("batch-mode", new Integer (BATCH_MODE)); 73 table.put("useAutoCommit", new Integer (USE_AUTOCOMMIT)); 74 table.put("ignoreAutoCommitExceptions", new Integer (IGNORE_AUTOCOMMIT_EXCEPTION)); 75 table.put("class-descriptor", new Integer (CLASS_DESCRIPTOR)); 76 table.put("class", new Integer (CLASS_NAME)); 77 table.put("proxy", new Integer (CLASS_PROXY)); 78 table.put("extent-class", new Integer (CLASS_EXTENT)); 79 table.put("extends", new Integer (EXTENDS)); 80 table.put("table", new Integer (TABLE_NAME)); 81 table.put("orderby", new Integer (ORDERBY)); 82 table.put("conversion", new Integer (FIELD_CONVERSION)); 83 table.put("row-reader", new Integer (ROW_READER)); 84 table.put("field-descriptor", new Integer (FIELD_DESCRIPTOR)); 85 table.put("name", new Integer (FIELD_NAME)); 86 table.put("column", new Integer (COLUMN_NAME)); 87 table.put("jdbc-type", new Integer (JDBC_TYPE)); 88 table.put("primarykey", new Integer (PRIMARY_KEY)); 89 table.put("autoincrement", new Integer (AUTO_INCREMENT)); 90 table.put("sequence-name", new Integer (SEQUENCE_NAME)); 91 table.put("nullable", new Integer (NULLABLE)); 92 table.put("indexed", new Integer (INDEXED)); 93 table.put("length", new Integer (LENGTH)); 94 table.put("precision", new Integer (PRECISION)); 95 table.put("scale", new Integer (SCALE)); 96 table.put(TAG_ACCESS, new Integer (ACCESS)); 97 98 table.put("reference-descriptor", new Integer (REFERENCE_DESCRIPTOR)); 99 table.put("class-ref", new Integer (REFERENCED_CLASS)); 100 table.put("foreignkey", new Integer (FOREIGN_KEY)); 101 table.put("auto-retrieve", new Integer (AUTO_RETRIEVE)); 102 table.put("auto-update", new Integer (AUTO_UPDATE)); 103 table.put("auto-delete", new Integer (AUTO_DELETE)); 104 table.put("collection-descriptor", new Integer (COLLECTION_DESCRIPTOR)); 105 table.put("element-class-ref", new Integer (ITEMS_CLASS)); 106 table.put("inverse-foreignkey", new Integer (INVERSE_FK)); 107 table.put("collection-class", new Integer (COLLECTION_CLASS)); 108 table.put("indirection-table", new Integer (INDIRECTION_TABLE)); 109 table.put("fk-pointing-to-element-class", new Integer (FK_POINTING_TO_ITEMS_CLASS)); 110 table.put("fk-pointing-to-this-class", new Integer (FK_POINTING_TO_THIS_CLASS)); 111 table.put("jndi-datasource-name", new Integer (DATASOURCE_NAME)); 112 table.put("jdbc-level", new Integer (JDBC_LEVEL)); 113 table.put("locking", new Integer (LOCKING)); 114 table.put("update-lock", new Integer (UPDATE_LOCK)); 115 table.put("refresh", new Integer (REFRESH)); 116 table.put("proxy", new Integer (PROXY_REFERENCE)); 117 table.put("sort", new Integer (SORT)); 118 table.put("otm-dependent", new Integer (OTM_DEPENDENT)); 119 120 table.put("index-descriptor", new Integer (INDEX_DESCRIPTOR)); 121 table.put("index-column", new Integer (INDEX_COLUMN)); 122 table.put("unique", new Integer (UNIQUE)); 123 table.put("name", new Integer (NAME)); 124 125 table.put(PoolConfiguration.MAX_ACTIVE, new Integer (CON_MAX_ACTIVE)); 126 table.put(PoolConfiguration.MAX_IDLE, new Integer (CON_MAX_IDLE)); 127 table.put(PoolConfiguration.MAX_WAIT, new Integer (CON_MAX_WAIT)); 128 table.put( 129 PoolConfiguration.MIN_EVICTABLE_IDLE_TIME_MILLIS, 130 new Integer (CON_MIN_EVICTABLE_IDLE_TIME_MILLIS)); 131 table.put( 132 PoolConfiguration.NUM_TESTS_PER_EVICTION_RUN, 133 new Integer (CON_NUM_TESTS_PER_EVICTION_RUN)); 134 table.put(PoolConfiguration.TEST_ON_BORROW, new Integer (CON_TEST_ON_BORROW)); 135 table.put(PoolConfiguration.TEST_ON_RETURN, new Integer (CON_TEST_ON_RETURN)); 136 table.put(PoolConfiguration.TEST_WHILE_IDLE, new Integer (CON_TEST_WHILE_IDLE)); 137 table.put( 138 PoolConfiguration.TIME_BETWEEN_EVICTION_RUNS_MILLIS, 139 new Integer (CON_TIME_BETWEEN_EVICTION_RUNS_MILLIS)); 140 table.put(PoolConfiguration.WHEN_EXHAUSTED_ACTION, new Integer (CON_WHEN_EXHAUSTED_ACTION)); 141 table.put(PoolConfiguration.VALIDATION_QUERY, new Integer (VALIDATION_QUERY)); 142 143 table.put(PoolConfiguration.LOG_ABANDONED, new Integer (CON_LOG_ABANDONED)); 144 table.put(PoolConfiguration.REMOVE_ABANDONED, new Integer (CON_REMOVE_ABANDONED)); 145 table.put( 146 PoolConfiguration.REMOVE_ABANDONED_TIMEOUT, 147 new Integer (CON_REMOVE_ABANDONED_TIMEOUT)); 148 149 table.put("connectionFactory", new Integer (CONNECTION_FACTORY)); 150 table.put("connection-pool", new Integer (CONNECTION_POOL)); 151 table.put("class-ref", new Integer (CLASS_REF)); 152 table.put("id", new Integer (ID)); 153 table.put("field-id-ref", new Integer (FIELD_ID_REF)); 154 table.put("field-ref", new Integer (FIELD_REF)); 155 table.put("attribute", new Integer (ATTRIBUTE)); 156 table.put("attribute-name", new Integer (ATTRIBUTE_NAME)); 157 table.put("attribute-value", new Integer (ATTRIBUTE_VALUE)); 158 table.put("documentation", new Integer (DOCUMENTATION)); 159 table.put("accept-locks", new Integer (ACCEPT_LOCKS)); 160 161 table.put("sequence-manager", new Integer (SEQUENCE_MANAGER)); 162 table.put("className", new Integer (SEQUENCE_MANAGER_CLASS)); 163 164 table.put("query-customizer", new Integer (QUERY_CUSTOMIZER)); 165 table.put("initialization-method", new Integer (INITIALIZATION_METHOD)); 166 table.put("factory-class", new Integer (FACTORY_CLASS)); 167 table.put("factory-method", new Integer (FACTORY_METHOD)); 168 169 table.put("insert-procedure", new Integer (INSERT_PROCEDURE)); 170 table.put("update-procedure", new Integer (UPDATE_PROCEDURE)); 171 table.put("delete-procedure", new Integer (DELETE_PROCEDURE)); 172 table.put("constant-argument", new Integer (CONSTANT_ARGUMENT)); 173 table.put("runtime-argument", new Integer (RUNTIME_ARGUMENT)); 174 table.put("return", new Integer (RETURN)); 175 table.put("value", new Integer (VALUE)); 176 table.put("return-field-ref", new Integer (RETURN_FIELD_REF)); 177 table.put("include-pk-only", new Integer (INCLUDE_PK_FIELDS_ONLY)); 178 table.put("include-all-fields", new Integer (INCLUDE_ALL_FIELDS)); 179 180 table.put("object-cache", new Integer (OBJECT_CACHE)); 181 182 table.put("proxy-prefetching-limit", new Integer (PROXY_PREFETCHING_LIMIT)); 183 184 } 186 187 190 public static RepositoryTags getInstance() 191 { 192 return instance; 193 } 194 195 200 public String getTagById(int elementId) 201 { 202 return (String ) table.getKeyByValue(new Integer (elementId)); 203 } 204 205 210 public String getOpeningTagById(int elementId) 211 { 212 return "<" + table.getKeyByValue(new Integer (elementId)) + ">"; 213 } 214 215 221 public String getOpeningTagNonClosingById(int elementId) 222 { 223 return "<" + table.getKeyByValue(new Integer (elementId)); 224 } 225 226 231 public String getOpeningTagById(int elementId, String attributes) 232 { 233 return "<" + table.getKeyByValue(new Integer (elementId)) + " " + attributes + ">"; 234 } 235 236 242 public String getAttribute(int elementId, String value) 243 { 244 return table.getKeyByValue(new Integer (elementId)) + "=\"" + value + "\""; 245 } 246 247 252 public String getClosingTagById(int elementId) 253 { 254 return "</" + table.getKeyByValue(new Integer (elementId)) + ">"; 255 } 256 257 263 public int getIdByTag(String tag) 264 { 265 Integer value = (Integer ) table.getValueByKey(tag); 266 if (value == null) 267 LoggerFactory.getDefaultLogger().error( 268 "** " + this.getClass().getName() + ": Tag '" + tag + "' is not defined. **"); 269 return value.intValue(); 270 } 271 272 277 public String getCompleteTagById(int elementId, String characters) 278 { 279 String result = getOpeningTagById(elementId); 280 result += characters; 281 result += getClosingTagById(elementId); 282 return result; 283 } 284 } 285 | Popular Tags |