1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.onemind.commons.java.lang;
21
22 /***
23 * An mutable integer
24 * @author TiongHiang Lee (thlee@onemindsoft.org)
25 * @version $Id: MutableInteger.java,v 1.3 2004/09/03 13:24:14 thlee Exp $ $Name: $
26 */
27 public class MutableInteger extends Number
28 {
29
30 /*** the integer value * */
31 private int _value;
32
33 /***
34 * {@inheritDoc}
35 * @param l the int value
36 */
37 public MutableInteger(int l)
38 {
39 _value = l;
40 }
41
42 /***
43 * Set the value
44 * @param l the int value
45 */
46 public final void set(int l)
47 {
48 _value = l;
49 }
50
51 /***
52 * {@inheritDoc}
53 */
54 public final byte byteValue()
55 {
56 return (byte) _value;
57 }
58
59 /***
60 * {@inheritDoc}
61 */
62 public final double doubleValue()
63 {
64 return (double) _value;
65 }
66
67 /***
68 * {@inheritDoc}
69 */
70 public final float floatValue()
71 {
72 return (float) _value;
73 }
74
75 /***
76 * {@inheritDoc}
77 */
78 public final int intValue()
79 {
80 return _value;
81 }
82
83 /***
84 * {@inheritDoc}
85 */
86 public final long longValue()
87 {
88 return (long) _value;
89 }
90
91 /***
92 * {@inheritDoc}
93 */
94 public final short shortValue()
95 {
96 return (short) _value;
97 }
98
99 /***
100 * increase by i
101 * @param i the value to increase
102 */
103 public void inc(int i)
104 {
105 _value += i;
106 }
107
108 /***
109 * decrease by i
110 * @param i the value to decrease
111 */
112 public void dec(int i)
113 {
114 _value -= i;
115 }
116
117 /***
118 * {@inheritDoc}
119 */
120 public String toString()
121 {
122 return String.valueOf(_value);
123 }
124 }