01: package net.sourceforge.jaxor.mappers;
02:
03: import net.sourceforge.jaxor.MetaField;
04: import net.sourceforge.jaxor.api.FieldLifeCycleListener;
05: import net.sourceforge.jaxor.api.JaxorContext;
06:
07: /**
08: * Created By: Mike
09: * Date: Nov 27, 2003
10: * Time: 9:15:07 PM
11: *
12: * Last Checkin: $Author: mrettig $
13: * Date: $Date: 2004/01/24 18:03:56 $
14: * Revision: $Revision: 1.6 $
15: */
16: public class LongVersionFieldAdapter extends FieldAdapterImpl implements
17: FieldLifeCycleListener {
18:
19: public LongVersionFieldAdapter(MetaField metaData, Object obj) {
20: super (metaData, obj);
21: }
22:
23: public void beforeInsert(JaxorContext context) {
24: increment();
25: }
26:
27: private void increment() {
28: if (getValue() == null)
29: setValue(new Long(0));
30: else
31: setValue(new Long(((Long) getValue()).longValue() + 1));
32: }
33:
34: public void beforeUpdate(JaxorContext context) {
35: increment();
36: }
37:
38: public void beforeDelete(JaxorContext context) {
39: }
40: }
|