Source Code Cross Referenced for DBColumn.java in  » Database-ORM » db-ojb » org » apache » ojb » tools » mapping » reversedb » 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.tools.mapping.reversedb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.ojb.tools.mapping.reversedb;
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:        /**
019:         *
020:         * @author <a href="mailto:bfl@florianbruckner.com">Florian Bruckner</a> 
021:         * @version $Id: DBColumn.java,v 1.1.2.1 2005/12/21 22:32:04 tomdz Exp $
022:         */
023:        public class DBColumn implements  MetadataNodeInterface,
024:                javax.swing.tree.TreeNode,
025:                org.apache.ojb.tools.mapping.reversedb.gui.PropertySheetModel {
026:            private DBTable aTable;
027:            private String strColumnName;
028:            private String strJavaFieldName;
029:            private String strJavaFieldType;
030:            private int iColumnType;
031:            private String strColumnTypeName;
032:            private boolean isPrimaryKeyPart = false;
033:            private boolean bAutoIncrement = false;
034:
035:            private boolean enabled = true;
036:
037:            /** Creates a new instance of DBColumn */
038:
039:            public DBColumn(java.sql.DatabaseMetaData pdbMeta, DBTable paTable,
040:                    String pstrColumnName, int piColumnType,
041:                    String pstrColumnTypeName) {
042:                aTable = paTable;
043:                strColumnName = pstrColumnName;
044:                /*    this.strJavaFieldName = Character.toLowerCase(pstrColumnName.charAt(0)) 
045:                 + pstrColumnName.substring(1);*/
046:                this .strJavaFieldName = Namer.nameField(this .strColumnName);
047:                iColumnType = piColumnType;
048:                this .strJavaFieldType = Utilities.hmJDBCTypeToJavaType.get(
049:                        new Integer(iColumnType)).toString();
050:                strColumnTypeName = pstrColumnTypeName;
051:            }
052:
053:            public boolean getAutoIncrement() {
054:                return this .bAutoIncrement;
055:            }
056:
057:            public void setAutoIncrement(boolean b) {
058:                this .bAutoIncrement = b;
059:            }
060:
061:            public boolean isEnabled() {
062:                return this .enabled;
063:            }
064:
065:            public void setEnabled(boolean b) {
066:                this .enabled = b;
067:            }
068:
069:            public int getColumnType() {
070:                return this .iColumnType;
071:            }
072:
073:            public String getJavaFieldName() {
074:                return this .strJavaFieldName;
075:            }
076:
077:            public void setJavaFieldName(String s) {
078:                this .strJavaFieldName = s;
079:            }
080:
081:            public String getJavaFieldType() {
082:                return this .strJavaFieldType;
083:            }
084:
085:            public void setJavaFieldType(String s) {
086:                this .strJavaFieldType = s;
087:            }
088:
089:            public void setColumnType(int i) {
090:                this .iColumnType = i;
091:            }
092:
093:            public void setColumnType(String s) {
094:                Integer i = (Integer) Utilities.mJDBCNameToType.get(s);
095:                if (i != null) {
096:                    this .iColumnType = i.intValue();
097:                }
098:            }
099:
100:            public String getColumnTypeName() {
101:                return this .strColumnTypeName;
102:            }
103:
104:            public DBTable getDBTable() {
105:                return this .aTable;
106:            }
107:
108:            public boolean isTreeEnabled() {
109:                return this .aTable.isTreeEnabled() && this .isEnabled();
110:            }
111:
112:            public void read() throws java.sql.SQLException {
113:            }
114:
115:            public void generateReferences() throws java.sql.SQLException {
116:            }
117:
118:            public void setPrimaryKeyPart(boolean b) {
119:                this .isPrimaryKeyPart = b;
120:            }
121:
122:            public boolean isPrimaryKeyPart() {
123:                return this .isPrimaryKeyPart;
124:            }
125:
126:            public String getColumnName() {
127:                return this .strColumnName;
128:            }
129:
130:            public java.util.Enumeration children() {
131:                return null;
132:            }
133:
134:            public boolean getAllowsChildren() {
135:                return false;
136:            }
137:
138:            public javax.swing.tree.TreeNode getChildAt(int param) {
139:                return null;
140:            }
141:
142:            public int getChildCount() {
143:                return 0;
144:            }
145:
146:            public int getIndex(javax.swing.tree.TreeNode treeNode) {
147:                return 0;
148:            }
149:
150:            public javax.swing.tree.TreeNode getParent() {
151:                return this .aTable;
152:            }
153:
154:            public boolean isLeaf() {
155:                return true;
156:            }
157:
158:            public String toString() {
159:                if (this .isPrimaryKeyPart)
160:                    return strColumnName + " (PK)";
161:                else
162:                    return this .strColumnName;
163:            }
164:
165:            public Class getPropertySheetClass() {
166:                return org.apache.ojb.tools.mapping.reversedb.gui.DBColumnPropertySheet.class;
167:            }
168:
169:            public String getXML() {
170:                if (this .isTreeEnabled()) {
171:                    java.io.StringWriter sw = new java.io.StringWriter();
172:                    writeXML(new java.io.PrintWriter(sw));
173:                    return sw.getBuffer().toString();
174:                    /*        
175:                     String strReturn =  
176:                     "  <field-descriptor id=\"" + this.id + "\"" + System.getProperty("line.separator")
177:                     +  "    name=\"" + this.strJavaFieldName + "\"" + System.getProperty("line.separator")
178:                     +  "    column=\"" + this.strColumnName + "\"" + System.getProperty("line.separator")
179:                     +  "    jdbc-type=\"" + Utilities.hmJDBCTypeToName.get(new Integer(this.iColumnType)) + "\"" + System.getProperty("line.separator");
180:                     if (this.isPrimaryKeyPart())
181:                     strReturn += "    primarykey=\"true\"" + System.getProperty("line.separator");
182:                     if (this.getAutoIncrement())
183:                     strReturn += "    <autoincrement>true</autoincrement>" + System.getProperty("line.separator");
184:                     strReturn += "  />";
185:                     return strReturn;      
186:                     */
187:                } else
188:                    return "";
189:
190:            }
191:
192:            public void writeXML(java.io.PrintWriter pw) {
193:                pw.println("  <field-descriptor ");
194:                pw.println("     name=\"" + this .strJavaFieldName + "\"");
195:                pw.println("     column=\"" + this .strColumnName + "\"");
196:                pw.println("     jdbc-type=\""
197:                        + Utilities.hmJDBCTypeToName.get(new Integer(
198:                                this .iColumnType)) + "\"");
199:                if (this .isPrimaryKeyPart())
200:                    pw.println("     primarykey=\"true\"");
201:                if (this .getAutoIncrement())
202:                    pw.println("     <autoincrement>true</autoincrement>");
203:                pw.println("  />");
204:            }
205:
206:            public void generateJava(java.io.File aFile, String strHeader,
207:                    String strFooter) throws java.io.IOException,
208:                    java.io.FileNotFoundException {
209:                throw new UnsupportedOperationException(
210:                        "Generate Java on DBColumn is not allowed");
211:            }
212:
213:            public void setPackage(String packageName) {
214:                throw new UnsupportedOperationException(
215:                        "Set Package on DBColumn is not allowed");
216:            }
217:
218:            public String getJavaFieldDefinition() {
219:                if (this .isTreeEnabled()) {
220:                    return "  private " + this .getJavaFieldType() + " "
221:                            + this .getJavaFieldName() + ";";
222:                } else
223:                    return "";
224:            }
225:
226:            public String getJavaGetterSetterDefinition() {
227:                if (this .isTreeEnabled()) {
228:                    String strReturn = "";
229:                    strReturn = "  public "
230:                            + this .getJavaFieldType()
231:                            + " get"
232:                            + this .getJavaFieldName().substring(0, 1)
233:                                    .toUpperCase()
234:                            + this .getJavaFieldName().substring(1) + "()"
235:                            + System.getProperty("line.separator");
236:
237:                    strReturn += "  {" + System.getProperty("line.separator");
238:                    strReturn += "     return this." + this .getJavaFieldName()
239:                            + ";" + System.getProperty("line.separator");
240:                    strReturn += "  }" + System.getProperty("line.separator");
241:                    strReturn += "  public void set"
242:                            + this .getJavaFieldName().substring(0, 1)
243:                                    .toUpperCase()
244:                            + this .getJavaFieldName().substring(1) + "("
245:                            + this .getJavaFieldType() + " param)"
246:                            + System.getProperty("line.separator");
247:                    strReturn += "  {" + System.getProperty("line.separator");
248:                    strReturn += "    this." + this .getJavaFieldName()
249:                            + " = param;"
250:                            + System.getProperty("line.separator");
251:                    strReturn += "  }" + System.getProperty("line.separator");
252:                    return strReturn;
253:                } else
254:                    return "";
255:            }
256:
257:            /**
258:             *  @deprecated
259:             */
260:            public int getId() {
261:                return 0;
262:            }
263:
264:        }
265:
266:        /***************************** Changelog *****************************
267:         // $Log: DBColumn.java,v $
268:         // Revision 1.1.2.1  2005/12/21 22:32:04  tomdz
269:         // Updated license
270:         //
271:         // Revision 1.1  2004/05/05 16:39:05  arminw
272:         // fix fault
273:         // wrong package structure used:
274:         // org.apache.ojb.tools.reversdb
275:         // org.apache.ojb.tools.reversdb2
276:         //
277:         // instead of
278:         // org.apache.ojb.tools.mapping.reversdb
279:         // org.apache.ojb.tools.mapping.reversdb2
280:         //
281:         // Revision 1.1  2004/05/04 13:45:00  arminw
282:         // move reverseDB stuff
283:         //
284:         // Revision 1.9  2004/04/04 23:53:42  brianm
285:         // Fixed initial copyright dates to match cvs repository
286:         //
287:         // Revision 1.8  2004/03/11 18:16:22  brianm
288:         // ASL 2.0
289:         //
290:         // Revision 1.7  2003/12/12 16:37:16  brj
291:         // removed unnecessary casts, semicolons etc.
292:         //
293:         // Revision 1.6  2003/07/22 11:05:13  florianbruckner
294:         // add a name beautifier (courtesy G.Wayne Kidd)
295:         //
296:         // Revision 1.5  2003/06/21 10:27:45  florianbruckner
297:         // implement XML generation with PrintWriter; getXML() still works and uses writeXML(java.io.PrintWriter)
298:         // getId() is deprecated and returns 0 now; Ids are not used for XML generation.
299:         //
300:         // Revision 1.4  2003/01/28 21:42:53  florianbruckner
301:         // update XML generation
302:         //
303:         // Revision 1.3  2003/01/28 19:59:14  florianbruckner
304:         // some updates to schema reading to make it a bit more compatible
305:         //
306:         // Revision 1.2  2002/06/17 19:34:33  jvanzyl
307:         // Correcting all the package references.
308:         // PR:
309:         // Obtained from:
310:         // Submitted by:
311:         // Reviewed by:
312:         //
313:         // Revision 1.1.1.1  2002/06/17 18:16:51  jvanzyl
314:         // Initial OJB import
315:         //
316:         // Revision 1.2  2002/05/16 11:47:09  florianbruckner
317:         // fix CR/LF issue, change license to ASL
318:         //
319:         // Revision 1.1  2002/04/18 11:44:16  mpoeschl
320:         //
321:         // move files to new location
322:         //
323:         // Revision 1.4  2002/04/09 17:08:32  thma
324:         // *** empty log message ***
325:         //
326:         // Revision 1.3  2002/04/07 09:05:16  thma
327:         // *** empty log message ***
328:         //
329:         // Revision 1.2  2002/03/11 17:36:05  florianbruckner
330:         // fix line break issue for these files that were previously checked in with -kb
331:         //
332:         // Revision 1.1  2002/03/04 17:19:32  thma
333:         // initial checking for Florians Reverse engineering tool
334:         //
335:         // Revision 1.1.1.1  2002/02/20 13:35:25  Administrator
336:         // initial import
337:         //
338:         /***************************** Changelog *****************************/
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.