01: package net.xoetrope.xui.helper;
02:
03: import net.xoetrope.xui.data.XModel;
04: import net.xoetrope.xui.data.XBaseModel;
05:
06: /**
07: * A helper for an int model field
08: * <p> Copyright (c) Xoetrope Ltd., 2002-2004</p>
09: * <p> $Revision: 1.2 $</p>
10: * <p> License: see License.txt</p>
11: */
12: public class IntegerAdapter {
13: XModel model;
14:
15: public IntegerAdapter(Object modelNode) {
16: model = (XModel) modelNode;
17: }
18:
19: /**
20: * Get the model value as an int value
21: * @return the integer value
22: */
23: public int get() {
24: return model.getAttribValueAsInt(XBaseModel.VALUE_ATTRIBUTE);
25: }
26:
27: /**
28: * Set the model value as an integer value
29: * @param newValue the new value
30: */
31: public void set(int newValue) {
32: model.set(new Integer(newValue));
33: }
34:
35: /**
36: * Increment the model value by one
37: */
38: public void increment() {
39: model.set(new Integer(get() + 1));
40: }
41:
42: /**
43: * Decrement the model value by one
44: */
45: public void decrement() {
46: model.set(new Integer(get() - 1));
47: }
48: }
|