Source Code Cross Referenced for RepositoryTags.java in  » Database-ORM » db-ojb » org » apache » ojb » broker » metadata » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » db ojb » org.apache.ojb.broker.metadata 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.ojb.broker.metadata;
002:
003:        /* Copyright 2002-2005 The Apache Software Foundation
004:         *
005:         * Licensed under the Apache License, Version 2.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        import org.apache.ojb.broker.util.DoubleHashtable;
019:        import org.apache.ojb.broker.util.logging.LoggerFactory;
020:        import org.apache.ojb.broker.util.pooling.PoolConfiguration;
021:
022:        /**
023:         * this class maintains a table mapping the xml-tags used in the
024:         * repository.dtd to their corresponding ids used within OJB.
025:         * This table is used in <br>
026:         * 1. the RepositoryXmlHandler to identify tags on parsing the
027:         * repository.xml in a large switch statement.
028:         * 2. in the RepositoryPersistor to get the proper tag for a
029:         * given XmlCapable id during assembling the repository.xml
030:         * for output.<br>
031:         * <b>Important note: This class is the only place where XML tags from the
032:         * repository.dtd are maintained.
033:         * All usages of these tags within OJB must use this table to ease
034:         * changes of the DTD.</b>
035:         * @author		Thomas Mahler
036:         */
037:        public class RepositoryTags implements  RepositoryElements {
038:            /**
039:             * the two-way hashtable holding all entries.
040:             */
041:            private DoubleHashtable table;
042:
043:            /**
044:             * the singleton instance of this class.
045:             */
046:            private static RepositoryTags instance = new RepositoryTags();
047:
048:            /**
049:             * private Constructor, please use getInstance() to obtain
050:             * the singleton instance of this class.
051:             */
052:            private RepositoryTags() {
053:                // construct the mapping table
054:                table = new DoubleHashtable();
055:                table.put("descriptor-repository", new Integer(
056:                        MAPPING_REPOSITORY));
057:                table.put("version", new Integer(REPOSITORY_VERSION));
058:                table.put("isolation-level", new Integer(ISOLATION_LEVEL));
059:                table.put("jdbc-connection-descriptor", new Integer(
060:                        JDBC_CONNECTION_DESCRIPTOR));
061:                table.put("platform", new Integer(DBMS_NAME));
062:                table.put("schema", new Integer(SCHEMA_NAME));
063:                table.put("jcd-alias", new Integer(JCD_ALIAS));
064:                table
065:                        .put("default-connection", new Integer(
066:                                DEFAULT_CONNECTION));
067:                table.put("driver", new Integer(DRIVER_NAME));
068:                table.put("protocol", new Integer(URL_PROTOCOL));
069:                table.put("subprotocol", new Integer(URL_SUBPROTOCOL));
070:                table.put("dbalias", new Integer(URL_DBALIAS));
071:                table.put("username", new Integer(USER_NAME));
072:                table.put("password", new Integer(USER_PASSWD));
073:                table.put("eager-release", new Integer(EAGER_RELEASE));
074:                table.put("batch-mode", new Integer(BATCH_MODE));
075:                table.put("useAutoCommit", new Integer(USE_AUTOCOMMIT));
076:                table.put("ignoreAutoCommitExceptions", new Integer(
077:                        IGNORE_AUTOCOMMIT_EXCEPTION));
078:                table.put("class-descriptor", new Integer(CLASS_DESCRIPTOR));
079:                table.put("class", new Integer(CLASS_NAME));
080:                table.put("proxy", new Integer(CLASS_PROXY));
081:                table.put("extent-class", new Integer(CLASS_EXTENT));
082:                table.put("extends", new Integer(EXTENDS));
083:                table.put("table", new Integer(TABLE_NAME));
084:                table.put("orderby", new Integer(ORDERBY));
085:                table.put("conversion", new Integer(FIELD_CONVERSION));
086:                table.put("row-reader", new Integer(ROW_READER));
087:                table.put("field-descriptor", new Integer(FIELD_DESCRIPTOR));
088:                table.put("name", new Integer(FIELD_NAME));
089:                table.put("column", new Integer(COLUMN_NAME));
090:                table.put("jdbc-type", new Integer(JDBC_TYPE));
091:                table.put("primarykey", new Integer(PRIMARY_KEY));
092:                table.put("autoincrement", new Integer(AUTO_INCREMENT));
093:                table.put("sequence-name", new Integer(SEQUENCE_NAME));
094:                table.put("nullable", new Integer(NULLABLE));
095:                table.put("indexed", new Integer(INDEXED));
096:                table.put("length", new Integer(LENGTH));
097:                table.put("precision", new Integer(PRECISION));
098:                table.put("scale", new Integer(SCALE));
099:                table.put(TAG_ACCESS, new Integer(ACCESS));
100:
101:                table.put("reference-descriptor", new Integer(
102:                        REFERENCE_DESCRIPTOR));
103:                table.put("class-ref", new Integer(REFERENCED_CLASS));
104:                table.put("foreignkey", new Integer(FOREIGN_KEY));
105:                table.put("auto-retrieve", new Integer(AUTO_RETRIEVE));
106:                table.put("auto-update", new Integer(AUTO_UPDATE));
107:                table.put("auto-delete", new Integer(AUTO_DELETE));
108:                table.put("collection-descriptor", new Integer(
109:                        COLLECTION_DESCRIPTOR));
110:                table.put("element-class-ref", new Integer(ITEMS_CLASS));
111:                table.put("inverse-foreignkey", new Integer(INVERSE_FK));
112:                table.put("collection-class", new Integer(COLLECTION_CLASS));
113:                table.put("indirection-table", new Integer(INDIRECTION_TABLE));
114:                table.put("fk-pointing-to-element-class", new Integer(
115:                        FK_POINTING_TO_ITEMS_CLASS));
116:                table.put("fk-pointing-to-this-class", new Integer(
117:                        FK_POINTING_TO_THIS_CLASS));
118:                table.put("jndi-datasource-name", new Integer(DATASOURCE_NAME));
119:                table.put("jdbc-level", new Integer(JDBC_LEVEL));
120:                table.put("locking", new Integer(LOCKING));
121:                table.put("update-lock", new Integer(UPDATE_LOCK));
122:                table.put("refresh", new Integer(REFRESH));
123:                table.put("proxy", new Integer(PROXY_REFERENCE));
124:                table.put("sort", new Integer(SORT));
125:                table.put("otm-dependent", new Integer(OTM_DEPENDENT));
126:
127:                table.put("index-descriptor", new Integer(INDEX_DESCRIPTOR));
128:                table.put("index-column", new Integer(INDEX_COLUMN));
129:                table.put("unique", new Integer(UNIQUE));
130:                table.put("name", new Integer(NAME));
131:
132:                table.put(PoolConfiguration.MAX_ACTIVE, new Integer(
133:                        CON_MAX_ACTIVE));
134:                table
135:                        .put(PoolConfiguration.MAX_IDLE, new Integer(
136:                                CON_MAX_IDLE));
137:                table
138:                        .put(PoolConfiguration.MAX_WAIT, new Integer(
139:                                CON_MAX_WAIT));
140:                table.put(PoolConfiguration.MIN_EVICTABLE_IDLE_TIME_MILLIS,
141:                        new Integer(CON_MIN_EVICTABLE_IDLE_TIME_MILLIS));
142:                table.put(PoolConfiguration.NUM_TESTS_PER_EVICTION_RUN,
143:                        new Integer(CON_NUM_TESTS_PER_EVICTION_RUN));
144:                table.put(PoolConfiguration.TEST_ON_BORROW, new Integer(
145:                        CON_TEST_ON_BORROW));
146:                table.put(PoolConfiguration.TEST_ON_RETURN, new Integer(
147:                        CON_TEST_ON_RETURN));
148:                table.put(PoolConfiguration.TEST_WHILE_IDLE, new Integer(
149:                        CON_TEST_WHILE_IDLE));
150:                table.put(PoolConfiguration.TIME_BETWEEN_EVICTION_RUNS_MILLIS,
151:                        new Integer(CON_TIME_BETWEEN_EVICTION_RUNS_MILLIS));
152:                table.put(PoolConfiguration.WHEN_EXHAUSTED_ACTION, new Integer(
153:                        CON_WHEN_EXHAUSTED_ACTION));
154:                table.put(PoolConfiguration.VALIDATION_QUERY, new Integer(
155:                        VALIDATION_QUERY));
156:
157:                table.put(PoolConfiguration.LOG_ABANDONED, new Integer(
158:                        CON_LOG_ABANDONED));
159:                table.put(PoolConfiguration.REMOVE_ABANDONED, new Integer(
160:                        CON_REMOVE_ABANDONED));
161:                table.put(PoolConfiguration.REMOVE_ABANDONED_TIMEOUT,
162:                        new Integer(CON_REMOVE_ABANDONED_TIMEOUT));
163:
164:                table.put("connectionFactory", new Integer(CONNECTION_FACTORY));
165:                table.put("connection-pool", new Integer(CONNECTION_POOL));
166:                table.put("class-ref", new Integer(CLASS_REF));
167:                table.put("id", new Integer(ID));
168:                table.put("field-id-ref", new Integer(FIELD_ID_REF));
169:                table.put("field-ref", new Integer(FIELD_REF));
170:                table.put("attribute", new Integer(ATTRIBUTE));
171:                table.put("attribute-name", new Integer(ATTRIBUTE_NAME));
172:                table.put("attribute-value", new Integer(ATTRIBUTE_VALUE));
173:                table.put("documentation", new Integer(DOCUMENTATION));
174:                table.put("accept-locks", new Integer(ACCEPT_LOCKS));
175:
176:                table.put("sequence-manager", new Integer(SEQUENCE_MANAGER));
177:                table.put("className", new Integer(SEQUENCE_MANAGER_CLASS));
178:
179:                table.put("query-customizer", new Integer(QUERY_CUSTOMIZER));
180:                table.put("initialization-method", new Integer(
181:                        INITIALIZATION_METHOD));
182:                table.put("factory-class", new Integer(FACTORY_CLASS));
183:                table.put("factory-method", new Integer(FACTORY_METHOD));
184:
185:                table.put("insert-procedure", new Integer(INSERT_PROCEDURE));
186:                table.put("update-procedure", new Integer(UPDATE_PROCEDURE));
187:                table.put("delete-procedure", new Integer(DELETE_PROCEDURE));
188:                table.put("constant-argument", new Integer(CONSTANT_ARGUMENT));
189:                table.put("runtime-argument", new Integer(RUNTIME_ARGUMENT));
190:                table.put("return", new Integer(RETURN));
191:                table.put("value", new Integer(VALUE));
192:                table.put("return-field-ref", new Integer(RETURN_FIELD_REF));
193:                table.put("include-pk-only",
194:                        new Integer(INCLUDE_PK_FIELDS_ONLY));
195:                table
196:                        .put("include-all-fields", new Integer(
197:                                INCLUDE_ALL_FIELDS));
198:
199:                table.put("object-cache", new Integer(OBJECT_CACHE));
200:
201:                table.put("proxy-prefetching-limit", new Integer(
202:                        PROXY_PREFETCHING_LIMIT));
203:
204:                // add new tags here !
205:            }
206:
207:            /**
208:             * returns the singleton instance.
209:             */
210:            public static RepositoryTags getInstance() {
211:                return instance;
212:            }
213:
214:            /**
215:             * returns the xml-tag literal associated with the repository element with
216:             * id <code>elementId</code>.
217:             * @return the resulting tag
218:             */
219:            public String getTagById(int elementId) {
220:                return (String) table.getKeyByValue(new Integer(elementId));
221:            }
222:
223:            /**
224:             * returns the opening xml-tag associated with the repository element with
225:             * id <code>elementId</code>.
226:             * @return the resulting tag
227:             */
228:            public String getOpeningTagById(int elementId) {
229:                return "<" + table.getKeyByValue(new Integer(elementId)) + ">";
230:            }
231:
232:            /**
233:             * returns the opening but non-closing xml-tag
234:             * associated with the repository element with
235:             * id <code>elementId</code>.
236:             * @return the resulting tag
237:             */
238:            public String getOpeningTagNonClosingById(int elementId) {
239:                return "<" + table.getKeyByValue(new Integer(elementId));
240:            }
241:
242:            /**
243:             * returns the opening xml-tag associated with the repository element with
244:             * id <code>elementId</code>.
245:             * @return the resulting tag
246:             */
247:            public String getOpeningTagById(int elementId, String attributes) {
248:                return "<" + table.getKeyByValue(new Integer(elementId)) + " "
249:                        + attributes + ">";
250:            }
251:
252:            /**
253:             * returns the opening but non-closing xml-tag
254:             * associated with the repository element with
255:             * id <code>elementId</code>.
256:             * @return the resulting tag
257:             */
258:            public String getAttribute(int elementId, String value) {
259:                return table.getKeyByValue(new Integer(elementId)) + "=\""
260:                        + value + "\"";
261:            }
262:
263:            /**
264:             * returns the closing xml-tag associated with the repository element with
265:             * id <code>elementId</code>.
266:             * @return the resulting tag
267:             */
268:            public String getClosingTagById(int elementId) {
269:                return "</" + table.getKeyByValue(new Integer(elementId)) + ">";
270:            }
271:
272:            /**
273:             * returns the repository element id associated with the xml-tag
274:             * literal <code>tag</code>.
275:             * @return the resulting repository element id.
276:             * @throws NullPointerException if no value was found for <b>tag</b>
277:             */
278:            public int getIdByTag(String tag) {
279:                Integer value = (Integer) table.getValueByKey(tag);
280:                if (value == null)
281:                    LoggerFactory.getDefaultLogger().error(
282:                            "** " + this .getClass().getName() + ": Tag '" + tag
283:                                    + "' is not defined. **");
284:                return value.intValue();
285:            }
286:
287:            /**
288:             * returns the opening xml-tag associated with the repository element with
289:             * id <code>elementId</code>.
290:             * @return the resulting tag
291:             */
292:            public String getCompleteTagById(int elementId, String characters) {
293:                String result = getOpeningTagById(elementId);
294:                result += characters;
295:                result += getClosingTagById(elementId);
296:                return result;
297:            }
298:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.