Class UInteger
java.lang.Object
java.lang.Number
org.joou.UNumber
org.joou.UInteger
- All Implemented Interfaces:
Serializable, Comparable<UInteger>
The
unsigned int type- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final intDefault size for the value cache.static final UIntegerA constant holding the maximum value anunsigned intcan have as UInteger, 232-1.static final longA constant holding the maximum value anunsigned intcan have, 232-1.static final UIntegerA constant holding the minimum value anunsigned intcan have as UInteger, 0.static final longA constant holding the minimum value anunsigned intcan have, 0.private static final StringSystem property name for the property to set the size of the pre-cache.private static final longGenerated UIDprivate final longThe value modelling the content of thisunsigned intprivate static final UInteger[]Cached values -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(int val) intdoublebooleanfloatprivate static UIntegergetCached(long value) Retrieve a cached value.private static final intFigure out the size of the precache.inthashCode()intintValue()longprivate static final UInteger[]mkValues()Generate a cached value for initial unsigned integer values.private static longrangeCheck(long value) Throw exception if value out of range (long version)private ObjectReplace version read through deserialization with cached version.subtract(int val) Get this number as aBigInteger.toString()static UIntegervalueOf(int value) Create anunsigned intby masking it with0xFFFFFFFFi.e.static UIntegervalueOf(long value) Create anunsigned intstatic UIntegerCreate anunsigned intprivate static UIntegervalueOfUnchecked(long value) Get the value of a long without checking the value.Methods inherited from class Number
byteValue, shortValue
-
Field Details
-
CLASS
-
CLASS_NAME
-
PRECACHE_PROPERTY
System property name for the property to set the size of the pre-cache. -
DEFAULT_PRECACHE_SIZE
private static final int DEFAULT_PRECACHE_SIZEDefault size for the value cache.- See Also:
-
serialVersionUID
private static final long serialVersionUIDGenerated UID- See Also:
-
VALUES
Cached values -
MIN_VALUE
public static final long MIN_VALUEA constant holding the minimum value anunsigned intcan have, 0.- See Also:
-
MAX_VALUE
public static final long MAX_VALUEA constant holding the maximum value anunsigned intcan have, 232-1.- See Also:
-
MIN
A constant holding the minimum value anunsigned intcan have as UInteger, 0. -
MAX
A constant holding the maximum value anunsigned intcan have as UInteger, 232-1. -
value
private final long valueThe value modelling the content of thisunsigned int
-
-
Constructor Details
-
UInteger
private UInteger(long value, boolean unused) Unchecked internal constructor. This serves two purposes: first it allowsUInteger(long)to stay deprecated without warnings and second constructor without unnecessary value checks.- Parameters:
value- The value to wrapunused- Unused parameter to distinguish between this and the deprecated public constructor.
-
UInteger
Create anunsigned int- Throws:
NumberFormatException- Ifvalueis not in the range of anunsigned int
-
UInteger
private UInteger(int value) Create anunsigned intby masking it with0xFFFFFFFFi.e.(int) -1becomes(uint) 4294967295 -
UInteger
Create anunsigned int- Throws:
NumberFormatException- Ifvaluedoes not contain a parsableunsigned int.
-
-
Method Details
-
getPrecacheSize
private static final int getPrecacheSize()Figure out the size of the precache.- Returns:
- The parsed value of the system property
PRECACHE_PROPERTYorDEFAULT_PRECACHE_SIZEif the property is not set, not a number or retrieving results in aSecurityException. If the parsed value is zero or negative no cache will be created. If the value is larger thanInteger.MAX_VALUEthen Integer#MAX_VALUE will be used.
-
mkValues
Generate a cached value for initial unsigned integer values.- Returns:
- Array of cached values for UInteger
-
getCached
Retrieve a cached value.- Parameters:
value- Cached value to retrieve- Returns:
- Cached value if one exists. Null otherwise.
-
valueOfUnchecked
Get the value of a long without checking the value. -
valueOf
Create anunsigned int- Throws:
NumberFormatException- Ifvaluedoes not contain a parsableunsigned int.
-
valueOf
Create anunsigned intby masking it with0xFFFFFFFFi.e.(int) -1becomes(uint) 4294967295 -
valueOf
Create anunsigned int- Throws:
NumberFormatException- Ifvalueis not in the range of anunsigned byte
-
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.- Returns:
- cached instance of this object's value if one exists, otherwise this object
- Throws:
ObjectStreamException
-
intValue
-
longValue
-
floatValue
public float floatValue()- Specified by:
floatValuein classNumber
-
doubleValue
public double doubleValue()- Specified by:
doubleValuein classNumber
-
toBigInteger
Description copied from class:UNumberGet this number as aBigInteger. This is a convenience method for callingnew BigInteger(toString())- Overrides:
toBigIntegerin classUNumber
-
hashCode
-
equals
-
toString
-
compareTo
- Specified by:
compareToin interfaceComparable<UInteger>
-
add
-
add
-
subtract
-
subtract
-