Source Code Cross Referenced for JDBCCMPFieldPropertyMetaData.java in  » EJB-Server-JBoss-4.2.1 » server » org » jboss » ejb » plugins » cmp » jdbc » 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 » EJB Server JBoss 4.2.1 » server » org.jboss.ejb.plugins.cmp.jdbc.metadata 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package org.jboss.ejb.plugins.cmp.jdbc.metadata;
023:
024:        import org.jboss.deployment.DeploymentException;
025:        import org.jboss.metadata.MetaData;
026:
027:        import org.w3c.dom.Element;
028:
029:        /**
030:         *   This immutable class contains information about the an overriden field property.
031:         *
032:         * @author <a href="mailto:dain@daingroup.com">Dain Sundstrom</a>
033:         *   @version $Revision: 57209 $
034:         */
035:        public final class JDBCCMPFieldPropertyMetaData {
036:            /**
037:             * the cmp field on which this property is defined
038:             */
039:            private final JDBCCMPFieldMetaData cmpField;
040:
041:            /** 
042:             * name of this property
043:             */
044:            private final String propertyName;
045:
046:            /**
047:             * the column name in the table
048:             */
049:            private final String columnName;
050:
051:            /**
052:             * the jdbc type (see java.sql.Types), used in PreparedStatement.setParameter
053:             */
054:            private final int jdbcType;
055:
056:            /**
057:             * the sql type, used for table creation.
058:             */
059:            private final String sqlType;
060:
061:            /**
062:             * Should null values not be allowed for this property.
063:             */
064:            private final boolean notNull;
065:
066:            /**
067:             * Constructs cmp field property meta data with the data contained in the 
068:             * property xml element from a jbosscmp-jdbc xml file.
069:             *
070:             * @param cmpField the JDBCCMPFieldMetaData on which this property is defined
071:             * @param element the xml Element which contains the metadata about this 
072:             *    field
073:             * @throws DeploymentException if the xml element is not semantically correct
074:             */
075:            public JDBCCMPFieldPropertyMetaData(JDBCCMPFieldMetaData cmpField,
076:                    Element element) throws DeploymentException {
077:
078:                this .cmpField = cmpField;
079:
080:                // Property name
081:                propertyName = MetaData.getUniqueChildContent(element,
082:                        "property-name");
083:
084:                // Column name
085:                String columnStr = MetaData.getOptionalChildContent(element,
086:                        "column-name");
087:                if (columnStr != null) {
088:                    columnName = columnStr;
089:                } else {
090:                    columnName = null;
091:                }
092:
093:                // jdbc type
094:                String jdbcStr = MetaData.getOptionalChildContent(element,
095:                        "jdbc-type");
096:                if (jdbcStr != null) {
097:                    jdbcType = JDBCMappingMetaData.getJdbcTypeFromName(jdbcStr);
098:                    sqlType = MetaData.getUniqueChildContent(element,
099:                            "sql-type");
100:                } else {
101:                    jdbcType = Integer.MIN_VALUE;
102:                    sqlType = null;
103:                }
104:
105:                // notNull
106:                notNull = (MetaData.getOptionalChild(element, "not-null") != null);
107:            }
108:
109:            /**
110:             * Constructs cmp field property meta data based on the data contained in 
111:             * the defaultValues parameter but defined on the specified cmpField. This 
112:             * is effectly a copy constructory, except it can change the cmpField object
113:             * on which the property is defined.
114:             *
115:             * @param cmpField the JDBCCMPFieldMetaData on which this property is defined
116:             * @param defaultValues the defaultValues of this property
117:             */
118:            public JDBCCMPFieldPropertyMetaData(JDBCCMPFieldMetaData cmpField,
119:                    JDBCCMPFieldPropertyMetaData defaultValues) {
120:
121:                this .cmpField = cmpField;
122:
123:                // Property name
124:                propertyName = defaultValues.propertyName;
125:
126:                // Column name
127:                columnName = defaultValues.columnName;
128:
129:                // jdbc type
130:                jdbcType = defaultValues.jdbcType;
131:
132:                // sql type
133:                sqlType = defaultValues.sqlType;
134:
135:                // not-null
136:                notNull = defaultValues.notNull;
137:            }
138:
139:            /**
140:             * Gets the name of the property to be overriden.
141:             */
142:            public String getPropertyName() {
143:                return propertyName;
144:            }
145:
146:            /**
147:             * Gets the column name the property should use or null if the
148:             * column name is not overriden. 
149:             */
150:            public String getColumnName() {
151:                return columnName;
152:            }
153:
154:            /**
155:             * Gets the JDBC type the property should use or Integer.MIN_VALUE 
156:             * if not overriden.
157:             */
158:            public int getJDBCType() {
159:                return jdbcType;
160:            }
161:
162:            /**
163:             * Gets the SQL type the property should use or null 
164:             * if not overriden.
165:             */
166:            public String getSQLType() {
167:                return sqlType;
168:            }
169:
170:            /**
171:             * Should this field allow null values?
172:             * @return true if this field will not allow a null value.
173:             */
174:            public boolean isNotNull() {
175:                return notNull;
176:            }
177:
178:            /**
179:             * Compares this JDBCCMPFieldPropertyMetaData against the specified object.
180:             * Returns true if the objects are the same. Two 
181:             * JDBCCMPFieldPropertyMetaData are the same if they both have the same name
182:             * and are defined on the same cmpField.
183:             * @param o the reference object with which to compare
184:             * @return true if this object is the same as the object argument; false
185:             *    otherwise
186:             */
187:            public boolean equals(Object o) {
188:                if (o instanceof  JDBCCMPFieldPropertyMetaData) {
189:                    JDBCCMPFieldPropertyMetaData cmpFieldProperty = (JDBCCMPFieldPropertyMetaData) o;
190:                    return propertyName.equals(cmpFieldProperty.propertyName)
191:                            && cmpField.equals(cmpFieldProperty.cmpField);
192:                }
193:                return false;
194:            }
195:
196:            /**
197:             * Returns a hashcode for this JDBCCMPFieldPropertyMetaData. The hashcode is
198:             * computed based on the hashCode of the declaring entity and the hashCode
199:             * of the fieldName
200:             * @return a hash code value for this object
201:             */
202:            public int hashCode() {
203:                int result = 17;
204:                result = 37 * result + cmpField.hashCode();
205:                result = 37 * result + propertyName.hashCode();
206:                return result;
207:            }
208:
209:            /**
210:             * Returns a string describing this JDBCCMPFieldPropertyMetaData. The exact
211:             * details of the representation are unspecified and subject to change, but
212:             * the following may be regarded as typical:
213:             * 
214:             * "[JDBCCMPFieldPropertyMetaData: propertyName=line1,
215:             *       [JDBCCMPFieldMetaData: fieldName=address, 
216:             *             [JDBCEntityMetaData: entityName=UserEJB]]"
217:             *
218:             * @return a string representation of the object
219:             */
220:            public String toString() {
221:                return "[JDBCCMPFieldPropertyMetaData : propertyName="
222:                        + propertyName + ", " + cmpField + "]";
223:            }
224:        }
w_ww.j__a_va___2___s_._co_m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.