edu.neu.ccs
Class XByte

java.lang.Object
  extended byedu.neu.ccs.XObject
      extended byedu.neu.ccs.XNumber
          extended byedu.neu.ccs.XByte
All Implemented Interfaces:
Cloneable, Serializable, Stringable
Direct Known Subclasses:
HexXByte

public class XByte
extends XNumber

Object wrapper for the primitive byte type that also provides Stringable capabilities. The default value for this class is the byte representation of zero.

Since:
1.0
Version:
2.2
See Also:
Serialized Form

Field Summary
private  byte value
          The wrapped value of this object.
 
Fields inherited from class edu.neu.ccs.XObject
changeAdapter, VALUE
 
Constructor Summary
XByte()
          Constructs a wrapper for the default byte value.
XByte(byte b)
          Constructs a wrapper for the given byte value.
XByte(String s)
          Constructs a wrapper for the byte value whose state information is encapsulated in the given String data.
 
Method Summary
 byte byteValue()
          Returns the value of this number as a byte value.
 double doubleValue()
          Returns the value of this number as a double value.
 boolean equals(Object other)
          Returns true if the wrapped object is equal to the given object, and false if it is not.
 float floatValue()
          Returns the value of this number as a float value.
 void fromStringData(String data)
          Sets the state of this object using information contained in the given String.
 byte getValue()
          Returns the value wrapped by this object.
 int hashCode()
          Returns an int hash code appropriate for the wrapped object.
 int intValue()
          Returns the value of this number as a int value.
 long longValue()
          Returns the value of this number as a long value.
static byte parseByte(String s)
          Parses a byte value from a String using the current shared parser.
 void setValue(byte b)
          Sets the value wrapped by this object to the provided value.
 short shortValue()
          Returns the value of this number as a short value.
static byte[] toPrimitiveArray(XByte[] x)
          Returns an array of primitive byte values copied from the given array of XByte objects.
 String toString()
          Returns a String representation of the wrapped value.
 String toStringData()
          Returns a String encapsulation of this object that contains information needed to set the state of this object at a later time.
static XByte[] toXArray(byte[] a)
          Returns an array of XByte objects initialized from the given array of byte values.
 
Methods inherited from class edu.neu.ccs.XObject
addPropertyChangeListener, addPropertyChangeListener, formatErrorMessage, removePropertyChangeListener, removePropertyChangeListener, toStringArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

value

private byte value
The wrapped value of this object.

Constructor Detail

XByte

public XByte()
Constructs a wrapper for the default byte value.

See Also:
XByte(byte), XByte(String)

XByte

public XByte(byte b)
Constructs a wrapper for the given byte value.

Parameters:
b - the value to be wrapped
See Also:
XByte(), XByte(String)

XByte

public XByte(String s)
      throws ParseException
Constructs a wrapper for the byte value whose state information is encapsulated in the given String data.

Parameters:
s - a String representation of the desired value
Throws:
ParseException - if the data is malformed
See Also:
XByte(), XByte(byte)
Method Detail

fromStringData

public void fromStringData(String data)
                    throws ParseException
Description copied from interface: Stringable
Sets the state of this object using information contained in the given String.

Specified by:
fromStringData in interface Stringable
Specified by:
fromStringData in class XObject
Throws:
ParseException

toStringData

public String toStringData()
Description copied from interface: Stringable
Returns a String encapsulation of this object that contains information needed to set the state of this object at a later time.

Specified by:
toStringData in interface Stringable
Specified by:
toStringData in class XObject

equals

public boolean equals(Object other)
Returns true if the wrapped object is equal to the given object, and false if it is not.

Parameters:
other - the object to be compared with the wrapped object

hashCode

public int hashCode()
Returns an int hash code appropriate for the wrapped object.


toString

public String toString()
Returns a String representation of the wrapped value.


setValue

public void setValue(byte b)
Sets the value wrapped by this object to the provided value.

Parameters:
b - the value to be wrapped
See Also:
getValue()

getValue

public byte getValue()
Returns the value wrapped by this object.

See Also:
setValue(byte)

byteValue

public byte byteValue()
Description copied from class: XNumber
Returns the value of this number as a byte value.

Specified by:
byteValue in class XNumber

shortValue

public short shortValue()
Description copied from class: XNumber
Returns the value of this number as a short value.

Specified by:
shortValue in class XNumber

intValue

public int intValue()
Description copied from class: XNumber
Returns the value of this number as a int value.

Specified by:
intValue in class XNumber

longValue

public long longValue()
Description copied from class: XNumber
Returns the value of this number as a long value.

Specified by:
longValue in class XNumber

floatValue

public float floatValue()
Description copied from class: XNumber
Returns the value of this number as a float value.

Specified by:
floatValue in class XNumber

doubleValue

public double doubleValue()
Description copied from class: XNumber
Returns the value of this number as a double value.

Specified by:
doubleValue in class XNumber

parseByte

public static byte parseByte(String s)
                      throws NumberFormatException
Parses a byte value from a String using the current shared parser.

Parameters:
s - the String data to parse
Returns:
the extracted byte value
Throws:
NumberFormatException - if the data is malformed

toPrimitiveArray

public static byte[] toPrimitiveArray(XByte[] x)
Returns an array of primitive byte values copied from the given array of XByte objects.

Parameters:
x - an array of XBytes
Returns:
the resulting array of byte values
See Also:
toXArray(byte[])

toXArray

public static XByte[] toXArray(byte[] a)
Returns an array of XByte objects initialized from the given array of byte values.

Parameters:
a - an array of bytes
Returns:
the resulting array of XByte objects
See Also:
toPrimitiveArray(XByte[])