KickJava   Java API By Example, From Geeks To Geeks.

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


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 boxing/unboxing int's
8  */

9 public class SettableIntValue extends SettableValue {
10
11   public SettableIntValue() {
12     super();
13   }
14
15   public void setInt(int value) {
16     super.set(new Integer JavaDoc(value));
17   }
18
19   public int intValue() {
20     return intValue(0);
21   }
22
23   public int intValue(int defaultValue) {
24     if (isSet()) {
25       Integer JavaDoc i = (Integer JavaDoc) value();
26       return i.intValue();
27     } else {
28       return defaultValue;
29     }
30   }
31
32   public Object JavaDoc clone() {
33     SettableIntValue out = new SettableIntValue();
34     if (this.isSet()) out.set(this.value());
35     return out;
36   }
37 }
Popular Tags