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