01: package net.sourceforge.jaxor.util;
02:
03: import net.sourceforge.jaxor.api.FieldAdapter;
04: import net.sourceforge.jaxor.api.MutationInterceptor;
05:
06: import java.sql.Timestamp;
07:
08: /**
09: * Created By: Mike
10: * Date: Feb 9, 2004
11: * Time: 12:04:10 AM
12: *
13: * Last Checkin: $Author: mrettig $
14: * Date: $Date: 2004/02/10 02:50:39 $
15: * Revision: $Revision: 1.3 $
16: */
17: public class JaxorTimestamp extends Timestamp implements
18: MutationInterceptor {
19:
20: private transient FieldAdapter _field;
21:
22: public JaxorTimestamp(long time, FieldAdapter field) {
23: super (time);
24: _field = field;
25: }
26:
27: public Object getDecoratedObject() {
28: return new Timestamp(getTime());
29: }
30:
31: public FieldAdapter getFieldAdapter() {
32: return _field;
33: }
34:
35: public void setFieldAdapter(FieldAdapter adapter) {
36: _field = adapter;
37: }
38:
39: public void setNanos(int n) {
40: Timestamp clone = (Timestamp) clone();
41: super .setNanos(n);
42: registerChange(clone);
43: }
44:
45: public void setYear(int year) {
46: Timestamp clone = (Timestamp) clone();
47: super .setYear(year);
48: registerChange(clone);
49: }
50:
51: public void setMonth(int month) {
52: Timestamp clone = (Timestamp) clone();
53: super .setMonth(month);
54: registerChange(clone);
55: }
56:
57: public void setDate(int date) {
58: Timestamp clone = (Timestamp) clone();
59: super .setDate(date);
60: registerChange(clone);
61: }
62:
63: public void setHours(int hours) {
64: Timestamp clone = (Timestamp) clone();
65: super .setHours(hours);
66: registerChange(clone);
67: }
68:
69: public void setMinutes(int minutes) {
70: Timestamp clone = (Timestamp) clone();
71: super .setMinutes(minutes);
72: registerChange(clone);
73: }
74:
75: public void setSeconds(int seconds) {
76: Timestamp clone = (Timestamp) clone();
77: super .setSeconds(seconds);
78: registerChange(clone);
79: }
80:
81: public void setTime(long time) {
82: Timestamp clone = (Timestamp) clone();
83: super .setTime(time);
84: registerChange(clone);
85: }
86:
87: private void registerChange(Timestamp clone) {
88: if (_field != null && _field.getValue() == this)
89: _field.registerChange(this, clone);
90: }
91: }
|