View Javadoc

1   /*
2    * Copyright (C) 2004 TiongHiang Lee
3    *
4    * This library is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Lesser General Public
6    * License as published by the Free Software Foundation; either
7    * version 2.1 of the License, or (at your option) any later version.
8    *
9    * This library is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12   * Lesser General Public License for more details.
13   *
14   * You should have received a copy of the GNU Lesser General Public
15   * License along with this library; if not,  write to the Free Software
16   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17   *
18   * Email: thlee@onemindsoft.org
19   */
20  
21  package org.onemind.commons.java.lang;
22  
23  /***
24   * An mutable short
25   * @author TiongHiang Lee (thlee@onemindsoft.org)
26   * @version $Id: MutableShort.java,v 1.3 2004/09/03 13:24:14 thlee Exp $ $Name:  $
27   */
28  public class MutableShort extends Number
29  {
30  
31      /*** the long value * */
32      private short _value;
33  
34      /***
35       * {@inheritDoc}
36       * @param l the long value
37       */
38      public MutableShort(short l)
39      {
40          _value = l;
41      }
42  
43      /***
44       * Set the short value
45       * @param l the short value
46       */
47      public final void set(short l)
48      {
49          _value = l;
50      }
51  
52      /***
53       * {@inheritDoc}
54       */
55      public final byte byteValue()
56      {
57          return (byte) _value;
58      }
59  
60      /***
61       * {@inheritDoc}
62       */
63      public final double doubleValue()
64      {
65          return (double) _value;
66      }
67  
68      /***
69       * {@inheritDoc}
70       */
71      public final float floatValue()
72      {
73          return _value;
74      }
75  
76      /***
77       * {@inheritDoc}
78       */
79      public final int intValue()
80      {
81          return (int) _value;
82      }
83  
84      /***
85       * {@inheritDoc}
86       */
87      public final long longValue()
88      {
89          return (long) _value;
90      }
91  
92      /***
93       * {@inheritDoc}
94       */
95      public final short shortValue()
96      {
97          return (short) _value;
98      }
99      
100     /***
101      * increase by i
102      * @param i the value to increase
103      */
104     public void inc(short i)
105     {
106         _value += i;
107     }
108     
109     /***
110      * decrease by i
111      * @param i the value to decrease
112      */
113     public void dec(short i)
114     {
115         _value -= i;
116     }
117     
118     /*** 
119      * {@inheritDoc}
120      */
121     public String toString()
122     {
123         return String.valueOf(_value);
124     }
125 }