1 23 24 28 29 package com.sun.jdo.spi.persistence.support.sqlstore.sco; 30 31 import java.io.ObjectStreamException ; 32 33 import com.sun.jdo.spi.persistence.support.sqlstore.PersistenceCapable; 34 import com.sun.jdo.spi.persistence.support.sqlstore.StateManager; 35 import com.sun.jdo.spi.persistence.support.sqlstore.SCO; 36 import com.sun.jdo.spi.persistence.support.sqlstore.SCODate; 37 import com.sun.jdo.spi.persistence.support.sqlstore.PersistenceManager; 38 39 45 public class SqlTime 46 extends java.sql.Time 47 implements SCODate 48 { 49 private transient PersistenceCapable owner; 50 51 private transient String fieldName; 52 53 59 public SqlTime(Object owner, String fieldName) 60 { 61 super(0); 62 if (owner instanceof PersistenceCapable) 63 { 64 this.owner = (PersistenceCapable)owner; 65 this.fieldName = fieldName; 66 } 67 } 68 69 76 public SqlTime(Object owner, String fieldName, long date) 77 { 78 super(date); 79 if (owner instanceof PersistenceCapable) 80 { 81 this.owner = (PersistenceCapable)owner; 82 this.fieldName = fieldName; 83 } 84 } 85 86 93 public void setTime(long time) { 94 this.makeDirty(); 95 super.setTime(time); 96 } 97 98 106 public Object clone() 107 { 108 SqlTime obj = (SqlTime) super.clone(); 109 110 obj.owner = null; 111 obj.fieldName = null; 112 113 return obj; 114 } 115 116 117 118 127 public void setHours(int hours) { 128 this.makeDirty(); 129 super.setHours(hours); 130 } 131 132 141 public void setMinutes(int minutes) { 142 this.makeDirty(); 143 super.setMinutes(minutes); 144 } 145 146 155 public void setSeconds(int seconds) { 156 this.makeDirty(); 157 super.setSeconds(seconds); 158 } 159 160 161 162 166 public Object cloneInternal() 167 { 168 return super.clone(); 169 } 170 171 178 public void setTimeInternal(long time) { 179 super.setTime(time); 180 } 181 182 187 public void unsetOwner() 188 { 189 this.owner = null; 190 this.fieldName = null; 191 } 192 193 198 public Object getOwner() 199 { 200 return this.owner; 201 } 202 203 208 public String getFieldName() 209 { 210 return this.fieldName; 211 } 212 213 216 public StateManager makeDirty() 217 { 218 if (owner != null) 219 { 220 StateManager stateManager = owner.jdoGetStateManager(); 221 222 if (stateManager != null) 223 { 224 PersistenceManager pm = (PersistenceManager) stateManager.getPersistenceManagerInternal(); 225 226 pm.acquireShareLock(); 227 228 try 229 { 230 synchronized (stateManager) 231 { 232 if (owner != null) 237 { 238 stateManager.makeDirty(fieldName); 239 return stateManager; 240 } 241 } 242 } 243 finally 244 { 245 pm.releaseShareLock(); 246 } 247 } 248 } 249 return null; 250 } 251 252 255 public void applyUpdates(StateManager sm, boolean modified) 256 { 257 } 258 259 266 Object writeReplace() throws ObjectStreamException 267 { 268 return new java.sql.Time (getTime()); 269 } 270 } 271 | Popular Tags |