01: /*
02: * This is free software, licensed under the Gnu Public License (GPL)
03: * get a copy from <http://www.gnu.org/licenses/gpl.html>
04: * $Id: BooleanPropertyHolder.java,v 1.3 2004/02/03 09:53:07 hzeller Exp $
05: * author: Henner Zeller <H.Zeller@acm.org>
06: */
07: package henplus.property;
08:
09: /**
10: * A boolean property.
11: */
12: public abstract class BooleanPropertyHolder extends
13: EnumeratedPropertyHolder {
14: private final static String[] BOOL_VALUES = { "0", "off", "false",
15: "1", "on", "true" };
16:
17: public BooleanPropertyHolder() {
18: super (BOOL_VALUES);
19: }
20:
21: public BooleanPropertyHolder(boolean initialValue) {
22: this ();
23: _propertyValue = initialValue ? "true" : "false";
24: }
25:
26: protected final void enumeratedPropertyChanged(int index,
27: String value) throws Exception {
28: /*
29: * the upper part of the array contains the 'true' values.
30: */
31: booleanPropertyChanged(index >= (BOOL_VALUES.length / 2));
32: }
33:
34: /**
35: * to be overridden to get informed of the boolean change. Throw
36: * an Exception if this change is not possible.
37: */
38: public abstract void booleanPropertyChanged(boolean newValue)
39: throws Exception;
40: }
41: /*
42: * Local variables:
43: * c-basic-offset: 4
44: * compile-command: "ant -emacs -find build.xml"
45: * End:
46: */
|