Source Code Cross Referenced for Field.java in  » Database-ORM » castor » org » castor » ddlgen » schemaobject » 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 » castor » org.castor.ddlgen.schemaobject 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006 Le Duc Bao, Ralf Joachim
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005:         * use this file except in compliance with the License. You may obtain a copy of
006:         * the License at
007:         * 
008:         * http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013:         * License for the specific language governing permissions and limitations under
014:         * the License.
015:         */
016:        package org.castor.ddlgen.schemaobject;
017:
018:        import org.apache.commons.logging.Log;
019:        import org.apache.commons.logging.LogFactory;
020:        import org.castor.ddlgen.DDLWriter;
021:        import org.castor.ddlgen.GeneratorException;
022:        import org.castor.ddlgen.typeinfo.TypeInfo;
023:
024:        /**
025:         * Abstract base class of all field implementations.
026:         * 
027:         * @author <a href="mailto:leducbao AT gmail DOT com">Le Duc Bao</a>
028:         * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a>
029:         * @version $Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
030:         * @since 1.1
031:         */
032:        public abstract class Field extends AbstractSchemaObject {
033:            //--------------------------------------------------------------------------
034:
035:            /** The <a href="http://jakarta.apache.org/commons/logging/">Jakarta Commons
036:             *  Logging </a> instance used for all logging. */
037:            private static final Log LOG = LogFactory.getLog(Field.class);
038:
039:            //--------------------------------------------------------------------------
040:
041:            /** Key generator for this field. */
042:            private KeyGenerator _keyGenerator;
043:
044:            /** Is this field part of the identity? */
045:            private boolean _isIdentity;
046:
047:            /** Is this field a required one? */
048:            private boolean _isRequired;
049:
050:            /** Type information of this field. */
051:            private TypeInfo _type;
052:
053:            /** Table which contains this field. */
054:            private Table _table;
055:
056:            //--------------------------------------------------------------------------
057:
058:            /**
059:             * Set key generator for this field. <code>null</code> if the field has no key
060:             * generator.
061:             * 
062:             * @param keyGenerator Key generator for this field.
063:             */
064:            public final void setKeyGenerator(final KeyGenerator keyGenerator) {
065:                _keyGenerator = keyGenerator;
066:            }
067:
068:            /**
069:             * Get key generator for this field.
070:             * 
071:             * @return Key generator for this field.
072:             */
073:            public final KeyGenerator getKeyGenerator() {
074:                return _keyGenerator;
075:            }
076:
077:            /**
078:             * Set if this field is part of the identity?
079:             * 
080:             * @param isIdentity <code>true</code> if the field is part of the identity,
081:             *        <code>true</code> otherwise.
082:             */
083:            public final void setIdentity(final boolean isIdentity) {
084:                _isIdentity = isIdentity;
085:            }
086:
087:            /**
088:             * Get if this field is part of the identity?
089:             * 
090:             * @return <code>true</code> if the field is part of the identity,
091:             *         <code>true</code> otherwise.
092:             */
093:            public final boolean isIdentity() {
094:                return _isIdentity;
095:            }
096:
097:            /**
098:             * Set if this field is a required one?
099:             * 
100:             * @param isRequired <code>true</code> if the field is required, <code>true</code>
101:             *        otherwise.
102:             */
103:            public final void setRequired(final boolean isRequired) {
104:                _isRequired = isRequired;
105:            }
106:
107:            /**
108:             * Get if this field is a required one?
109:             * 
110:             * @return <code>true</code> if the field is required, <code>true</code>
111:             *         otherwise.
112:             */
113:            public final boolean isRequired() {
114:                return _isRequired;
115:            }
116:
117:            /**
118:             * Set type information of this field.
119:             * 
120:             * @param type Type information of this field.
121:             */
122:            public final void setType(final TypeInfo type) {
123:                _type = type;
124:            }
125:
126:            /**
127:             * Get type information of this field.
128:             * 
129:             * @return Type information of this field.
130:             */
131:            public final TypeInfo getType() {
132:                return _type;
133:            }
134:
135:            /**
136:             * Set table which contains this field.
137:             * 
138:             * @param table Table which contains this field.
139:             */
140:            public final void setTable(final Table table) {
141:                _table = table;
142:            }
143:
144:            /**
145:             * Get table which contains this field.
146:             * 
147:             * @return Table which contains this field.
148:             */
149:            public final Table getTable() {
150:                return _table;
151:            }
152:
153:            //--------------------------------------------------------------------------
154:
155:            /**
156:             * Get length parameter from mapping of sql field.
157:             * <br/>
158:             * Returns <code>null</code> as it is not supported yet.
159:             * 
160:             * @return length Length parameter from mapping of sql field.
161:             */
162:            public final Integer getLength() {
163:                return null;
164:            }
165:
166:            /**
167:             * Get precision parameter from mapping of sql field.
168:             * <br/>
169:             * Returns <code>null</code> as it is not supported yet.
170:             * 
171:             * @return precision Precision parameter from mapping of sql field.
172:             */
173:            public final Integer getPrecision() {
174:                return null;
175:            }
176:
177:            /**
178:             * Get decimals parameter from mapping of sql field.
179:             * <br/>
180:             * Returns <code>null</code> as it is not supported yet.
181:             * 
182:             * @return decimals Decimals parameter from mapping of sql field.
183:             */
184:            public final Integer getDecimals() {
185:                return null;
186:            }
187:
188:            //--------------------------------------------------------------------------
189:
190:            /**
191:             * {@inheritDoc}
192:             */
193:            public final void toDropDDL(final DDLWriter writer) {
194:            }
195:
196:            //--------------------------------------------------------------------------
197:
198:            /**
199:             * Check if given field can be merged with this one.
200:             * 
201:             * @param field Field to check if it is able to be merged.
202:             * @throws GeneratorException If fields cannot be merged.
203:             */
204:            public final void merge(final Field field)
205:                    throws GeneratorException {
206:                if (field == null) {
207:                    String msg = "Field to merge is missing.";
208:                    LOG.error(msg);
209:                    throw new GeneratorException(msg);
210:                }
211:
212:                if (!equals(getName(), field.getName())) {
213:                    String msg = "Name of field differs from: " + getName();
214:                    LOG.error(msg);
215:                    throw new GeneratorException(msg);
216:                }
217:
218:                if (!equals(getTable(), field.getTable())) {
219:                    String msg = "Table of field differs from: "
220:                            + getTable().getName();
221:                    LOG.error(msg);
222:                    throw new GeneratorException(msg);
223:                }
224:
225:                if (_isIdentity != field._isIdentity) {
226:                    LOG
227:                            .warn("Merge table: Field 'identity' attributes are different");
228:                }
229:
230:                if (_isRequired != field._isRequired) {
231:                    LOG
232:                            .warn("Merge table: Field 'required' attributes are different");
233:                }
234:
235:                _type.merge(field._type);
236:            }
237:
238:            //--------------------------------------------------------------------------
239:
240:            /**
241:             * {@inheritDoc}
242:             */
243:            public final boolean equals(final Object other) {
244:                if (other == this ) {
245:                    return true;
246:                }
247:                if (other == null) {
248:                    return false;
249:                }
250:                if (other.getClass() != this .getClass()) {
251:                    return false;
252:                }
253:
254:                Field field = (Field) other;
255:                return equals(getName(), field.getName())
256:                        && equals(_table, field._table)
257:                        && equals(_type, field._type)
258:                        && (_isRequired == field._isRequired)
259:                        && (_isIdentity == field._isIdentity)
260:                        && equals(_keyGenerator, field._keyGenerator);
261:            }
262:
263:            /**
264:             * {@inheritDoc}
265:             */
266:            public final int hashCode() {
267:                int hashCode = 0;
268:                if (getName() != null) {
269:                    hashCode += getName().hashCode();
270:                }
271:                hashCode *= HASHFACTOR;
272:                if (_table != null) {
273:                    hashCode += _table.hashCode();
274:                }
275:                hashCode *= HASHFACTOR;
276:                if (_type != null) {
277:                    hashCode += _type.hashCode();
278:                }
279:                hashCode *= HASHFACTOR;
280:                hashCode += Boolean.valueOf(_isRequired).hashCode();
281:                hashCode *= HASHFACTOR;
282:                hashCode += Boolean.valueOf(_isIdentity).hashCode();
283:                hashCode *= HASHFACTOR;
284:                if (_keyGenerator != null) {
285:                    hashCode += _keyGenerator.hashCode();
286:                }
287:                return hashCode;
288:            }
289:
290:            //--------------------------------------------------------------------------
291:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.