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


001:        /*
002:            $Header: /cvsroot/xorm/xorm/src/org/xorm/ObjectState.java,v 1.6 2004/05/19 19:59:44 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;
021:
022:        /**
023:         * A single instance of ObjectState tracks the state of a
024:         * persistent object.
025:         */
026:        class ObjectState {
027:            // Bitwise stati
028:            public static final byte STATUS_TRANSACTIONAL = 1;
029:            public static final byte STATUS_DIRTY = 2;
030:            public static final byte STATUS_PERSISTENT = 4;
031:            public static final byte STATUS_NEW = 8;
032:            public static final byte STATUS_DELETED = 16;
033:            public static final byte STATUS_HOLLOW = 32 + 4;
034:
035:            private static final String[] STATUS_NAME = new String[] {
036:                    "Transient", "Transient-Clean", null, "Transient-Dirty", /* 0 - 3 */
037:                    "Persistent-Nontransactional", "Persistent-Clean", null,
038:                    "Persistent-Dirty", /* 4 - 7 */
039:                    null, null, null, null, /* 8 - 11 */
040:                    null, "Persistent-New", null, null, /* 12 - 15 */
041:                    null, null, null, null, /* 16 - 19 */
042:                    null, "Persistent-Deleted", null, null, /* 20 - 23 */
043:                    null, null, null, null, /* 24 - 27 */
044:                    null, "Persistent-New-Deleted", null, null, /* 28 - 31 */
045:                    null, null, null, null, /* 32 - 35 */
046:                    "Hollow" /* 36 */
047:            };
048:
049:            // Pseudo-stati, corresponding to JDO terminology
050:            public static final byte STATUS_TRANSIENT = 0;
051:            public static final byte STATUS_TRANSIENT_CLEAN = STATUS_TRANSACTIONAL;
052:            public static final byte STATUS_TRANSIENT_DIRTY = STATUS_TRANSACTIONAL
053:                    + STATUS_DIRTY;
054:            public static final byte STATUS_PERSISTENT_NONTRANSACTIONAL = STATUS_PERSISTENT;
055:            public static final byte STATUS_PERSISTENT_CLEAN = STATUS_PERSISTENT
056:                    + STATUS_TRANSACTIONAL;
057:            public static final byte STATUS_PERSISTENT_DIRTY = STATUS_PERSISTENT
058:                    + STATUS_TRANSACTIONAL + STATUS_DIRTY;
059:            public static final byte STATUS_PERSISTENT_NEW = STATUS_PERSISTENT
060:                    + STATUS_TRANSACTIONAL + STATUS_NEW;
061:            public static final byte STATUS_PERSISTENT_DELETED = STATUS_PERSISTENT
062:                    + STATUS_TRANSACTIONAL + STATUS_DELETED;
063:            public static final byte STATUS_PERSISTENT_NEW_DELETED = STATUS_PERSISTENT
064:                    + STATUS_TRANSACTIONAL + STATUS_NEW + STATUS_DELETED;
065:
066:            public final String getStatusName() {
067:                return STATUS_NAME[status];
068:            }
069:
070:            // Status of this object, one of the constants above. 
071:            protected byte status;
072:
073:            // The object being tracked
074:            protected Object proxy;
075:
076:            protected ObjectState(Object proxy) {
077:                this .proxy = proxy;
078:            }
079:
080:            // Immutables can be reused for default values
081:            private static final Byte DEFAULT_BYTE = new Byte((byte) 0);
082:            private static final Character DEFAULT_CHAR = new Character(
083:                    '\u0000');
084:            private static final Double DEFAULT_DOUBLE = new Double(0.0D);
085:            private static final Float DEFAULT_FLOAT = new Float(0.0F);
086:            private static final Integer DEFAULT_INT = new Integer(0);
087:            private static final Long DEFAULT_LONG = new Long(0L);
088:            private static final Short DEFAULT_SHORT = new Short((short) 0);
089:
090:            /** Returns a wrapped default value for primitive types. */
091:            static Object defaultValue(Class type) {
092:                if (type.equals(Integer.TYPE)) {
093:                    return DEFAULT_INT;
094:                }
095:                if (type.equals(Long.TYPE)) {
096:                    return DEFAULT_LONG;
097:                }
098:                if (type.equals(Short.TYPE)) {
099:                    return DEFAULT_SHORT;
100:                }
101:                if (type.equals(Float.TYPE)) {
102:                    return DEFAULT_FLOAT;
103:                }
104:                if (type.equals(Double.TYPE)) {
105:                    return DEFAULT_DOUBLE;
106:                }
107:                if (type.equals(Boolean.TYPE)) {
108:                    return Boolean.FALSE;
109:                }
110:                if (type.equals(Byte.TYPE)) {
111:                    return DEFAULT_BYTE;
112:                }
113:                if (type.equals(Character.TYPE)) {
114:                    return DEFAULT_CHAR;
115:                }
116:                return null;
117:            }
118:
119:            public boolean isDirty() {
120:                return (status & STATUS_DIRTY) > 0;
121:            }
122:
123:            public void setDirty(boolean value) {
124:                if (value) {
125:                    status |= STATUS_DIRTY;
126:                } else {
127:                    status &= ~STATUS_DIRTY;
128:                }
129:            }
130:
131:            public boolean isTransactional() {
132:                return (status & STATUS_TRANSACTIONAL) > 0;
133:            }
134:
135:            public void setTransactional(boolean value) {
136:                if (value) {
137:                    status |= STATUS_TRANSACTIONAL;
138:                } else {
139:                    status &= ~STATUS_TRANSACTIONAL;
140:                }
141:            }
142:
143:            public boolean isPersistent() {
144:                return (status & STATUS_PERSISTENT) > 0;
145:            }
146:
147:            public void setPersistent(boolean value) {
148:                if (value) {
149:                    status |= STATUS_PERSISTENT;
150:                } else {
151:                    status &= ~STATUS_PERSISTENT;
152:                }
153:            }
154:
155:            public boolean isNew() {
156:                return (status & STATUS_NEW) > 0;
157:            }
158:
159:            public void setNew(boolean value) {
160:                if (value) {
161:                    status |= STATUS_NEW;
162:                } else {
163:                    status &= ~STATUS_NEW;
164:                }
165:            }
166:
167:            public boolean isDeleted() {
168:                return (status & STATUS_DELETED) > 0;
169:            }
170:
171:            public void setDeleted(boolean value) {
172:                if (value) {
173:                    status |= STATUS_DELETED;
174:                } else {
175:                    status &= ~STATUS_DELETED;
176:                }
177:            }
178:
179:            public boolean isHollow() {
180:                // Note that this one is different!
181:                return (status == STATUS_HOLLOW);
182:            }
183:
184:            public void setHollow(boolean value) {
185:                status = STATUS_HOLLOW;
186:            }
187:
188:            public void setStatus(byte status) {
189:                this .status = status;
190:            }
191:
192:            public byte getStatus() {
193:                return status;
194:            }
195:
196:            public void setProxy(Object proxy) {
197:                this .proxy = proxy;
198:            }
199:
200:            public Object getProxy() {
201:                return proxy;
202:            }
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.