1 23 24 package com.sun.jdo.spi.persistence.support.sqlstore.sco; 25 26 import java.io.ObjectStreamException ; 27 28 import com.sun.jdo.spi.persistence.support.sqlstore.PersistenceCapable; 29 import com.sun.jdo.spi.persistence.support.sqlstore.StateManager; 30 import com.sun.jdo.spi.persistence.support.sqlstore.SCO; 31 import com.sun.jdo.spi.persistence.support.sqlstore.SCODate; 32 import com.sun.jdo.spi.persistence.support.sqlstore.PersistenceManager; 33 34 40 public class Date 41 extends java.util.Date 42 implements SCODate 43 { 44 45 private transient PersistenceCapable owner; 46 47 private transient String fieldName; 48 49 55 public Date(Object owner, String fieldName) 56 { 57 super(); 58 if (owner instanceof PersistenceCapable) 59 { 60 this.owner = (PersistenceCapable)owner; 61 this.fieldName = fieldName; 62 } 63 } 64 65 72 public Date(Object owner, String fieldName, long date) 73 { 74 super(date); 75 if (owner instanceof PersistenceCapable) 76 { 77 this.owner = (PersistenceCapable)owner; 78 this.fieldName = fieldName; 79 } 80 } 81 82 89 public void setTime(long time) { 90 this.makeDirty(); 91 super.setTime(time); 92 } 93 94 102 public Object clone() 103 { 104 Date obj = (Date) super.clone(); 105 106 obj.owner = null; 107 obj.fieldName = null; 108 109 return obj; 110 } 111 112 113 114 124 public void setYear(int year) { 125 this.makeDirty(); 126 super.setYear(year); 127 } 128 129 137 public void setMonth(int month) { 138 this.makeDirty(); 139 super.setMonth(month); 140 } 141 142 152 public void setDate(int date) { 153 this.makeDirty(); 154 super.setDate(date); 155 } 156 157 166 public void setHours(int hours) { 167 this.makeDirty(); 168 super.setHours(hours); 169 } 170 171 180 public void setMinutes(int minutes) { 181 this.makeDirty(); 182 super.setMinutes(minutes); 183 } 184 185 194 public void setSeconds(int seconds) { 195 this.makeDirty(); 196 super.setSeconds(seconds); 197 } 198 199 200 201 205 public Object cloneInternal() 206 { 207 return super.clone(); 208 } 209 210 217 public void setTimeInternal(long time) { 218 super.setTime(time); 219 } 220 221 226 public void unsetOwner() 227 { 228 this.owner = null; 229 this.fieldName = null; 230 } 231 232 237 public Object getOwner() 238 { 239 return this.owner; 240 } 241 242 247 public String getFieldName() 248 { 249 return this.fieldName; 250 } 251 252 255 public StateManager makeDirty() 256 { 257 if (owner != null) 258 { 259 StateManager stateManager = owner.jdoGetStateManager(); 260 261 if (stateManager != null) 262 { 263 PersistenceManager pm = (PersistenceManager) stateManager.getPersistenceManagerInternal(); 264 265 pm.acquireShareLock(); 266 267 try 268 { 269 synchronized (stateManager) 270 { 271 if (owner != null) 276 { 277 stateManager.makeDirty(fieldName); 278 return stateManager; 279 } 280 } 281 } 282 finally 283 { 284 pm.releaseShareLock(); 285 } 286 } 287 288 } 289 290 return null; 291 } 292 293 296 public void applyUpdates(StateManager sm, boolean modified) 297 { 298 } 299 300 301 308 Object writeReplace() throws ObjectStreamException 309 { 310 return new java.util.Date (getTime()); 311 } 312 313 } 314 315 316 317 | Popular Tags |