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


001:        package org.apache.ojb.jdori.sql;
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:        import javax.jdo.spi.PersistenceCapable;
019:
020:        import org.apache.ojb.broker.PersistenceBroker;
021:        import org.apache.ojb.broker.metadata.AttributeDescriptorBase;
022:        import org.apache.ojb.broker.metadata.ClassDescriptor;
023:
024:        import com.sun.jdori.FieldManager;
025:        import com.sun.jdori.model.jdo.JDOClass;
026:        import com.sun.jdori.model.jdo.JDOField;
027:
028:        /**
029:         * @author Thomas Mahler
030:         */
031:        public class OjbFieldManager implements  FieldManager {
032:
033:            private PersistenceCapable pc;
034:
035:            private PersistenceBroker broker;
036:
037:            /**
038:             * Constructor for OjbFieldManager.
039:             */
040:            public OjbFieldManager() {
041:                super ();
042:            }
043:
044:            /**
045:             * Constructor for OjbFieldManager.
046:             */
047:            public OjbFieldManager(PersistenceCapable pPc) {
048:                pc = pPc;
049:            }
050:
051:            /**
052:             * Constructor for OjbFieldManager.
053:             */
054:            public OjbFieldManager(PersistenceCapable pPc,
055:                    PersistenceBroker pBroker) {
056:                pc = pPc;
057:                broker = pBroker;
058:            }
059:
060:            /**
061:             * @see com.sun.jdori.FieldManager#storeBooleanField(int, boolean)
062:             */
063:            public void storeBooleanField(int fieldNum, boolean value) {
064:            }
065:
066:            /**
067:             * @see com.sun.jdori.FieldManager#fetchBooleanField(int)
068:             */
069:            public boolean fetchBooleanField(int fieldNum) {
070:                Boolean value = (Boolean) getValue(fieldNum);
071:                return value.booleanValue();
072:            }
073:
074:            /**
075:             * @see com.sun.jdori.FieldManager#storeCharField(int, char)
076:             */
077:            public void storeCharField(int fieldNum, char value) {
078:            }
079:
080:            /**
081:             * @see com.sun.jdori.FieldManager#fetchCharField(int)
082:             */
083:            public char fetchCharField(int fieldNum) {
084:                Character value = (Character) getValue(fieldNum);
085:                return value.charValue();
086:            }
087:
088:            /**
089:             * @see com.sun.jdori.FieldManager#storeByteField(int, byte)
090:             */
091:            public void storeByteField(int fieldNum, byte value) {
092:            }
093:
094:            /**
095:             * @see com.sun.jdori.FieldManager#fetchByteField(int)
096:             */
097:            public byte fetchByteField(int fieldNum) {
098:                Byte value = (Byte) getValue(fieldNum);
099:                return value.byteValue();
100:            }
101:
102:            /**
103:             * @see com.sun.jdori.FieldManager#storeShortField(int, short)
104:             */
105:            public void storeShortField(int fieldNum, short value) {
106:            }
107:
108:            /**
109:             * @see com.sun.jdori.FieldManager#fetchShortField(int)
110:             */
111:            public short fetchShortField(int fieldNum) {
112:                Short value = (Short) getValue(fieldNum);
113:                return value.shortValue();
114:            }
115:
116:            /**
117:             * @see com.sun.jdori.FieldManager#storeIntField(int, int)
118:             */
119:            public void storeIntField(int fieldNum, int value) {
120:            }
121:
122:            /**
123:             * @see com.sun.jdori.FieldManager#fetchIntField(int)
124:             */
125:            public int fetchIntField(int fieldNum) {
126:                Integer value = (Integer) getValue(fieldNum);
127:                return value.intValue();
128:            }
129:
130:            /**
131:             * @see com.sun.jdori.FieldManager#storeLongField(int, long)
132:             */
133:            public void storeLongField(int fieldNum, long value) {
134:            }
135:
136:            /**
137:             * @see com.sun.jdori.FieldManager#fetchLongField(int)
138:             */
139:            public long fetchLongField(int fieldNum) {
140:                Long value = (Long) getValue(fieldNum);
141:                return value.longValue();
142:            }
143:
144:            /**
145:             * @see com.sun.jdori.FieldManager#storeFloatField(int, float)
146:             */
147:            public void storeFloatField(int fieldNum, float value) {
148:            }
149:
150:            /**
151:             * @see com.sun.jdori.FieldManager#fetchFloatField(int)
152:             */
153:            public float fetchFloatField(int fieldNum) {
154:                Float value = (Float) getValue(fieldNum);
155:                return value.floatValue();
156:            }
157:
158:            /**
159:             * @see com.sun.jdori.FieldManager#storeDoubleField(int, double)
160:             */
161:            public void storeDoubleField(int fieldNum, double value) {
162:            }
163:
164:            /**
165:             * @see com.sun.jdori.FieldManager#fetchDoubleField(int)
166:             */
167:            public double fetchDoubleField(int fieldNum) {
168:                Double value = (Double) getValue(fieldNum);
169:                return value.doubleValue();
170:            }
171:
172:            /**
173:             * @see com.sun.jdori.FieldManager#storeStringField(int, String)
174:             */
175:            public void storeStringField(int fieldNum, String value) {
176:            }
177:
178:            /**
179:             * @see com.sun.jdori.FieldManager#fetchStringField(int)
180:             */
181:            public String fetchStringField(int fieldNum) {
182:                String value = (String) getValue(fieldNum);
183:                return value;
184:            }
185:
186:            /**
187:             * @see com.sun.jdori.FieldManager#storeObjectField(int, Object)
188:             */
189:            public void storeObjectField(int fieldNum, Object value) {
190:            }
191:
192:            /**
193:             * @see com.sun.jdori.FieldManager#fetchObjectField(int)
194:             */
195:            public Object fetchObjectField(int fieldNum) {
196:                Object value = getValue(fieldNum);
197:                return value;
198:            }
199:
200:            /**
201:             * Returns the pc.
202:             * @return PersistenceCapable
203:             */
204:            public PersistenceCapable getPc() {
205:                return pc;
206:            }
207:
208:            /**
209:             * Sets the pc.
210:             * @param pc The pc to set
211:             */
212:            public void setPc(PersistenceCapable pc) {
213:                this .pc = pc;
214:            }
215:
216:            String getAttributeName(int fieldNum) {
217:                JDOClass jdoClass = Helper.getJDOClass(pc.getClass());
218:                JDOField jdoField = jdoClass.getField(fieldNum);
219:                String attributeName = jdoField.getName();
220:                return attributeName;
221:            }
222:
223:            /**
224:             * retrieve the value of attribute[fieldNum] from the object.
225:             * @return Object the value of attribute[fieldNum]
226:             */
227:            Object getValue(int fieldNum) {
228:                String attributeName = getAttributeName(fieldNum);
229:                ClassDescriptor cld = broker.getClassDescriptor(pc.getClass());
230:
231:                // field could be a primitive typed attribute...
232:                AttributeDescriptorBase fld = cld
233:                        .getFieldDescriptorByName(attributeName);
234:                // field could be a reference attribute...
235:                if (fld == null) {
236:                    fld = cld.getObjectReferenceDescriptorByName(attributeName);
237:                }
238:                // or it could be a collection attribute:
239:                if (fld == null) {
240:                    fld = cld.getCollectionDescriptorByName(attributeName);
241:                }
242:                Object value = fld.getPersistentField().get(pc);
243:                return value;
244:            }
245:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.