Source Code Cross Referenced for SingleFieldMapping.java in  » Database-ORM » JPOX » org » jpox » store » mapping » 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 » JPOX » org.jpox.store.mapping 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************
002:        Copyright (c) 2002 Mike Martin (TJDO) and others. All rights reserved. 
003:        Licensed under the Apache License, Version 2.0 (the "License");
004:        you may not use this file except in compliance with the License.
005:        You may obtain a copy of the License at
006:
007:            http://www.apache.org/licenses/LICENSE-2.0
008:
009:        Unless required by applicable law or agreed to in writing, software
010:        distributed under the License is distributed on an "AS IS" BASIS,
011:        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012:        See the License for the specific language governing permissions and
013:        limitations under the License.
014:
015:
016:        Contributors:
017:        2003 Andy Jefferson - coding standards
018:        2005 Andy Jefferson - added "value" field for cases where a parameter is put in a query "result"
019:        2006 Andy Jefferson - remove typeInfo
020:            ...
021:         **********************************************************************/package org.jpox.store.mapping;
022:
023:        import org.jpox.ClassLoaderResolver;
024:        import org.jpox.ObjectManager;
025:        import org.jpox.metadata.AbstractMemberMetaData;
026:        import org.jpox.store.DatastoreAdapter;
027:        import org.jpox.store.DatastoreContainerObject;
028:        import org.jpox.store.DatastoreField;
029:        import org.jpox.store.expression.ScalarExpression;
030:
031:        /**
032:         * Simple mapping for a java field mapping to a single datastore field.
033:         * @version $Revision: 1.32 $
034:         **/
035:        public abstract class SingleFieldMapping extends JavaTypeMapping {
036:            /**
037:             * Initialize this JavaTypeMapping with the given DatastoreAdapter for the given FieldMetaData.
038:             * @param dba The Datastore Adapter that this Mapping should use.
039:             * @param fmd FieldMetaData for the field to be mapped (if any)
040:             * @param container The datastore container storing this mapping (if any)
041:             * @param clr the ClassLoaderResolver
042:             */
043:            public void initialize(DatastoreAdapter dba,
044:                    AbstractMemberMetaData fmd,
045:                    DatastoreContainerObject container, ClassLoaderResolver clr) {
046:                super .initialize(dba, fmd, container, clr);
047:                prepareDatastoreMapping();
048:            }
049:
050:            /**
051:             * Method to prepare a field mapping for use in the datastore.
052:             * This creates the column in the table.
053:             */
054:            protected void prepareDatastoreMapping() {
055:                MappingManager mmgr = datastoreContainer.getStoreManager()
056:                        .getMappingManager();
057:                DatastoreField col = mmgr.createDatastoreField(this ,
058:                        getJavaTypeForDatastoreMapping(0), 0);
059:                mmgr.createDatastoreMapping(this , fmd, 0, datastoreContainer
060:                        .getStoreManager(), col);
061:            }
062:
063:            /**
064:             * Accessor for the default length for this type in the datastore (if applicable).
065:             * @param index requested datastore field index.
066:             * @return Default length
067:             */
068:            public int getDefaultLength(int index) {
069:                return -1;
070:            }
071:
072:            /**
073:             * Accessor for an array of valid values that this type can take.
074:             * This can be used at the datastore side for restricting the values to be inserted.
075:             * @param index requested datastore field index.
076:             * @return The valid values
077:             */
078:            public ScalarExpression[] getValidValues(int index) {
079:                return null;
080:            }
081:
082:            /**
083:             * Accessor for the name of the java-type actually used when mapping the particular datastore
084:             * field. This java-type must have an entry in the datastore mappings.
085:             * @param index requested datastore field index.
086:             * @return the name of java-type for the requested datastore field.
087:             */
088:            public String getJavaTypeForDatastoreMapping(int index) {
089:                if (getJavaType() == null) {
090:                    return null;
091:                }
092:                return getJavaType().getName();
093:            }
094:
095:            /**
096:             * Equality operator
097:             * @param obj The object to compare with
098:             * @return Whether the objects are equal
099:             */
100:            public boolean equals(Object obj) {
101:                if (this  == obj) {
102:                    return true;
103:                }
104:
105:                if (!(obj instanceof  SingleFieldMapping)) {
106:                    return false;
107:                }
108:
109:                SingleFieldMapping cm = (SingleFieldMapping) obj;
110:
111:                return getClass().equals(cm.getClass()) && dba.equals(cm.dba);
112:            }
113:
114:            public void setBoolean(ObjectManager om, Object preparedStatement,
115:                    int[] exprIndex, boolean value) {
116:                getDataStoreMapping(0).setBoolean(preparedStatement,
117:                        exprIndex[0], value);
118:            }
119:
120:            public boolean getBoolean(ObjectManager om, Object resultSet,
121:                    int[] exprIndex) {
122:                return getDataStoreMapping(0).getBoolean(resultSet,
123:                        exprIndex[0]);
124:            }
125:
126:            public void setChar(ObjectManager om, Object preparedStatement,
127:                    int[] exprIndex, char value) {
128:                getDataStoreMapping(0).setChar(preparedStatement, exprIndex[0],
129:                        value);
130:            }
131:
132:            public char getChar(ObjectManager om, Object resultSet,
133:                    int[] exprIndex) {
134:                return getDataStoreMapping(0).getChar(resultSet, exprIndex[0]);
135:            }
136:
137:            public void setByte(ObjectManager om, Object preparedStatement,
138:                    int[] exprIndex, byte value) {
139:                getDataStoreMapping(0).setByte(preparedStatement, exprIndex[0],
140:                        value);
141:            }
142:
143:            public byte getByte(ObjectManager om, Object resultSet,
144:                    int[] exprIndex) {
145:                return getDataStoreMapping(0).getByte(resultSet, exprIndex[0]);
146:            }
147:
148:            public void setShort(ObjectManager om, Object preparedStatement,
149:                    int[] exprIndex, short value) {
150:                getDataStoreMapping(0).setShort(preparedStatement,
151:                        exprIndex[0], value);
152:            }
153:
154:            public short getShort(ObjectManager om, Object resultSet,
155:                    int[] exprIndex) {
156:                return getDataStoreMapping(0).getShort(resultSet, exprIndex[0]);
157:            }
158:
159:            public void setInt(ObjectManager om, Object preparedStatement,
160:                    int[] exprIndex, int value) {
161:                getDataStoreMapping(0).setInt(preparedStatement, exprIndex[0],
162:                        value);
163:            }
164:
165:            public int getInt(ObjectManager om, Object resultSet,
166:                    int[] exprIndex) {
167:                return getDataStoreMapping(0).getInt(resultSet, exprIndex[0]);
168:            }
169:
170:            public void setLong(ObjectManager om, Object preparedStatement,
171:                    int[] exprIndex, long value) {
172:                getDataStoreMapping(0).setLong(preparedStatement, exprIndex[0],
173:                        value);
174:            }
175:
176:            public long getLong(ObjectManager om, Object resultSet,
177:                    int[] exprIndex) {
178:                return getDataStoreMapping(0).getLong(resultSet, exprIndex[0]);
179:            }
180:
181:            public void setFloat(ObjectManager om, Object preparedStatement,
182:                    int[] exprIndex, float value) {
183:                getDataStoreMapping(0).setFloat(preparedStatement,
184:                        exprIndex[0], value);
185:            }
186:
187:            public float getFloat(ObjectManager om, Object resultSet,
188:                    int[] exprIndex) {
189:                return getDataStoreMapping(0).getFloat(resultSet, exprIndex[0]);
190:            }
191:
192:            public void setDouble(ObjectManager om, Object preparedStatement,
193:                    int[] exprIndex, double value) {
194:                getDataStoreMapping(0).setDouble(preparedStatement,
195:                        exprIndex[0], value);
196:            }
197:
198:            public double getDouble(ObjectManager om, Object resultSet,
199:                    int[] exprIndex) {
200:                return getDataStoreMapping(0)
201:                        .getDouble(resultSet, exprIndex[0]);
202:            }
203:
204:            public void setString(ObjectManager om, Object preparedStatement,
205:                    int[] exprIndex, String value) {
206:                getDataStoreMapping(0).setString(preparedStatement,
207:                        exprIndex[0], value);
208:            }
209:
210:            public String getString(ObjectManager om, Object resultSet,
211:                    int[] exprIndex) {
212:                return getDataStoreMapping(0)
213:                        .getString(resultSet, exprIndex[0]);
214:            }
215:
216:            public void setObject(ObjectManager om, Object preparedStatement,
217:                    int[] exprIndex, Object value) {
218:                getDataStoreMapping(0).setObject(preparedStatement,
219:                        exprIndex[0], value);
220:            }
221:
222:            public Object getObject(ObjectManager om, Object resultSet,
223:                    int[] exprIndex) {
224:                if (exprIndex == null) {
225:                    return null;
226:                }
227:                return getDataStoreMapping(0)
228:                        .getObject(resultSet, exprIndex[0]);
229:            }
230:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.