java.lang.Object
java.lang.Number
org.joou.UNumber
org.joou.UByte
- All Implemented Interfaces:
Serializable
,Comparable<UByte>
The
unsigned byte
type- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final UByte
A constant holding the maximum value anunsigned byte
can have as UByte, 28-1.static final short
A constant holding the maximum value anunsigned byte
can have, 28-1.static final UByte
A constant holding the minimum value anunsigned byte
can have as UByte, 0.static final short
A constant holding the minimum value anunsigned byte
can have, 0.private static final long
Generated UIDprivate final short
The value modelling the content of thisunsigned byte
private static final UByte[]
Cached values -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(int val) int
double
boolean
float
int
hashCode()
int
intValue()
long
private static final UByte[]
mkValues()
Generate a cached value for each byte value.private static short
rangeCheck
(int value) Throw exception if value out of range (int version)private static short
rangeCheck
(long value) Throw exception if value out of range (long version)private static short
rangeCheck
(short value) Throw exception if value out of range (short version)private Object
Replace version read through deserialization with cached version.subtract
(int val) Get this number as aBigInteger
.toString()
static UByte
valueOf
(byte value) Get an instance of anunsigned byte
by masking it with0xFF
i.e.static UByte
valueOf
(int value) Get an instance of anunsigned byte
static UByte
valueOf
(long value) Get an instance of anunsigned byte
static UByte
valueOf
(short value) Get an instance of anunsigned byte
static UByte
Get an instance of anunsigned byte
private static UByte
valueOfUnchecked
(short value) Get the value of a short without checking the value.Methods inherited from class java.lang.Number
byteValue, shortValue
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDGenerated UID- See Also:
-
VALUES
Cached values -
MIN_VALUE
public static final short MIN_VALUEA constant holding the minimum value anunsigned byte
can have, 0.- See Also:
-
MAX_VALUE
public static final short MAX_VALUEA constant holding the maximum value anunsigned byte
can have, 28-1.- See Also:
-
MIN
A constant holding the minimum value anunsigned byte
can have as UByte, 0. -
MAX
A constant holding the maximum value anunsigned byte
can have as UByte, 28-1. -
value
private final short valueThe value modelling the content of thisunsigned byte
-
-
Constructor Details
-
UByte
Create anunsigned byte
- Throws:
NumberFormatException
- Ifvalue
is not in the range of anunsigned byte
-
UByte
Create anunsigned byte
- Throws:
NumberFormatException
- Ifvalue
is not in the range of anunsigned byte
-
UByte
Create anunsigned byte
- Throws:
NumberFormatException
- Ifvalue
is not in the range of anunsigned byte
-
UByte
private UByte(byte value) Create anunsigned byte
by masking it with0xFF
i.e.(byte) -1
becomes(ubyte) 255
-
UByte
Create anunsigned byte
- Throws:
NumberFormatException
- Ifvalue
does not contain a parsableunsigned byte
.
-
-
Method Details
-
mkValues
Generate a cached value for each byte value.- Returns:
- Array of cached values for UByte.
-
valueOf
Get an instance of anunsigned byte
- Throws:
NumberFormatException
- Ifvalue
does not contain a parsableunsigned byte
.
-
valueOf
Get an instance of anunsigned byte
by masking it with0xFF
i.e.(byte) -1
becomes(ubyte) 255
-
valueOfUnchecked
Get the value of a short without checking the value.- Throws:
NumberFormatException
-
valueOf
Get an instance of anunsigned byte
- Throws:
NumberFormatException
- Ifvalue
is not in the range of anunsigned byte
-
valueOf
Get an instance of anunsigned byte
- Throws:
NumberFormatException
- Ifvalue
is not in the range of anunsigned byte
-
valueOf
Get an instance of anunsigned byte
- Throws:
NumberFormatException
- Ifvalue
is not in the range of anunsigned byte
-
rangeCheck
Throw exception if value out of range (short version)- Parameters:
value
- Value to check- Returns:
- value if it is in range
- Throws:
NumberFormatException
- if value is out of range
-
rangeCheck
Throw exception if value out of range (int version)- Parameters:
value
- Value to check- Returns:
- value if it is in range
- Throws:
NumberFormatException
- if value is out of range
-
rangeCheck
Throw exception if value out of range (long version)- Parameters:
value
- Value to check- Returns:
- value if it is in range
- Throws:
NumberFormatException
- if value is out of range
-
readResolve
Replace version read through deserialization with cached version. Note that this does not use thevalueOfUnchecked(short)
as we have no guarantee that the value from the stream is valid.- Returns:
- cached instance of this object's value
- Throws:
ObjectStreamException
-
intValue
public int intValue() -
longValue
public long longValue() -
floatValue
public float floatValue()- Specified by:
floatValue
in classNumber
-
doubleValue
public double doubleValue()- Specified by:
doubleValue
in classNumber
-
hashCode
public int hashCode() -
equals
-
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<UByte>
-
toBigInteger
Description copied from class:UNumber
Get this number as aBigInteger
. This is a convenience method for callingnew BigInteger(toString())
- Overrides:
toBigInteger
in classUNumber
-
add
- Throws:
NumberFormatException
-
add
- Throws:
NumberFormatException
-
subtract
-
subtract
-