Source Code Cross Referenced for SqlTimestamp.java in  » Database-ORM » TJDO » com » triactive » 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 » Database ORM » TJDO » com.triactive.jdo.sco 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004 (C) TJDO.
003:         * All rights reserved.
004:         *
005:         * This software is distributed under the terms of the TJDO License version 1.0.
006:         * See the terms of the TJDO License in the documentation provided with this software.
007:         *
008:         * $Id: SqlTimestamp.java,v 1.6 2004/01/18 03:01:06 jackknifebarber Exp $
009:         */
010:
011:        package com.triactive.jdo.sco;
012:
013:        import com.triactive.jdo.SCO;
014:        import java.io.ObjectStreamException;
015:        import javax.jdo.JDOHelper;
016:
017:        /**
018:         * A mutable second-class SQL timestamp object.
019:         *
020:         * @author <a href="mailto:mmartin5@austin.rr.com">Mike Martin</a>
021:         * @version $Revision: 1.6 $
022:         */
023:
024:        public class SqlTimestamp extends java.sql.Timestamp implements  SCO {
025:            private transient Object owner;
026:            private transient String fieldName;
027:
028:            /**
029:             * Creates a <code>SqlTimestamp</code> object that represents the same time
030:             * as the given <tt>java.sql.Timestamp</tt>. Assigns owning object and field
031:             * name.
032:             *
033:             * @param owner     the owning object
034:             * @param fieldName the owning field name
035:             * @param ts        the initial timestamp value
036:             */
037:
038:            public SqlTimestamp(Object owner, String fieldName,
039:                    java.sql.Timestamp ts) {
040:                super (ts.getTime());
041:                super .setNanos(ts.getNanos());
042:
043:                this .owner = owner;
044:                this .fieldName = fieldName;
045:            }
046:
047:            public Object getOwner() {
048:                return owner;
049:            }
050:
051:            public String getFieldName() {
052:                return fieldName;
053:            }
054:
055:            public void makeDirty() {
056:                if (owner != null)
057:                    JDOHelper.makeDirty(owner, fieldName);
058:            }
059:
060:            public void applyUpdates() {
061:            }
062:
063:            public void unsetOwner() {
064:                owner = null;
065:                fieldName = null;
066:            }
067:
068:            /**
069:             * Creates and returns a copy of this object.
070:             *
071:             * <P>Mutable second-class Objects are required to provide a public
072:             * clone method in order to allow for copying PersistenceCapable
073:             * objects. In contrast to Object.clone(), this method must not throw a
074:             * CloneNotSupportedException.
075:             */
076:
077:            public Object clone() {
078:                Object obj = super .clone();
079:
080:                ((SqlTimestamp) obj).unsetOwner();
081:
082:                return obj;
083:            }
084:
085:            public void setTime(long time) {
086:                super .setTime(time);
087:                makeDirty();
088:            }
089:
090:            public void setNanos(int n) {
091:                super .setNanos(n);
092:                makeDirty();
093:            }
094:
095:            /**
096:             * Sets the year of this <tt>Date</tt> object to be the specified 
097:             * value plus 1900. This <code>Date</code> object is modified so 
098:             * that it represents a point in time within the specified year, 
099:             * with the month, date, hour, minute, and second the same as 
100:             * before, as interpreted in the local time zone. (Of course, if 
101:             * the date was February 29, for example, and the year is set to a 
102:             * non-leap year, then the new date will be treated as if it were 
103:             * on March 1.)
104:             *
105:             * @param   year    the year value.
106:             * @see     java.util.Calendar
107:             * @deprecated As of JDK version 1.1,
108:             * replaced by <code>Calendar.set(Calendar.YEAR, year + 1900)</code>.
109:             */
110:
111:            public void setYear(int year) {
112:                super .setYear(year);
113:                makeDirty();
114:            }
115:
116:            /**
117:             * Sets the month of this date to the specified value. This 
118:             * <tt>Date</tt> object is modified so that it represents a point 
119:             * in time within the specified month, with the year, date, hour, 
120:             * minute, and second the same as before, as interpreted in the 
121:             * local time zone. If the date was October 31, for example, and 
122:             * the month is set to June, then the new date will be treated as 
123:             * if it were on July 1, because June has only 30 days.
124:             *
125:             * @param   month   the month value between 0-11.
126:             * @see     java.util.Calendar
127:             * @deprecated As of JDK version 1.1,
128:             * replaced by <code>Calendar.set(Calendar.MONTH, int month)</code>.
129:             */
130:
131:            public void setMonth(int month) {
132:                super .setMonth(month);
133:                makeDirty();
134:            }
135:
136:            /**
137:             * Sets the day of the month of this <tt>Date</tt> object to the 
138:             * specified value. This <tt>Date</tt> object is modified so that 
139:             * it represents a point in time within the specified day of the 
140:             * month, with the year, month, hour, minute, and second the same 
141:             * as before, as interpreted in the local time zone. If the date 
142:             * was April 30, for example, and the date is set to 31, then it 
143:             * will be treated as if it were on May 1, because April has only 
144:             * 30 days.
145:             *
146:             * @param   date   the day of the month value between 1-31.
147:             * @see     java.util.Calendar
148:             * @deprecated As of JDK version 1.1,
149:             * replaced by <code>Calendar.set(Calendar.DAY_OF_MONTH, int date)</code>.
150:             */
151:
152:            public void setDate(int date) {
153:                super .setDate(date);
154:                makeDirty();
155:            }
156:
157:            /**
158:             * Sets the hour of this <tt>Date</tt> object to the specified value. 
159:             * This <tt>Date</tt> object is modified so that it represents a point 
160:             * in time within the specified hour of the day, with the year, month, 
161:             * date, minute, and second the same as before, as interpreted in the 
162:             * local time zone.
163:             *
164:             * @param   hours   the hour value.
165:             * @see     java.util.Calendar
166:             * @deprecated As of JDK version 1.1,
167:             * replaced by <code>Calendar.set(Calendar.HOUR_OF_DAY, int hours)</code>.
168:             */
169:
170:            public void setHours(int hours) {
171:                super .setHours(hours);
172:                makeDirty();
173:            }
174:
175:            /**
176:             * Sets the minutes of this <tt>Date</tt> object to the specified value. 
177:             * This <tt>Date</tt> object is modified so that it represents a point 
178:             * in time within the specified minute of the hour, with the year, month, 
179:             * date, hour, and second the same as before, as interpreted in the 
180:             * local time zone.
181:             *
182:             * @param   minutes   the value of the minutes.
183:             * @see     java.util.Calendar
184:             * @deprecated As of JDK version 1.1,
185:             * replaced by <code>Calendar.set(Calendar.MINUTE, int minutes)</code>.
186:             */
187:
188:            public void setMinutes(int minutes) {
189:                super .setMinutes(minutes);
190:                makeDirty();
191:            }
192:
193:            /**
194:             * Sets the seconds of this <tt>Date</tt> to the specified value. 
195:             * This <tt>Date</tt> object is modified so that it represents a 
196:             * point in time within the specified second of the minute, with 
197:             * the year, month, date, hour, and minute the same as before, as 
198:             * interpreted in the local time zone.
199:             *
200:             * @param   seconds   the seconds value.
201:             * @see     java.util.Calendar
202:             * @deprecated As of JDK version 1.1,
203:             * replaced by <code>Calendar.set(Calendar.SECOND, int seconds)</code>. 
204:             */
205:
206:            public void setSeconds(int seconds) {
207:                super .setSeconds(seconds);
208:                makeDirty();
209:            }
210:
211:            /**
212:             * Replaces the object to be serialized with a java.sql.Timestamp object.
213:             * Invoked by the serialization mechanism to obtain an alternative object
214:             * to be used when writing an object to the stream.
215:             *
216:             * @return
217:             *      The <code>java.sql.Timestamp</code> to be serialized instead of this
218:             *      object.
219:             */
220:
221:            protected Object writeReplace() throws ObjectStreamException {
222:                java.sql.Timestamp ts = new java.sql.Timestamp(getTime());
223:
224:                ts.setNanos(getNanos());
225:
226:                return ts;
227:            }
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.