Source Code Cross Referenced for Date.java in  » Testing » PolePosition-0.20 » com » versant » core » jdo » sco » 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 
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;
012:
013:        import com.versant.core.common.Debug;
014:        import com.versant.core.jdo.VersantStateManager;
015:        import com.versant.core.common.VersantFieldMetaData;
016:
017:        import javax.jdo.spi.PersistenceCapable;
018:        import java.io.*;
019:
020:        /**
021:         * @keep-all
022:         */
023:        public class Date extends java.util.Date implements  SCODate {
024:
025:            private transient PersistenceCapable owner;
026:            private final transient VersantFieldMetaData fmd;
027:            private transient VersantStateManager stateManager;
028:
029:            /**
030:             * Creates a <code>Date</code> object that represents the given time
031:             * in milliseconds.
032:             *
033:             * @param date the number of milliseconds
034:             */
035:            public Date(PersistenceCapable owner,
036:                    VersantStateManager stateManager, VersantFieldMetaData fmd,
037:                    long date) {
038:                super (date);
039:                this .owner = owner;
040:                this .stateManager = stateManager;
041:                this .fmd = fmd;
042:            }
043:
044:            /**
045:             * Sets the <tt>Date</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:             * 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:                return obj;
070:            }
071:
072:            /** -----------Depricated Methods------------------*/
073:
074:            /**
075:             * Sets the year of this <tt>Date</tt> object to be the specified
076:             * value plus 1900.
077:             *
078:             * @param year the year value.
079:             * @see java.util.Calendar
080:             * @see java.util.Date
081:             * @deprecated As of JDK version 1.1,
082:             *             replaced by <code>Calendar.set(Calendar.YEAR, year + 1900)</code>.
083:             */
084:            public void setYear(int year) {
085:                this .makeDirty();
086:                super .setYear(year);
087:            }
088:
089:            /**
090:             * Sets the month of this date to the specified value.
091:             *
092:             * @param month the month value between 0-11.
093:             * @see java.util.Calendar
094:             * @see java.util.Date
095:             * @deprecated As of JDK version 1.1,
096:             *             replaced by <code>Calendar.set(Calendar.MONTH, int month)</code>.
097:             */
098:            public void setMonth(int month) {
099:                this .makeDirty();
100:                super .setMonth(month);
101:            }
102:
103:            /**
104:             * Sets the day of the month of this <tt>Date</tt> object to the
105:             * specified value.
106:             *
107:             * @param date the day of the month value between 1-31.
108:             * @see java.util.Calendar
109:             * @see java.util.Date
110:             * @deprecated As of JDK version 1.1,
111:             *             replaced by <code>Calendar.set(Calendar.DAY_OF_MONTH, int date)</code>.
112:             */
113:            public void setDate(int date) {
114:                this .makeDirty();
115:                super .setDate(date);
116:            }
117:
118:            /**
119:             * Sets the hour of this <tt>Date</tt> object to the specified value.
120:             *
121:             * @param hours the hour value.
122:             * @see java.util.Calendar
123:             * @see java.util.Date
124:             * @deprecated As of JDK version 1.1,
125:             *             replaced by <code>Calendar.set(Calendar.HOUR_OF_DAY, int hours)</code>.
126:             */
127:            public void setHours(int hours) {
128:                this .makeDirty();
129:                super .setHours(hours);
130:            }
131:
132:            /**
133:             * Sets the minutes of this <tt>Date</tt> object to the specified value.
134:             *
135:             * @param minutes the value of the minutes.
136:             * @see java.util.Calendar
137:             * @see java.util.Date
138:             * @deprecated As of JDK version 1.1,
139:             *             replaced by <code>Calendar.set(Calendar.MINUTE, int minutes)</code>.
140:             */
141:            public void setMinutes(int minutes) {
142:                this .makeDirty();
143:                super .setMinutes(minutes);
144:            }
145:
146:            /**
147:             * Sets the seconds of this <tt>Date</tt> to the specified value.
148:             *
149:             * @param seconds the seconds value.
150:             * @see java.util.Calendar
151:             * @see java.util.Date
152:             * @deprecated As of JDK version 1.1,
153:             *             replaced by <code>Calendar.set(Calendar.SECOND, int seconds)</code>.
154:             */
155:            public void setSeconds(int seconds) {
156:                this .makeDirty();
157:                super .setSeconds(seconds);
158:            }
159:
160:            /** ---------------- internal methods ------------------- */
161:
162:            /**
163:             * Sets the <tt>Date</tt> object without notification of the Owner
164:             * field. Used internaly to populate date from DB
165:             *
166:             * @param time the number of milliseconds.
167:             * @see java.util.Date
168:             */
169:            public void setTimeInternal(long time) {
170:                super .setTime(time);
171:            }
172:
173:            /**
174:             * Nullifies references to the owner Object and Field
175:             */
176:            public void makeTransient() {
177:                this .owner = null;
178:                this .stateManager = null;
179:            }
180:
181:            /**
182:             * Returns the owner object of the SCO instance
183:             *
184:             * @return owner object
185:             */
186:            public Object getOwner() {
187:                return this .owner;
188:            }
189:
190:            /**
191:             * Marks object dirty
192:             */
193:            public void makeDirty() {
194:                if (stateManager != null) {
195:                    stateManager.makeDirty(owner, fmd.getManagedFieldNo());
196:                }
197:            }
198:
199:            public void reset() {
200:            }
201:
202:            public void writeExternal(ObjectOutput out) throws IOException {
203:                out.writeLong(super .getTime());
204:            }
205:
206:            public void readExternal(ObjectInput in) throws IOException,
207:                    ClassNotFoundException {
208:                super .setTime(in.readLong());
209:            }
210:
211:            public static void main(String[] args) throws Exception {
212:                Date d = new Date(null, null, null, System.currentTimeMillis());
213:                final long time = System.currentTimeMillis() - 5000;
214:                d.setTime(time);
215:                ByteArrayOutputStream bout = new ByteArrayOutputStream();
216:                ObjectOutputStream out = new ObjectOutputStream(bout);
217:                out.writeObject(d);
218:
219:                ObjectInputStream in = new ObjectInputStream(
220:                        new ByteArrayInputStream(bout.toByteArray()));
221:                Object o = in.readObject();
222:                Debug.OUT.println("####### o.type = " + o.getClass().getName());
223:                Debug.OUT.println("####### equal = " + d.equals(o));
224:            }
225:
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.