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.Date;
07:
08: /**
09: * Created By: Mike
10: * Date: Feb 8, 2004
11: * Time: 11:54:04 PM
12: *
13: * Last Checkin: $Author: mrettig $
14: * Date: $Date: 2004/02/10 02:50:39 $
15: * Revision: $Revision: 1.3 $
16: */
17: public class JaxorDate extends Date implements MutationInterceptor {
18:
19: private transient FieldAdapter _field;
20:
21: public JaxorDate(Date date, FieldAdapter field) {
22: super (date.getTime());
23: _field = field;
24: }
25:
26: public Object getDecoratedObject() {
27: return new Date(getTime());
28: }
29:
30: public void setFieldAdapter(FieldAdapter adapter) {
31: _field = adapter;
32: }
33:
34: public void setHours(int i) {
35: Date clone = (Date) clone();
36: super .setHours(i);
37: registerChange(clone);
38: }
39:
40: private void registerChange(Date clone) {
41: if (_field != null && _field.getValue() == this )
42: _field.registerChange(this , clone);
43: }
44:
45: public FieldAdapter getFieldAdapter() {
46: return _field;
47: }
48:
49: public void setMinutes(int i) {
50: Date clone = (Date) clone();
51: super .setMinutes(i);
52: registerChange(clone);
53: }
54:
55: public void setSeconds(int i) {
56: Date clone = (Date) clone();
57: super .setSeconds(i);
58: registerChange(clone);
59: }
60:
61: public void setYear(int year) {
62: Date clone = (Date) clone();
63: super .setYear(year);
64: registerChange(clone);
65: }
66:
67: public void setMonth(int month) {
68: Date clone = (Date) clone();
69: super .setMonth(month);
70: registerChange(clone);
71: }
72:
73: public void setDate(int date) {
74: Date clone = (Date) clone();
75: super .setDate(date);
76: registerChange(clone);
77: }
78:
79: public void setTime(long date) {
80: Date clone = (Date) clone();
81: super.setTime(date);
82: registerChange(clone);
83: }
84: }
|