Source Code Cross Referenced for JDOEnhanced.java in  » Database-ORM » XORM » org » xorm » tests » model » 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 » XORM » org.xorm.tests.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:            $Header: /cvsroot/xorm/xorm/tests/src/org/xorm/tests/model/JDOEnhanced.java,v 1.1 2002/09/30 03:26:08 wbiggs Exp $
003:
004:            This file is part of XORM.
005:
006:            XORM is free software; you can redistribute it and/or modify
007:            it under the terms of the GNU General Public License as published by
008:            the Free Software Foundation; either version 2 of the License, or
009:            (at your option) any later version.
010:
011:            XORM is distributed in the hope that it will be useful,
012:            but WITHOUT ANY WARRANTY; without even the implied warranty of
013:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:            GNU General Public License for more details.
015:
016:            You should have received a copy of the GNU General Public License
017:            along with XORM; if not, write to the Free Software
018:            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         */
020:        package org.xorm.tests.model;
021:
022:        import javax.jdo.spi.PersistenceCapable;
023:        import javax.jdo.spi.StateManager;
024:        import javax.jdo.PersistenceManager;
025:
026:        /**
027:         * This class simulates the structure of a reference-enhanced JDO class.
028:         */
029:        public class JDOEnhanced implements  PersistenceCapable {
030:            private String str;
031:
032:            public String getStr() {
033:                return jdoGetstr(this );
034:            }
035:
036:            public void setStr(String str) {
037:                jdoSetstr(this , str);
038:            }
039:
040:            // 20.20.1 Generated fields
041:            protected transient StateManager jdoStateManager = null;
042:            protected transient byte jdoFlags = PersistenceCapable.READ_WRITE_OK;
043:            private final static int jdoInheritedFieldCount = 0;
044:
045:            private final static String[] jdoFieldNames = { "str" };
046:            private final static Class[] jdoFieldTypes = { String.class };
047:            private final static byte[] jdoFieldFlags = { CHECK_READ
048:                    + CHECK_WRITE };
049:            private final static Class jdoPersistenceCapableSuperclass = null;
050:
051:            // 20.20.2 Generated static initializer
052:            static {
053:                javax.jdo.spi.JDOImplHelper.registerClass(JDOEnhanced.class,
054:                        jdoFieldNames, jdoFieldTypes, jdoFieldFlags,
055:                        jdoPersistenceCapableSuperclass, new JDOEnhanced());
056:            }
057:
058:            // 20.20.3 Generated interrogatives
059:            public final boolean jdoIsPersistent() {
060:                return jdoStateManager == null ? false : jdoStateManager
061:                        .isPersistent(this );
062:            }
063:
064:            public final boolean jdoIsTransactional() {
065:                return jdoStateManager == null ? false : jdoStateManager
066:                        .isTransactional(this );
067:            }
068:
069:            public final boolean jdoIsNew() {
070:                return jdoStateManager == null ? false : jdoStateManager
071:                        .isNew(this );
072:            }
073:
074:            public final boolean jdoIsDirty() {
075:                return jdoStateManager == null ? false : jdoStateManager
076:                        .isDirty(this );
077:            }
078:
079:            public final boolean jdoIsDeleted() {
080:                return jdoStateManager == null ? false : jdoStateManager
081:                        .isDeleted(this );
082:            }
083:
084:            public final void jdoMakeDirty(String fieldName) {
085:                if (jdoStateManager == null)
086:                    return;
087:                jdoStateManager.makeDirty(this , fieldName);
088:            }
089:
090:            public final PersistenceManager jdoGetPersistenceManager() {
091:                return jdoStateManager == null ? null : jdoStateManager
092:                        .getPersistenceManager(this );
093:            }
094:
095:            public final Object jdoGetObjectId() {
096:                return jdoStateManager == null ? null : jdoStateManager
097:                        .getObjectId(this );
098:            }
099:
100:            public final Object jdoGetTransactionalObjectId() {
101:                return jdoStateManager == null ? null : jdoStateManager
102:                        .getTransactionalObjectId(this );
103:            }
104:
105:            // 20.20.4 Generated jdoReplaceStateManager
106:            public final synchronized void jdoReplaceStateManager(
107:                    StateManager sm) {
108:                // throws exception if current sm didn't request the change
109:                if (jdoStateManager != null) {
110:                    jdoStateManager = jdoStateManager.replacingStateManager(
111:                            this , sm);
112:                } else {
113:                    SecurityManager sec = System.getSecurityManager();
114:                    if (sec != null) {
115:                        sec.checkPermission( // throws exception if not authorized
116:                                javax.jdo.spi.JDOPermission.SET_STATE_MANAGER);
117:                    }
118:                    jdoStateManager = sm;
119:                }
120:            }
121:
122:            // 20.20.5 Generated jdoReplaceFlags
123:            public final void jdoReplaceFlags() {
124:                if (jdoStateManager != null) {
125:                    jdoFlags = jdoStateManager.replacingFlags(this );
126:                }
127:            }
128:
129:            // 20.20.6 Generated jdoNewInstance helpers
130:            public PersistenceCapable jdoNewInstance(StateManager sm) {
131:                // if class is abstract, throw new JDOFatalInternalException()
132:                JDOEnhanced pc = new JDOEnhanced();
133:                pc.jdoStateManager = sm;
134:                pc.jdoFlags = LOAD_REQUIRED;
135:                return pc;
136:            }
137:
138:            public PersistenceCapable jdoNewInstance(StateManager sm,
139:                    Object object) {
140:                // if class is abstract, throw new JDOFatalInternalException()
141:                JDOEnhanced pc = new JDOEnhanced();
142:                pc.jdoStateManager = sm;
143:                pc.jdoFlags = LOAD_REQUIRED;
144:                // now copy the key fields into the new instance
145:                //jdoCopyKeyFieldsFromObjectId (oid);
146:                return pc;
147:            }
148:
149:            // 20.20.7
150:            public int jdoGetManagedFieldCount() {
151:                return jdoFieldNames.length;
152:            }
153:
154:            // 20.20.8
155:
156:            private final static String jdoGetstr(JDOEnhanced x) {
157:                // this field is in the default fetch group (CHECK_READ)
158:                if (x.jdoFlags <= READ_WRITE_OK) {
159:                    // ok to read
160:                    return x.str;
161:                }
162:                // field needs to be fetched from StateManager
163:                // this call might result in str being stored in instance
164:                StateManager sm = x.jdoStateManager;
165:                if (sm != null) {
166:                    if (sm.isLoaded(x, 0))
167:                        return x.str;
168:                    return sm.getStringField(x, 0, x.str);
169:                } else {
170:                    return x.str;
171:                }
172:            }
173:
174:            private final static void jdoSetstr(JDOEnhanced x, String newValue) {
175:                // this field is in the default fetch group
176:                if (x.jdoFlags == READ_WRITE_OK) {
177:                    // ok to read, write
178:                    x.str = newValue;
179:                    return;
180:                }
181:                StateManager sm = x.jdoStateManager;
182:                if (sm != null) {
183:                    sm.setStringField(x, 0, x.str, newValue);
184:                } else {
185:                    x.str = newValue;
186:                }
187:            }
188:
189:            // 20.20.10 Generated jdoReplaceField and jdoReplaceFields
190:            public void jdoReplaceField(int fieldNumber) {
191:                switch (fieldNumber) {
192:                case 0:
193:                    str = jdoStateManager.replacingStringField(this ,
194:                            fieldNumber);
195:                    break;
196:                default:
197:                    throw new IllegalArgumentException("fieldNumber");
198:                }
199:            }
200:
201:            public void jdoReplaceFields(int[] fieldNumbers) {
202:                for (int i = 0; i < fieldNumbers.length; ++i) {
203:                    int fieldNumber = fieldNumbers[i];
204:                    jdoReplaceField(fieldNumber);
205:                }
206:            }
207:
208:            // 20.20.11 Generated jdoProvideField and jdoProvideFields
209:            public void jdoProvideField(int fieldNumber) {
210:                switch (fieldNumber) {
211:                case 0:
212:                    jdoStateManager.providedStringField(this , fieldNumber, str);
213:                    break;
214:                default:
215:                    throw new IllegalArgumentException("fieldNumber");
216:                }
217:            }
218:
219:            public void jdoProvideFields(int[] fieldNumbers) {
220:                for (int i = 0; i < fieldNumbers.length; ++i) {
221:                    int fieldNumber = fieldNumbers[i];
222:                    jdoProvideField(fieldNumber);
223:                }
224:            }
225:
226:            // 20.20.12 Generated jdoCopyField and jdoCopyFields
227:            public void jdoCopyFields(Object pc, int[] fieldNumbers) {
228:                // the other instance must be owned by the same StateManager
229:                // and our StateManager must not be null!
230:                if (((JDOEnhanced) pc).jdoStateManager != this .jdoStateManager)
231:                    throw new IllegalArgumentException(
232:                            "this.jdoStateManager != other.jdoStateManager");
233:                if (this .jdoStateManager == null)
234:                    throw new IllegalStateException(
235:                            "this.jdoStateManager == null");
236:                // throw ClassCastException if other class is the wrong class
237:                JDOEnhanced other = (JDOEnhanced) pc;
238:                for (int i = 0; i < fieldNumbers.length; ++i) {
239:                    jdoCopyField(other, fieldNumbers[i]);
240:                } // for loop
241:            }
242:
243:            protected void jdoCopyField(JDOEnhanced other, int fieldNumber) {
244:                switch (fieldNumber) {
245:                case 0:
246:                    this .str = other.str;
247:                    break;
248:                default:
249:                    throw new IllegalArgumentException("fieldNumber");
250:                }
251:            }
252:
253:            // 20.20.13
254:            private void writeObject(java.io.ObjectOutputStream out)
255:                    throws java.io.IOException {
256:                jdoPreSerialize();
257:                out.defaultWriteObject();
258:            }
259:
260:            // 20.20.14
261:            private final void jdoPreSerialize() {
262:                if (jdoStateManager != null)
263:                    jdoStateManager.preSerialize(this );
264:            }
265:
266:            // 20.20.15
267:
268:            public Object jdoNewObjectIdInstance() {
269:                return null;
270:            }
271:
272:            public Object jdoNewObjectIdInstance(String arg) {
273:                return null;
274:            }
275:
276:            // 20.20.16
277:            public void jdoCopyKeyFieldsToObjectId(
278:                    PersistenceCapable.ObjectIdFieldSupplier supplier,
279:                    Object oid) {
280:            }
281:
282:            public void jdoCopyKeyFieldsToObjectId(Object oid) {
283:            }
284:
285:            // 20.20.17
286:            public void jdoCopyKeyFieldsFromObjectId(
287:                    PersistenceCapable.ObjectIdFieldConsumer consumer,
288:                    Object oid) {
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.