- java.lang.Object
-
- java.lang.Number
-
- org.joou.UNumber
-
- org.joou.UByte
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<UByte>
public final class UByte extends UNumber implements java.lang.Comparable<UByte>
Theunsigned bytetype- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static UByteMAXA constant holding the maximum value anunsigned bytecan have as UByte, 28-1.static shortMAX_VALUEA constant holding the maximum value anunsigned bytecan have, 28-1.static UByteMINA constant holding the minimum value anunsigned bytecan have as UByte, 0.static shortMIN_VALUEA constant holding the minimum value anunsigned bytecan have, 0.private static longserialVersionUIDGenerated UIDprivate shortvalueThe value modelling the content of thisunsigned byteprivate static UByte[]VALUESCached values
-
Constructor Summary
Constructors Modifier Constructor Description privateUByte(byte value)Create anunsigned byteby masking it with0xFFi.e.privateUByte(int value)Create anunsigned byteprivateUByte(long value)Create anunsigned byteprivateUByte(short value)Create anunsigned byteprivateUByte(java.lang.String value)Create anunsigned byte
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description UByteadd(int val)UByteadd(UByte val)intcompareTo(UByte o)doubledoubleValue()booleanequals(java.lang.Object obj)floatfloatValue()inthashCode()intintValue()longlongValue()private static UByte[]mkValues()Generate a cached value for each byte value.private static shortrangeCheck(int value)Throw exception if value out of range (int version)private static shortrangeCheck(long value)Throw exception if value out of range (long version)private static shortrangeCheck(short value)Throw exception if value out of range (short version)private java.lang.ObjectreadResolve()Replace version read through deserialization with cached version.UBytesubtract(int val)UBytesubtract(UByte val)java.math.BigIntegertoBigInteger()Get this number as aBigInteger.java.lang.StringtoString()static UBytevalueOf(byte value)Get an instance of anunsigned byteby masking it with0xFFi.e.static UBytevalueOf(int value)Get an instance of anunsigned bytestatic UBytevalueOf(long value)Get an instance of anunsigned bytestatic UBytevalueOf(short value)Get an instance of anunsigned bytestatic UBytevalueOf(java.lang.String value)Get an instance of anunsigned byteprivate static UBytevalueOfUnchecked(short value)Get the value of a short without checking the value.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Generated UID- See Also:
- Constant Field Values
-
VALUES
private static final UByte[] VALUES
Cached values
-
MIN_VALUE
public static final short MIN_VALUE
A constant holding the minimum value anunsigned bytecan have, 0.- See Also:
- Constant Field Values
-
MAX_VALUE
public static final short MAX_VALUE
A constant holding the maximum value anunsigned bytecan have, 28-1.- See Also:
- Constant Field Values
-
MIN
public static final UByte MIN
A constant holding the minimum value anunsigned bytecan have as UByte, 0.
-
MAX
public static final UByte MAX
A constant holding the maximum value anunsigned bytecan have as UByte, 28-1.
-
value
private final short value
The value modelling the content of thisunsigned byte
-
-
Constructor Detail
-
UByte
private UByte(long value) throws java.lang.NumberFormatExceptionCreate anunsigned byte- Throws:
java.lang.NumberFormatException- Ifvalueis not in the range of anunsigned byte
-
UByte
private UByte(int value) throws java.lang.NumberFormatExceptionCreate anunsigned byte- Throws:
java.lang.NumberFormatException- Ifvalueis not in the range of anunsigned byte
-
UByte
private UByte(short value) throws java.lang.NumberFormatExceptionCreate anunsigned byte- Throws:
java.lang.NumberFormatException- Ifvalueis not in the range of anunsigned byte
-
UByte
private UByte(byte value)
Create anunsigned byteby masking it with0xFFi.e.(byte) -1becomes(ubyte) 255
-
UByte
private UByte(java.lang.String value) throws java.lang.NumberFormatExceptionCreate anunsigned byte- Throws:
java.lang.NumberFormatException- Ifvaluedoes not contain a parsableunsigned byte.
-
-
Method Detail
-
mkValues
private static final UByte[] mkValues()
Generate a cached value for each byte value.- Returns:
- Array of cached values for UByte.
-
valueOf
public static UByte valueOf(java.lang.String value) throws java.lang.NumberFormatException
Get an instance of anunsigned byte- Throws:
java.lang.NumberFormatException- Ifvaluedoes not contain a parsableunsigned byte.
-
valueOf
public static UByte valueOf(byte value)
Get an instance of anunsigned byteby masking it with0xFFi.e.(byte) -1becomes(ubyte) 255
-
valueOfUnchecked
private static UByte valueOfUnchecked(short value) throws java.lang.NumberFormatException
Get the value of a short without checking the value.- Throws:
java.lang.NumberFormatException
-
valueOf
public static UByte valueOf(short value) throws java.lang.NumberFormatException
Get an instance of anunsigned byte- Throws:
java.lang.NumberFormatException- Ifvalueis not in the range of anunsigned byte
-
valueOf
public static UByte valueOf(int value) throws java.lang.NumberFormatException
Get an instance of anunsigned byte- Throws:
java.lang.NumberFormatException- Ifvalueis not in the range of anunsigned byte
-
valueOf
public static UByte valueOf(long value) throws java.lang.NumberFormatException
Get an instance of anunsigned byte- Throws:
java.lang.NumberFormatException- Ifvalueis not in the range of anunsigned byte
-
rangeCheck
private static short rangeCheck(short value) throws java.lang.NumberFormatExceptionThrow exception if value out of range (short version)- Parameters:
value- Value to check- Returns:
- value if it is in range
- Throws:
java.lang.NumberFormatException- if value is out of range
-
rangeCheck
private static short rangeCheck(int value) throws java.lang.NumberFormatExceptionThrow exception if value out of range (int version)- Parameters:
value- Value to check- Returns:
- value if it is in range
- Throws:
java.lang.NumberFormatException- if value is out of range
-
rangeCheck
private static short rangeCheck(long value) throws java.lang.NumberFormatExceptionThrow exception if value out of range (long version)- Parameters:
value- Value to check- Returns:
- value if it is in range
- Throws:
java.lang.NumberFormatException- if value is out of range
-
readResolve
private java.lang.Object readResolve() throws java.io.ObjectStreamExceptionReplace 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:
java.io.ObjectStreamException
-
intValue
public int intValue()
- Specified by:
intValuein classjava.lang.Number
-
longValue
public long longValue()
- Specified by:
longValuein classjava.lang.Number
-
floatValue
public float floatValue()
- Specified by:
floatValuein classjava.lang.Number
-
doubleValue
public double doubleValue()
- Specified by:
doubleValuein classjava.lang.Number
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
compareTo
public int compareTo(UByte o)
- Specified by:
compareToin interfacejava.lang.Comparable<UByte>
-
toBigInteger
public java.math.BigInteger toBigInteger()
Description copied from class:UNumberGet this number as aBigInteger. This is a convenience method for callingnew BigInteger(toString())- Overrides:
toBigIntegerin classUNumber
-
add
public UByte add(UByte val) throws java.lang.NumberFormatException
- Throws:
java.lang.NumberFormatException
-
add
public UByte add(int val) throws java.lang.NumberFormatException
- Throws:
java.lang.NumberFormatException
-
subtract
public UByte subtract(int val)
-
-