1 10 11 package com.triactive.jdo.sco; 12 13 import com.triactive.jdo.SCO; 14 import java.io.ObjectStreamException ; 15 import javax.jdo.JDOHelper; 16 17 18 24 25 public class SqlTimestamp extends java.sql.Timestamp implements SCO 26 { 27 private transient Object owner; 28 private transient String fieldName; 29 30 31 40 41 public SqlTimestamp(Object owner, String fieldName, java.sql.Timestamp ts) 42 { 43 super(ts.getTime()); 44 super.setNanos(ts.getNanos()); 45 46 this.owner = owner; 47 this.fieldName = fieldName; 48 } 49 50 51 public Object getOwner() 52 { 53 return owner; 54 } 55 56 57 public String getFieldName() 58 { 59 return fieldName; 60 } 61 62 63 public void makeDirty() 64 { 65 if (owner != null) 66 JDOHelper.makeDirty(owner, fieldName); 67 } 68 69 70 public void applyUpdates() 71 { 72 } 73 74 75 public void unsetOwner() 76 { 77 owner = null; 78 fieldName = null; 79 } 80 81 82 90 91 public Object clone() 92 { 93 Object obj = super.clone(); 94 95 ((SqlTimestamp)obj).unsetOwner(); 96 97 return obj; 98 } 99 100 101 public void setTime(long time) 102 { 103 super.setTime(time); 104 makeDirty(); 105 } 106 107 108 public void setNanos(int n) 109 { 110 super.setNanos(n); 111 makeDirty(); 112 } 113 114 115 130 131 public void setYear(int year) 132 { 133 super.setYear(year); 134 makeDirty(); 135 } 136 137 138 152 153 public void setMonth(int month) 154 { 155 super.setMonth(month); 156 makeDirty(); 157 } 158 159 160 175 176 public void setDate(int date) 177 { 178 super.setDate(date); 179 makeDirty(); 180 } 181 182 183 195 196 public void setHours(int hours) 197 { 198 super.setHours(hours); 199 makeDirty(); 200 } 201 202 203 215 216 public void setMinutes(int minutes) 217 { 218 super.setMinutes(minutes); 219 makeDirty(); 220 } 221 222 223 235 236 public void setSeconds(int seconds) 237 { 238 super.setSeconds(seconds); 239 makeDirty(); 240 } 241 242 243 252 253 protected Object writeReplace() throws ObjectStreamException 254 { 255 java.sql.Timestamp ts = new java.sql.Timestamp (getTime()); 256 257 ts.setNanos(getNanos()); 258 259 return ts; 260 } 261 } 262 | Popular Tags |