Source Code Cross Referenced for JDBCValuePropertyMetaData.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 java.lang.reflect.Method;
025:        import org.jboss.deployment.DeploymentException;
026:        import org.jboss.metadata.MetaData;
027:        import org.w3c.dom.Element;
028:
029:        /**
030:         * Imutable class which contains information about a single dependent
031:         * value object property.
032:         *     
033:         * @author <a href="mailto:dain@daingroup.com">Dain Sundstrom</a>
034:         * @version $Revision: 57209 $
035:         */
036:        public final class JDBCValuePropertyMetaData {
037:            private final String propertyName;
038:            private final Class propertyType;
039:            private final String columnName;
040:            private final String sqlType;
041:            private final int jdbcType;
042:            private final boolean notNull;
043:            private final Method getter;
044:            private final Method setter;
045:
046:            /**
047:             * Constructs a value property metadata class with the data contained in 
048:             * the property xml element from a jbosscmp-jdbc xml file.
049:             *
050:             * @param element the xml Element which contains the metadata about
051:             *       this property
052:             * @param classType the java Class type of the value class on which this 
053:             *       property is defined
054:             * @throws DeploymentException if the xml element is not semantically correct
055:             */
056:            public JDBCValuePropertyMetaData(Element element, Class classType)
057:                    throws DeploymentException {
058:
059:                // Property name
060:                propertyName = MetaData.getUniqueChildContent(element,
061:                        "property-name");
062:
063:                // Column name
064:                String columnNameString = MetaData.getOptionalChildContent(
065:                        element, "column-name");
066:                if (columnNameString != null) {
067:                    columnName = columnNameString;
068:                } else {
069:                    columnName = propertyName;
070:                }
071:
072:                // Not null
073:                Element notNullElement = MetaData.getOptionalChild(element,
074:                        "not-null");
075:                notNull = (notNullElement != null);
076:
077:                // Getter
078:                try {
079:                    getter = classType.getMethod(toGetterName(propertyName),
080:                            new Class[0]);
081:                } catch (Exception e) {
082:                    throw new DeploymentException(
083:                            "Unable to find getter for property "
084:                                    + propertyName
085:                                    + " on dependent value class "
086:                                    + classType.getName());
087:                }
088:
089:                // get property type from getter return type
090:                propertyType = getter.getReturnType();
091:
092:                // resolve setter
093:                try {
094:                    setter = classType.getMethod(toSetterName(propertyName),
095:                            new Class[] { propertyType });
096:                } catch (Exception e) {
097:                    throw new DeploymentException(
098:                            "Unable to find setter for property "
099:                                    + propertyName
100:                                    + " on dependent value class "
101:                                    + classType.getName());
102:                }
103:
104:                // jdbc type - optional
105:                String jdbcString = MetaData.getOptionalChildContent(element,
106:                        "jdbc-type");
107:                if (jdbcString != null) {
108:                    jdbcType = JDBCMappingMetaData
109:                            .getJdbcTypeFromName(jdbcString);
110:
111:                    // sql type - required if jdbc-type specified
112:                    sqlType = MetaData.getUniqueChildContent(element,
113:                            "sql-type");
114:                } else {
115:                    jdbcType = Integer.MIN_VALUE;
116:                    sqlType = null;
117:                }
118:            }
119:
120:            /**
121:             * Gets the name of this property. The name will always begin with a lower
122:             * case letter and is a Java Beans property name.  This is the base name of
123:             * the getter and setter property.
124:             *
125:             * @return the name of this property
126:             */
127:            public String getPropertyName() {
128:                return propertyName;
129:            }
130:
131:            /**
132:             * Gets the java class type of this property. The class the the return type
133:             * of the getter and type of the sole argument of the setter.
134:             *
135:             * @return the java Class type of this property
136:             */
137:            public Class getPropertyType() {
138:                return propertyType;
139:            }
140:
141:            /**
142:             * Gets the column name which this property will be persisted.
143:             *
144:             * @return the name of the column which this property will be persisted
145:             */
146:            public String getColumnName() {
147:                return columnName;
148:            }
149:
150:            /**
151:             * Gets the jdbc type of this property. The jdbc type is used to retrieve
152:             * data from a result set and to set parameters in a prepared statement.
153:             *
154:             * @return the jdbc type of this property
155:             */
156:            public int getJDBCType() {
157:                return jdbcType;
158:            }
159:
160:            /**
161:             * Gets the sql type of this mapping. The sql type is the sql column data 
162:             * type, and is used in CREATE TABLE statements. 
163:             *
164:             * @return the sql type String of this mapping
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:             * Gets the getter method of this property. The getter method is used to 
180:             * retrieve the value of this property from the value class.
181:             *
182:             * @return the Method which gets the value of this property
183:             */
184:            public Method getGetter() {
185:                return getter;
186:            }
187:
188:            /**
189:             * Gets the setter method of this property. The setter method is used to 
190:             * set the value of this property in the value class.
191:             *
192:             * @return the Method which sets the value of this property
193:             */
194:            public Method getSetter() {
195:                return setter;
196:            }
197:
198:            private static String toGetterName(String propertyName) {
199:                return "get" + upCaseFirstCharacter(propertyName);
200:            }
201:
202:            private static String toSetterName(String propertyName) {
203:                return "set" + upCaseFirstCharacter(propertyName);
204:            }
205:
206:            private static String upCaseFirstCharacter(String propertyName) {
207:                return Character.toUpperCase(propertyName.charAt(0))
208:                        + propertyName.substring(1);
209:            }
210:        }
w___ww__.__j_a___v__a2_s_.c__o__m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.