KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > util > SettableBoolValue


1 /**
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.util;
5
6 /**
7  * a thin wrapper around SettableValue to help with [un]boxing boolean values
8  */

9 public class SettableBoolValue extends SettableValue {
10
11   public SettableBoolValue() {
12     super();
13   }
14
15   public void setBool(boolean value) {
16     super.set(new Boolean JavaDoc(value));
17   }
18
19   /**
20    * @return set value; false otherwise
21    */

22   public boolean boolValue() {
23     return boolValue(false);
24   }
25
26   /**
27    * @return set value; defaultValue otherwise
28    */

29   public boolean boolValue(boolean defaultValue) {
30     if (isSet()) {
31       Boolean JavaDoc b = (Boolean JavaDoc) value();
32       return b.booleanValue();
33     } else {
34       return defaultValue;
35     }
36   }
37
38   public Object JavaDoc clone() {
39     SettableBoolValue out = new SettableBoolValue();
40     if (this.isSet()) out.set(this.value());
41     return out;
42   }
43
44 }
Popular Tags