Source Code Cross Referenced for DetachSCODate.java in  » Testing » PolePosition-0.20 » com » versant » core » jdo » sco » detached » 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 » Testing » PolePosition 0.20 » com.versant.core.jdo.sco.detached 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998 - 2005 Versant Corporation
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         * Versant Corporation - initial API and implementation
010:         */
011:        package com.versant.core.jdo.sco.detached;
012:
013:        import com.versant.core.common.Debug;
014:        import com.versant.core.jdo.VersantStateManager;
015:        import com.versant.core.common.VersantFieldMetaData;
016:        import com.versant.core.jdo.sco.VersantSimpleSCO;
017:        import com.versant.core.jdo.VersantStateManager;
018:
019:        import javax.jdo.spi.PersistenceCapable;
020:        import java.io.*;
021:
022:        public class DetachSCODate extends java.util.Date implements 
023:                Serializable, VersantSimpleSCO {
024:
025:            private PersistenceCapable owner;
026:            private int fieldNo;
027:            private VersantStateManager stateManager;
028:
029:            /**
030:             * Creates a <code>DetachSCODate</code> object that represents the given time
031:             * in milliseconds.
032:             *
033:             * @param date the number of milliseconds
034:             */
035:            public DetachSCODate(PersistenceCapable owner,
036:                    VersantStateManager stateManager, VersantFieldMetaData fmd,
037:                    long date) {
038:                super (date);
039:                this .owner = owner;
040:                this .stateManager = stateManager;
041:                this .fieldNo = fmd.getManagedFieldNo();
042:            }
043:
044:            /**
045:             * Sets the <tt>DetachSCODate</tt> object to represent a point in time that is
046:             * <tt>time</tt> milliseconds after January 1, 1970 00:00:00 GMT.
047:             *
048:             * @param time the number of milliseconds.
049:             * @see java.util.Date
050:             */
051:            public void setTime(long time) {
052:                this .makeDirty();
053:                super .setTime(time);
054:            }
055:
056:            /**
057:             * Creates and returns a copy of this object.
058:             * <p/>
059:             * <P>Mutable Second Class Objects are required to provide a public
060:             * clone method in order to allow for copying PersistenceCapable
061:             * objects. In contrast to Object.clone(), this method must not throw a
062:             * CloneNotSupportedException.
063:             */
064:            public Object clone() {
065:                Object obj = super .clone();
066:                if (obj instanceof  VersantSimpleSCO) {
067:                    ((VersantSimpleSCO) obj).makeTransient();
068:                }
069:
070:                return obj;
071:            }
072:
073:            /** -----------Depricated Methods------------------*/
074:
075:            /**
076:             * Sets the year of this <tt>DetachSCODate</tt> object to be the specified
077:             * value plus 1900.
078:             *
079:             * @param year the year value.
080:             * @see java.util.Calendar
081:             * @see java.util.Date
082:             * @deprecated As of JDK version 1.1,
083:             *             replaced by <code>Calendar.set(Calendar.YEAR, year + 1900)</code>.
084:             */
085:            public void setYear(int year) {
086:                this .makeDirty();
087:                super .setYear(year);
088:            }
089:
090:            /**
091:             * Sets the month of this date to the specified value.
092:             *
093:             * @param month the month value between 0-11.
094:             * @see java.util.Calendar
095:             * @see java.util.Date
096:             * @deprecated As of JDK version 1.1,
097:             *             replaced by <code>Calendar.set(Calendar.MONTH, int month)</code>.
098:             */
099:            public void setMonth(int month) {
100:                this .makeDirty();
101:                super .setMonth(month);
102:            }
103:
104:            /**
105:             * Sets the day of the month of this <tt>DetachSCODate</tt> object to the
106:             * specified value.
107:             *
108:             * @param date the day of the month value between 1-31.
109:             * @see java.util.Calendar
110:             * @see java.util.Date
111:             * @deprecated As of JDK version 1.1,
112:             *             replaced by <code>Calendar.set(Calendar.DAY_OF_MONTH, int date)</code>.
113:             */
114:            public void setDate(int date) {
115:                this .makeDirty();
116:                super .setDate(date);
117:            }
118:
119:            /**
120:             * Sets the hour of this <tt>DetachSCODate</tt> object to the specified value.
121:             *
122:             * @param hours the hour value.
123:             * @see java.util.Calendar
124:             * @see java.util.Date
125:             * @deprecated As of JDK version 1.1,
126:             *             replaced by <code>Calendar.set(Calendar.HOUR_OF_DAY, int hours)</code>.
127:             */
128:            public void setHours(int hours) {
129:                this .makeDirty();
130:                super .setHours(hours);
131:            }
132:
133:            /**
134:             * Sets the minutes of this <tt>DetachSCODate</tt> object to the specified value.
135:             *
136:             * @param minutes the value of the minutes.
137:             * @see java.util.Calendar
138:             * @see java.util.Date
139:             * @deprecated As of JDK version 1.1,
140:             *             replaced by <code>Calendar.set(Calendar.MINUTE, int minutes)</code>.
141:             */
142:            public void setMinutes(int minutes) {
143:                this .makeDirty();
144:                super .setMinutes(minutes);
145:            }
146:
147:            /**
148:             * Sets the seconds of this <tt>DetachSCODate</tt> to the specified value.
149:             *
150:             * @param seconds the seconds value.
151:             * @see java.util.Calendar
152:             * @see java.util.Date
153:             * @deprecated As of JDK version 1.1,
154:             *             replaced by <code>Calendar.set(Calendar.SECOND, int seconds)</code>.
155:             */
156:            public void setSeconds(int seconds) {
157:                this .makeDirty();
158:                super .setSeconds(seconds);
159:            }
160:
161:            /** ---------------- internal methods ------------------- */
162:
163:            /**
164:             * Sets the <tt>DetachSCODate</tt> object without notification of the Owner
165:             * field. Used internaly to populate date from DB
166:             *
167:             * @param time the number of milliseconds.
168:             * @see java.util.Date
169:             */
170:            public void setTimeInternal(long time) {
171:                super .setTime(time);
172:            }
173:
174:            /**
175:             * Nullifies references to the owner Object and Field
176:             */
177:            public void makeTransient() {
178:                this .owner = null;
179:                this .stateManager = null;
180:            }
181:
182:            /**
183:             * Returns the owner object of the SCO instance
184:             *
185:             * @return owner object
186:             */
187:            public Object getOwner() {
188:                return this .owner;
189:            }
190:
191:            /**
192:             * Marks object dirty
193:             */
194:            public void makeDirty() {
195:                if (stateManager != null && owner != null) {
196:                    stateManager.makeDirty(owner, fieldNo);
197:                }
198:            }
199:
200:            public void reset() {
201:            }
202:
203:            /**
204:             * Return the java class that is represented by this sco.
205:             *
206:             * @return
207:             */
208:            public Class getJavaType() {
209:                return java.util.Date.class;
210:            }
211:
212:            public void writeExternal(ObjectOutput out) throws IOException {
213:                out.writeLong(super .getTime());
214:            }
215:
216:            public void readExternal(ObjectInput in) throws IOException,
217:                    ClassNotFoundException {
218:                super .setTime(in.readLong());
219:            }
220:
221:            public static void main(String[] args) throws Exception {
222:                DetachSCODate d = new DetachSCODate(null, null, null, System
223:                        .currentTimeMillis());
224:                final long time = System.currentTimeMillis() - 5000;
225:                d.setTime(time);
226:                ByteArrayOutputStream bout = new ByteArrayOutputStream();
227:                ObjectOutputStream out = new ObjectOutputStream(bout);
228:                out.writeObject(d);
229:
230:                ObjectInputStream in = new ObjectInputStream(
231:                        new ByteArrayInputStream(bout.toByteArray()));
232:                Object o = in.readObject();
233:                Debug.OUT.println("####### o.type = " + o.getClass().getName());
234:                Debug.OUT.println("####### equal = " + d.equals(o));
235:            }
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.