org.openmali.types.primitives
Class MutableByte

java.lang.Object
  extended by java.lang.Number
      extended by org.openmali.types.primitives.MutableByte
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<MutableByte>

public class MutableByte
extends java.lang.Number
implements java.lang.Comparable<MutableByte>

This a mutable derivation of the Byte class. Most of the code is borrowed from the Byte class.

See Also:
Serialized Form

Constructor Summary
MutableByte(byte value)
          Constructs a newly allocated MutableByte object that represents the specified byte value.
MutableByte(java.lang.String s)
          Constructs a newly allocated MutableByte object that represents the byte value indicated by the String parameter.
 
Method Summary
 byte byteValue()
          Returns the value of this MutableByte as a byte.
 int compareTo(MutableByte anotherByte)
          Compares two MutableByte objects numerically.
 double doubleValue()
          Returns the value of this MutableByte as a double.
 boolean equals(java.lang.Object obj)
          Compares this object to the specified object.
 float floatValue()
          Returns the value of this MutableByte as a float.
 int hashCode()
          Returns a hash code for this MutableByte.
 int intValue()
          Returns the value of this MutableByte as an int.
 long longValue()
          Returns the value of this MutableByte as a long.
 void setValue(byte value)
           
 short shortValue()
          Returns the value of this MutableByte as a short.
 java.lang.String toString()
          Returns a String object representing this MutableByte's value.
static MutableByte valueOf(byte b)
          Returns a MutableByte instance representing the specified byte value.
static MutableByte valueOf(java.lang.String s)
          Returns a MutableByte object holding the value given by the specified String.
static MutableByte valueOf(java.lang.String s, int radix)
          Returns a MutableByte object holding the value extracted from the specified String when parsed with the radix given by the second argument.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MutableByte

public MutableByte(byte value)
Constructs a newly allocated MutableByte object that represents the specified byte value.

Parameters:
value - the value to be represented by the MutableByte.

MutableByte

public MutableByte(java.lang.String s)
            throws java.lang.NumberFormatException
Constructs a newly allocated MutableByte object that represents the byte value indicated by the String parameter. The string is converted to a byte value in exactly the manner used by the parseByte method for radix 10.

Parameters:
s - the String to be converted to a MutableByte
Throws:
java.lang.NumberFormatException - If the String does not contain a parsable byte.
See Also:
Byte.parseByte(java.lang.String, int)
Method Detail

setValue

public final void setValue(byte value)

byteValue

public final byte byteValue()
Returns the value of this MutableByte as a byte.

Overrides:
byteValue in class java.lang.Number

shortValue

public final short shortValue()
Returns the value of this MutableByte as a short.

Overrides:
shortValue in class java.lang.Number

intValue

public final int intValue()
Returns the value of this MutableByte as an int.

Specified by:
intValue in class java.lang.Number

longValue

public final long longValue()
Returns the value of this MutableByte as a long.

Specified by:
longValue in class java.lang.Number

floatValue

public float floatValue()
Returns the value of this MutableByte as a float.

Specified by:
floatValue in class java.lang.Number

doubleValue

public double doubleValue()
Returns the value of this MutableByte as a double.

Specified by:
doubleValue in class java.lang.Number

toString

public java.lang.String toString()
Returns a String object representing this MutableByte's value. The value is converted to signed decimal representation and returned as a string, exactly as if the byte value were given as an argument to the Byte.toString(byte) method.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the value of this object in base 10.

hashCode

public int hashCode()
Returns a hash code for this MutableByte.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Compares this object to the specified object. The result is true if and only if the argument is not null and is a MutableByte object that contains the same byte value as this object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare with
Returns:
true if the objects are the same; false otherwise.

compareTo

public int compareTo(MutableByte anotherByte)
Compares two MutableByte objects numerically.

Specified by:
compareTo in interface java.lang.Comparable<MutableByte>
Parameters:
anotherByte - the MutableByte to be compared.
Returns:
the value 0 if this MutableByte is equal to the argument MutableByte; a value less than 0 if this MutableByte is numerically less than the argument MutableByte; and a value greater than 0 if this MutableByte is numerically greater than the argument MutableByte (signed comparison).
Since:
1.2

valueOf

public static MutableByte valueOf(byte b)
Returns a MutableByte instance representing the specified byte value. If a new MutableByte instance is not required, this method should generally be used in preference to the constructor MutableByte(byte), as this method is likely to yield significantly better space and time performance by caching frequently requested values.

Parameters:
b - a byte value.
Returns:
a MutableByte instance representing b.
Since:
1.5

valueOf

public static MutableByte valueOf(java.lang.String s,
                                  int radix)
                           throws java.lang.NumberFormatException
Returns a MutableByte object holding the value extracted from the specified String when parsed with the radix given by the second argument. The first argument is interpreted as representing a signed byte in the radix specified by the second argument, exactly as if the argument were given to the Boolean.parseBoolean(String) method. The result is a MutableByte object that represents the byte value specified by the string.

In other words, this method returns a MutableByte object equal to the value of:

new MutableByte(Byte.parseByte(s, radix))

Parameters:
s - the string to be parsed
radix - the radix to be used in interpreting s
Returns:
a MutableByte object holding the value represented by the string argument in the specified radix.
Throws:
java.lang.NumberFormatException - If the String does not contain a parsable byte.

valueOf

public static MutableByte valueOf(java.lang.String s)
                           throws java.lang.NumberFormatException
Returns a MutableByte object holding the value given by the specified String. The argument is interpreted as representing a signed decimal byte, exactly as if the argument were given to the Boolean.parseBoolean(String) method. The result is a MutableByte object that represents the byte value specified by the string.

In other words, this method returns a MutableByte object equal to the value of:

new MutableByte(Byte.parseByte(s))

Parameters:
s - the string to be parsed
Returns:
a MutableByte object holding the value represented by the string argument
Throws:
java.lang.NumberFormatException - If the String does not contain a parsable byte.