Source Code Cross Referenced for LifeCycle.java in  » Database-ORM » Speedo_1.4.5 » org » objectweb » speedo » mim » api » 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 » Speedo_1.4.5 » org.objectweb.speedo.mim.api 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Speedo: an implementation of JDO compliant personality on top of JORM generic
003:         * I/O sub-system.
004:         * Copyright (C) 2001-2004 France Telecom R&D
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2 of the License, or (at your option) any later version.
010:         *
011:         * This library 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 GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         *
020:         *
021:         *
022:         * Contact: speedo@objectweb.org
023:         *
024:         * Authors: S.Chassande-Barrioz.
025:         *
026:         */package org.objectweb.speedo.mim.api;
027:
028:        /**
029:         * Representation of the life cycle of a JDO Instance.
030:         * @author	S.Chassande-Barrioz
031:         */
032:        public abstract class LifeCycle {
033:            public static final byte NOT_APPLICABLE = -2;
034:            public static final byte ERROR = -1;
035:            public static final byte TRANSIENT = 0;
036:            public static final byte TRANSIENT_CLEAN = 1;
037:            public static final byte TRANSIENT_DIRTY = 2;
038:            public static final byte PERSISTENT_NEW = 3;
039:            public static final byte PERSISTENT_NONTRANSACTIONAL = 4;
040:            public static final byte PERSISTENT_CLEAN = 5;
041:            public static final byte PERSISTENT_DIRTY = 6;
042:            public static final byte HOLLOW = 7;
043:            public static final byte PERSISTENT_DELETED = 8;
044:            public static final byte PERSISTENT_NEW_DELETED = 9;
045:
046:            public static final byte ACTION_MAKEPERSISTENT = 0;
047:            public static final byte ACTION_DELETEPERSISTENT = 1;
048:            public static final byte ACTION_MAKETRANSACTIONAL = 2;
049:            public static final byte ACTION_MAKENONTRANSACTIONAL = 3;
050:            public static final byte ACTION_MAKETRANSIENT = 4;
051:            public static final byte ACTION_COMMIT = 5;
052:            public static final byte ACTION_COMMIT_RETAINVALUES = 6;
053:            public static final byte ACTION_ROLLBACK = 7;
054:            public static final byte ACTION_ROLLBACK_RETAINVALUES = 8;
055:            public static final byte ACTION_REFRESH_ACTIVEDATASTORETRANSACTION = 9;
056:            public static final byte ACTION_REFRESH_ACTIVEOPTIMISTICTRANSACTION = 10;
057:            public static final byte ACTION_EVICT = 11;
058:            public static final byte ACTION_READFIELD_OUTSIDETRANSACTION = 12;
059:            public static final byte ACTION_READFIELD_ACTIVEOPTIMISTICTRANSACTION = 13;
060:            public static final byte ACTION_READFIELD_ACTIVEDATASTORETRANSACTION = 14;
061:            public static final byte ACTION_WRITEFIELD_ACTIVEDATASTORETRANSACTION = 15;
062:            public static final byte ACTION_WRITEFIELD_OUTSIDETRANSACTION = 16;
063:
064:            public static String actionToString(byte action) {
065:                switch (action) {
066:                case ACTION_MAKEPERSISTENT:
067:                    return "MAKEPERSISTENT";
068:                case ACTION_MAKETRANSACTIONAL:
069:                    return "MAKETRANSACTIONAL";
070:                case ACTION_MAKETRANSIENT:
071:                    return "MAKETRANSIENT";
072:                case ACTION_COMMIT:
073:                    return "COMMIT";
074:                case ACTION_COMMIT_RETAINVALUES:
075:                    return "COMMIT_RETAINVALUES";
076:                case ACTION_ROLLBACK:
077:                    return "ROLLBACK";
078:                case ACTION_ROLLBACK_RETAINVALUES:
079:                    return "ROLLBACK_RETAINVALUES";
080:                case ACTION_READFIELD_OUTSIDETRANSACTION:
081:                    return "READFIELD_OUTSIDETRANSACTION";
082:                case ACTION_READFIELD_ACTIVEOPTIMISTICTRANSACTION:
083:                    return "READFIELD_ACTIVEOPTIMISTICTRANSACTION";
084:                case ACTION_READFIELD_ACTIVEDATASTORETRANSACTION:
085:                    return "READFIELD_ACTIVEDATASTORETRANSACTION";
086:                case ACTION_WRITEFIELD_ACTIVEDATASTORETRANSACTION:
087:                    return "WRITEFIELD_ACTIVEDATASTORETRANSACTION";
088:                case ACTION_WRITEFIELD_OUTSIDETRANSACTION:
089:                    return "WRITEFIELD_OUTSIDETRANSACTION";
090:                case ACTION_MAKENONTRANSACTIONAL:
091:                    return "MAKENONTRANSACTIONAL";
092:                case ACTION_REFRESH_ACTIVEDATASTORETRANSACTION:
093:                    return "REFRESH_ACTIVEDATASTORETRANSACTION";
094:                case ACTION_REFRESH_ACTIVEOPTIMISTICTRANSACTION:
095:                    return "REFRESH_ACTIVEOPTIMISTICTRANSACTION";
096:                case ACTION_EVICT:
097:                    return "EVICT";
098:                case ACTION_DELETEPERSISTENT:
099:                    return "DELETEPERSISTENT";
100:                default:
101:                    return "ERROR";
102:                }
103:            }
104:
105:            public static String statusToString(byte status) {
106:                switch (status) {
107:                case TRANSIENT:
108:                    return "TRANSIENT";
109:                case TRANSIENT_CLEAN:
110:                    return "TRANSIENT_CLEAN";
111:                case TRANSIENT_DIRTY:
112:                    return "TRANSIENT_DIRTY";
113:                case PERSISTENT_NEW:
114:                    return "PERSISTENT_NEW";
115:                case PERSISTENT_NONTRANSACTIONAL:
116:                    return "PERSISTENT_NONTRANSACTIONAL";
117:                case PERSISTENT_CLEAN:
118:                    return "PERSISTENT_CLEAN";
119:                case PERSISTENT_DIRTY:
120:                    return "PERSISTENT_DIRTY";
121:                case HOLLOW:
122:                    return "HOLLOW";
123:                case PERSISTENT_DELETED:
124:                    return "PERSISTENT_DELETED";
125:                case PERSISTENT_NEW_DELETED:
126:                    return "PERSISTENT_NEW_DELETED";
127:                case ERROR:
128:                default:
129:                    return "ERROR";
130:                }
131:            }
132:
133:            /**
134:             * Gets the state transition in the JDO instances life cycle
135:             * @param status current instance status
136:             * @param action method that is currently invoked
137:             * @return the next state according to JDO rules
138:             */
139:            public static byte nextStatePersistenceCapable(byte status,
140:                    byte action) {
141:                switch (status) {
142:                case (TRANSIENT):
143:                    switch (action) {
144:                    case (ACTION_MAKEPERSISTENT):
145:                        return PERSISTENT_NEW;
146:                    case (ACTION_MAKETRANSACTIONAL):
147:                        return TRANSIENT_CLEAN;
148:                    case (ACTION_MAKETRANSIENT):
149:                    case (ACTION_COMMIT):
150:                    case (ACTION_COMMIT_RETAINVALUES):
151:                    case (ACTION_ROLLBACK):
152:                    case (ACTION_ROLLBACK_RETAINVALUES):
153:                    case (ACTION_READFIELD_OUTSIDETRANSACTION):
154:                    case (ACTION_READFIELD_ACTIVEOPTIMISTICTRANSACTION):
155:                    case (ACTION_READFIELD_ACTIVEDATASTORETRANSACTION):
156:                    case (ACTION_WRITEFIELD_ACTIVEDATASTORETRANSACTION):
157:                    case (ACTION_WRITEFIELD_OUTSIDETRANSACTION):
158:                        return TRANSIENT;
159:                    case (ACTION_MAKENONTRANSACTIONAL):
160:                    case (ACTION_REFRESH_ACTIVEDATASTORETRANSACTION):
161:                    case (ACTION_REFRESH_ACTIVEOPTIMISTICTRANSACTION):
162:                    case (ACTION_EVICT):
163:                        return NOT_APPLICABLE;
164:                    case (ACTION_DELETEPERSISTENT):
165:                    default:
166:                        return ERROR;
167:                    }
168:                case (TRANSIENT_CLEAN):
169:                    switch (action) {
170:                    case (ACTION_MAKEPERSISTENT):
171:                        return PERSISTENT_NEW;
172:                    case (ACTION_MAKENONTRANSACTIONAL):
173:                        return TRANSIENT;
174:                    case (ACTION_WRITEFIELD_OUTSIDETRANSACTION):
175:                        return TRANSIENT_DIRTY;
176:                    case (ACTION_MAKETRANSACTIONAL):
177:                    case (ACTION_MAKETRANSIENT):
178:                    case (ACTION_COMMIT):
179:                    case (ACTION_COMMIT_RETAINVALUES):
180:                    case (ACTION_ROLLBACK):
181:                    case (ACTION_ROLLBACK_RETAINVALUES):
182:                    case (ACTION_EVICT):
183:                    case (ACTION_READFIELD_OUTSIDETRANSACTION):
184:                    case (ACTION_READFIELD_ACTIVEOPTIMISTICTRANSACTION):
185:                    case (ACTION_READFIELD_ACTIVEDATASTORETRANSACTION):
186:                    case (ACTION_WRITEFIELD_ACTIVEDATASTORETRANSACTION):
187:                        return TRANSIENT_CLEAN;
188:                    case (ACTION_REFRESH_ACTIVEDATASTORETRANSACTION):
189:                    case (ACTION_REFRESH_ACTIVEOPTIMISTICTRANSACTION):
190:                        return NOT_APPLICABLE;
191:                    case (ACTION_DELETEPERSISTENT):
192:                    default:
193:                        return ERROR;
194:                    }
195:                case (TRANSIENT_DIRTY):
196:                    switch (action) {
197:                    case (ACTION_MAKEPERSISTENT):
198:                        return PERSISTENT_NEW;
199:                    case (ACTION_COMMIT):
200:                    case (ACTION_COMMIT_RETAINVALUES):
201:                    case (ACTION_ROLLBACK):
202:                    case (ACTION_ROLLBACK_RETAINVALUES):
203:                        return TRANSIENT_CLEAN;
204:                    case (ACTION_MAKETRANSACTIONAL):
205:                    case (ACTION_MAKETRANSIENT):
206:                    case (ACTION_EVICT):
207:                    case (ACTION_READFIELD_OUTSIDETRANSACTION):
208:                    case (ACTION_READFIELD_ACTIVEOPTIMISTICTRANSACTION):
209:                    case (ACTION_READFIELD_ACTIVEDATASTORETRANSACTION):
210:                    case (ACTION_WRITEFIELD_ACTIVEDATASTORETRANSACTION):
211:                        return TRANSIENT_DIRTY;
212:                    case (ACTION_REFRESH_ACTIVEDATASTORETRANSACTION):
213:                    case (ACTION_REFRESH_ACTIVEOPTIMISTICTRANSACTION):
214:                    case (ACTION_WRITEFIELD_OUTSIDETRANSACTION):
215:                        return NOT_APPLICABLE;
216:                    case (ACTION_DELETEPERSISTENT):
217:                    case (ACTION_MAKENONTRANSACTIONAL):
218:                    default:
219:                        return ERROR;
220:                    }
221:                case (PERSISTENT_NEW):
222:                    switch (action) {
223:                    case (ACTION_DELETEPERSISTENT):
224:                        return PERSISTENT_NEW_DELETED;
225:                    case (ACTION_COMMIT):
226:                        return HOLLOW;
227:                    case (ACTION_COMMIT_RETAINVALUES):
228:                        return PERSISTENT_NONTRANSACTIONAL;
229:                    case (ACTION_ROLLBACK):
230:                    case (ACTION_ROLLBACK_RETAINVALUES):
231:                        return TRANSIENT;
232:                    case (ACTION_MAKEPERSISTENT):
233:                    case (ACTION_MAKETRANSACTIONAL):
234:                    case (ACTION_REFRESH_ACTIVEDATASTORETRANSACTION):
235:                    case (ACTION_REFRESH_ACTIVEOPTIMISTICTRANSACTION):
236:                    case (ACTION_EVICT):
237:                    case (ACTION_READFIELD_OUTSIDETRANSACTION):
238:                    case (ACTION_READFIELD_ACTIVEOPTIMISTICTRANSACTION):
239:                    case (ACTION_READFIELD_ACTIVEDATASTORETRANSACTION):
240:                    case (ACTION_WRITEFIELD_ACTIVEDATASTORETRANSACTION):
241:                    case (ACTION_WRITEFIELD_OUTSIDETRANSACTION):
242:                        return PERSISTENT_NEW;
243:                    case (ACTION_MAKENONTRANSACTIONAL):
244:                        return NOT_APPLICABLE;
245:                    case (ACTION_MAKETRANSIENT):
246:                    default:
247:                        return ERROR;
248:                    }
249:                case (PERSISTENT_NONTRANSACTIONAL):
250:                    switch (action) {
251:                    case (ACTION_DELETEPERSISTENT):
252:                        return PERSISTENT_DELETED;
253:                    case (ACTION_MAKETRANSACTIONAL):
254:                    case (ACTION_READFIELD_ACTIVEDATASTORETRANSACTION):
255:                        return PERSISTENT_CLEAN;
256:                    case (ACTION_MAKETRANSIENT):
257:                        return TRANSIENT;
258:                    case (ACTION_EVICT):
259:                        return HOLLOW;
260:                    case (ACTION_WRITEFIELD_ACTIVEDATASTORETRANSACTION):
261:                        return PERSISTENT_DIRTY;
262:                    case (ACTION_MAKEPERSISTENT):
263:                    case (ACTION_MAKENONTRANSACTIONAL):
264:                    case (ACTION_COMMIT):
265:                    case (ACTION_COMMIT_RETAINVALUES):
266:                    case (ACTION_ROLLBACK):
267:                    case (ACTION_ROLLBACK_RETAINVALUES):
268:                    case (ACTION_REFRESH_ACTIVEDATASTORETRANSACTION):
269:                    case (ACTION_REFRESH_ACTIVEOPTIMISTICTRANSACTION):
270:                    case (ACTION_READFIELD_OUTSIDETRANSACTION):
271:                    case (ACTION_READFIELD_ACTIVEOPTIMISTICTRANSACTION):
272:                    case (ACTION_WRITEFIELD_OUTSIDETRANSACTION):
273:                        return PERSISTENT_NONTRANSACTIONAL;
274:                    default:
275:                        return ERROR;
276:                    }
277:                case (PERSISTENT_CLEAN):
278:                    switch (action) {
279:                    case (ACTION_DELETEPERSISTENT):
280:                        return PERSISTENT_DELETED;
281:                    case (ACTION_MAKENONTRANSACTIONAL):
282:                        return PERSISTENT_NONTRANSACTIONAL;
283:                    case (ACTION_MAKETRANSIENT):
284:                        return TRANSIENT;
285:                    case (ACTION_COMMIT):
286:                    case (ACTION_ROLLBACK):
287:                    case (ACTION_EVICT):
288:                        return HOLLOW;
289:                    case (ACTION_COMMIT_RETAINVALUES):
290:                    case (ACTION_ROLLBACK_RETAINVALUES):
291:                        return PERSISTENT_NONTRANSACTIONAL;
292:                    case (ACTION_WRITEFIELD_ACTIVEDATASTORETRANSACTION):
293:                        return PERSISTENT_DIRTY;
294:                    case (ACTION_MAKEPERSISTENT):
295:                    case (ACTION_MAKETRANSACTIONAL):
296:                    case (ACTION_REFRESH_ACTIVEDATASTORETRANSACTION):
297:                    case (ACTION_REFRESH_ACTIVEOPTIMISTICTRANSACTION):
298:                    case (ACTION_READFIELD_OUTSIDETRANSACTION):
299:                    case (ACTION_READFIELD_ACTIVEOPTIMISTICTRANSACTION):
300:                    case (ACTION_READFIELD_ACTIVEDATASTORETRANSACTION):
301:                        return PERSISTENT_CLEAN;
302:                    case (ACTION_WRITEFIELD_OUTSIDETRANSACTION):
303:                        return NOT_APPLICABLE;
304:                    default:
305:                        return ERROR;
306:                    }
307:                case (PERSISTENT_DIRTY):
308:                    switch (action) {
309:                    case (ACTION_DELETEPERSISTENT):
310:                        return PERSISTENT_DELETED;
311:                    case (ACTION_COMMIT):
312:                    case (ACTION_ROLLBACK):
313:                        return HOLLOW;
314:                    case (ACTION_COMMIT_RETAINVALUES):
315:                    case (ACTION_ROLLBACK_RETAINVALUES):
316:                    case (ACTION_REFRESH_ACTIVEOPTIMISTICTRANSACTION):
317:                        return PERSISTENT_NONTRANSACTIONAL;
318:                    case (ACTION_REFRESH_ACTIVEDATASTORETRANSACTION):
319:                        return PERSISTENT_CLEAN;
320:                    case (ACTION_MAKEPERSISTENT):
321:                    case (ACTION_MAKETRANSACTIONAL):
322:                    case (ACTION_EVICT):
323:                    case (ACTION_READFIELD_OUTSIDETRANSACTION):
324:                    case (ACTION_READFIELD_ACTIVEOPTIMISTICTRANSACTION):
325:                    case (ACTION_READFIELD_ACTIVEDATASTORETRANSACTION):
326:                    case (ACTION_WRITEFIELD_ACTIVEDATASTORETRANSACTION):
327:                        return PERSISTENT_DIRTY;
328:                    case (ACTION_MAKENONTRANSACTIONAL):
329:                    case (ACTION_WRITEFIELD_OUTSIDETRANSACTION):
330:                        return NOT_APPLICABLE;
331:                    case (ACTION_MAKETRANSIENT):
332:                    default:
333:                        return ERROR;
334:                    }
335:                case (HOLLOW):
336:                    switch (action) {
337:                    case (ACTION_DELETEPERSISTENT):
338:                        return PERSISTENT_DELETED;
339:                    case (ACTION_MAKETRANSIENT):
340:                        return TRANSIENT;
341:                    case (ACTION_READFIELD_OUTSIDETRANSACTION):
342:                    case (ACTION_READFIELD_ACTIVEOPTIMISTICTRANSACTION):
343:                    case (ACTION_WRITEFIELD_OUTSIDETRANSACTION):
344:                        return PERSISTENT_NONTRANSACTIONAL;
345:                    case (ACTION_READFIELD_ACTIVEDATASTORETRANSACTION):
346:                        return PERSISTENT_CLEAN;
347:                    case (ACTION_WRITEFIELD_ACTIVEDATASTORETRANSACTION):
348:                        return PERSISTENT_DIRTY;
349:                    case (ACTION_MAKEPERSISTENT):
350:                    case (ACTION_MAKETRANSACTIONAL):
351:                    case (ACTION_MAKENONTRANSACTIONAL):
352:                    case (ACTION_COMMIT):
353:                    case (ACTION_COMMIT_RETAINVALUES):
354:                    case (ACTION_ROLLBACK):
355:                    case (ACTION_ROLLBACK_RETAINVALUES):
356:                    case (ACTION_REFRESH_ACTIVEDATASTORETRANSACTION):
357:                    case (ACTION_REFRESH_ACTIVEOPTIMISTICTRANSACTION):
358:                    case (ACTION_EVICT):
359:                        return HOLLOW;
360:                    default:
361:                        return ERROR;
362:                    }
363:                case (PERSISTENT_DELETED):
364:                    switch (action) {
365:                    case (ACTION_COMMIT):
366:                    case (ACTION_COMMIT_RETAINVALUES):
367:                        return TRANSIENT;
368:                    case (ACTION_ROLLBACK):
369:                        return HOLLOW;
370:                    case (ACTION_ROLLBACK_RETAINVALUES):
371:                        return PERSISTENT_NONTRANSACTIONAL;
372:                    case (ACTION_MAKEPERSISTENT):
373:                    case (ACTION_DELETEPERSISTENT):
374:                    case (ACTION_MAKETRANSACTIONAL):
375:                    case (ACTION_REFRESH_ACTIVEDATASTORETRANSACTION):
376:                    case (ACTION_REFRESH_ACTIVEOPTIMISTICTRANSACTION):
377:                    case (ACTION_EVICT):
378:                    case (ACTION_READFIELD_OUTSIDETRANSACTION):
379:                    case (ACTION_READFIELD_ACTIVEOPTIMISTICTRANSACTION):
380:                    case (ACTION_READFIELD_ACTIVEDATASTORETRANSACTION):
381:                    case (ACTION_WRITEFIELD_ACTIVEDATASTORETRANSACTION):
382:                    case (ACTION_WRITEFIELD_OUTSIDETRANSACTION):
383:                        return PERSISTENT_DELETED;
384:                    case (ACTION_MAKENONTRANSACTIONAL):
385:                    case (ACTION_MAKETRANSIENT):
386:                    default:
387:                        return ERROR;
388:                    }
389:                case (PERSISTENT_NEW_DELETED):
390:                    switch (action) {
391:                    case (ACTION_COMMIT):
392:                    case (ACTION_COMMIT_RETAINVALUES):
393:                    case (ACTION_ROLLBACK):
394:                    case (ACTION_ROLLBACK_RETAINVALUES):
395:                        return TRANSIENT;
396:                    case (ACTION_MAKEPERSISTENT):
397:                    case (ACTION_DELETEPERSISTENT):
398:                    case (ACTION_MAKETRANSACTIONAL):
399:                    case (ACTION_REFRESH_ACTIVEDATASTORETRANSACTION):
400:                    case (ACTION_REFRESH_ACTIVEOPTIMISTICTRANSACTION):
401:                    case (ACTION_EVICT):
402:                    case (ACTION_READFIELD_OUTSIDETRANSACTION):
403:                    case (ACTION_READFIELD_ACTIVEOPTIMISTICTRANSACTION):
404:                    case (ACTION_READFIELD_ACTIVEDATASTORETRANSACTION):
405:                    case (ACTION_WRITEFIELD_ACTIVEDATASTORETRANSACTION):
406:                    case (ACTION_WRITEFIELD_OUTSIDETRANSACTION):
407:                        return PERSISTENT_NEW_DELETED;
408:                    case (ACTION_MAKENONTRANSACTIONAL):
409:                    case (ACTION_MAKETRANSIENT):
410:                    default:
411:                        return ERROR;
412:                    }
413:                default:
414:                    return ERROR;
415:                }
416:            }
417:
418:            /**
419:             * Make the instance dirty.
420:             * @param status current status
421:             * @return new status
422:             */
423:            public static byte makeDirty(byte status) {
424:                switch (status) {
425:                case (TRANSIENT):
426:                    return TRANSIENT;
427:                case (PERSISTENT_NEW):
428:                    return PERSISTENT_NEW;
429:                case (PERSISTENT_CLEAN):
430:                case (PERSISTENT_DIRTY):
431:                case (HOLLOW):
432:                case (PERSISTENT_NONTRANSACTIONAL):
433:                    return PERSISTENT_DIRTY;
434:                case (TRANSIENT_CLEAN):
435:                case (TRANSIENT_DIRTY):
436:                    return TRANSIENT_DIRTY;
437:                case (PERSISTENT_NEW_DELETED):
438:                    return PERSISTENT_NEW_DELETED;
439:                case (PERSISTENT_DELETED):
440:                    return PERSISTENT_DELETED;
441:                }
442:                return ERROR;
443:            }
444:
445:            /**
446:             * Indicates if the instance is persistent
447:             *
448:             * @param status current instance status
449:             * @return true if the instance is persistent
450:             */
451:            public static boolean isPersistent(byte status) {
452:                return status == PERSISTENT_NEW || status == PERSISTENT_CLEAN
453:                        || status == PERSISTENT_DIRTY || status == HOLLOW
454:                        || status == PERSISTENT_NONTRANSACTIONAL
455:                        || status == PERSISTENT_NEW_DELETED
456:                        || status == PERSISTENT_DELETED;
457:            }
458:
459:            /**
460:             * Indicates if the instance is transactional
461:             *
462:             * @param status current instance status
463:             * @return true if the instance is transactional
464:             */
465:            public static boolean isTransactional(byte status) {
466:                return status == PERSISTENT_NEW || status == TRANSIENT_CLEAN
467:                        || status == TRANSIENT_DIRTY
468:                        || status == PERSISTENT_CLEAN
469:                        || status == PERSISTENT_DIRTY
470:                        || status == PERSISTENT_NEW_DELETED
471:                        || status == PERSISTENT_DELETED;
472:            }
473:
474:            /**
475:             * Indicates if the instance is new
476:             *
477:             * @param status current instance status
478:             * @return true if the instance is bew
479:             */
480:            public static boolean isNew(byte status) {
481:                return status == PERSISTENT_NEW
482:                        || status == PERSISTENT_NEW_DELETED;
483:            }
484:
485:            /**
486:             * Indicates if the instance is dirty
487:             *
488:             * @param status current instance status
489:             * @return true if the instance is dirty
490:             */
491:            public static boolean isDirty(byte status) {
492:                return status == PERSISTENT_NEW || status == TRANSIENT_DIRTY
493:                        || status == PERSISTENT_DIRTY
494:                        || status == PERSISTENT_NEW_DELETED
495:                        || status == PERSISTENT_DELETED;
496:            }
497:
498:            /**
499:             * Indicates if the instance is deleted
500:             *
501:             * @param status current instance status
502:             * @return true if the instance is deleted
503:             */
504:            public static boolean isDeleted(byte status) {
505:                return status == PERSISTENT_NEW_DELETED
506:                        || status == PERSISTENT_DELETED;
507:            }
508:
509:            /**
510:             * Gets the initial state
511:             *
512:             * @return <code>TRANSIENT</code>
513:             */
514:            public static byte initState() {
515:                return TRANSIENT;
516:            }
517:
518:            /**
519:             * Indicates if the instance is transient
520:             *
521:             * @param status current instance status
522:             * @return true if the instance is transient
523:             */
524:            public static boolean isTransient(byte status) {
525:                return status == TRANSIENT || status == TRANSIENT_CLEAN
526:                        || status == TRANSIENT_DIRTY;
527:            }
528:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.