net.ajaest.lib.data
Class UByte

java.lang.Object
  extended by java.lang.Number
      extended by net.ajaest.lib.data.UByte
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<UByte>

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

The UByte class wraps a value of primitive type byte in an object and provides several methods to manipulate it as unsigned byte number. The use of this class is preferred for storing purposes.

Author:
Luis Alfonso Arce González
See Also:
Number, Byte, Serialized Form

Field Summary
static UByte MAX_VALUE
           
static UByte MIN_VALUE
           
private static long serialVersionUID
           
private  byte value
           
 
Constructor Summary
UByte(byte b)
           
UByte(int ui)
           
UByte(java.lang.String s)
           
 
Method Summary
 UByte add(UByte val)
          Returns a UByte whose value is (this + val).
 byte byteValue()
           
 int compareTo(UByte o)
           
 UByte divide(UByte val)
          Returns a UByte whose value is (this / val).
 double doubleValue()
           
 boolean equals(java.lang.Object obj)
           
 float floatValue()
           
 UByte gcd(UByte val)
          Returns a UByte whose value is the greatest common divisor of abs(this) and abs(val).
 int hashCode()
           
 int intValue()
           
 long longValue()
           
 UByte mod(UByte m)
          Returns a UByte whose value is (this mod m).
 UByte multiply(UByte val)
          Returns a UByte whose value is (this * val).
 UByte pow(int exponent)
          Returns a UByte whose value is (thisexponent).
 UByte square()
          Returns a UByte whose value is (this<sup>2</sup>).
 UByte subtract(UByte val)
          Returns a UByte whose value is abs(this - val).
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Number
shortValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

value

private byte value

MIN_VALUE

public static final UByte MIN_VALUE

MAX_VALUE

public static final UByte MAX_VALUE
Constructor Detail

UByte

public UByte(byte b)

UByte

public UByte(int ui)

UByte

public UByte(java.lang.String s)
Method Detail

add

public UByte add(UByte val)
Returns a UByte whose value is (this + val).

Parameters:
val - value to be added to this UByte.
Returns:
this + val

subtract

public UByte subtract(UByte val)
Returns a UByte whose value is abs(this - val).

Parameters:
val - value to be subtracted from this UByte.
Returns:
this - val

multiply

public UByte multiply(UByte val)
Returns a UByte whose value is (this * val).

Parameters:
val - value to be multiplied by this UByte.
Returns:
this * val

square

public UByte square()
Returns a UByte whose value is (this<sup>2</sup>).

Returns:
this<sup>2</sup>

divide

public UByte divide(UByte val)
Returns a UByte whose value is (this / val).

Parameters:
val - value by which this UByte is to be divided.
Returns:
this / val
Throws:
java.lang.ArithmeticException - val==0

mod

public UByte mod(UByte m)
Returns a UByte whose value is (this mod m).

Parameters:
m - the modulus.
Returns:
this mod m

pow

public UByte pow(int exponent)
Returns a UByte whose value is (thisexponent). Note that exponent is an integer rather than a UByte.

Parameters:
exponent - exponent to which this UByte is to be raised.
Returns:
thisexponent
Throws:
java.lang.ArithmeticException - exponent is negative. (This would cause the operation to yield a non-integer value.)

gcd

public UByte gcd(UByte val)
Returns a UByte whose value is the greatest common divisor of abs(this) and abs(val). Returns 0 if val==0.

Parameters:
val - value with which the GCD is to be computed.
Returns:
GCD(this, val)

byteValue

public byte byteValue()
Overrides:
byteValue in class java.lang.Number

doubleValue

public double doubleValue()
Specified by:
doubleValue in class java.lang.Number

floatValue

public float floatValue()
Specified by:
floatValue in class java.lang.Number

intValue

public int intValue()
Specified by:
intValue in class java.lang.Number

longValue

public long longValue()
Specified by:
longValue in class java.lang.Number

compareTo

public int compareTo(UByte o)
Specified by:
compareTo in interface java.lang.Comparable<UByte>

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object