Package org.joou

Class UInteger

All Implemented Interfaces:
Serializable, Comparable<UInteger>

public final class UInteger extends UNumber implements Comparable<UInteger>
The unsigned int type
See Also:
  • Field Details

    • CLASS

      private static final Class<UInteger> CLASS
    • CLASS_NAME

      private static final String CLASS_NAME
    • PRECACHE_PROPERTY

      private static final String 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_SIZE
      Default size for the value cache.
      See Also:
    • serialVersionUID

      private static final long serialVersionUID
      Generated UID
      See Also:
    • VALUES

      private static final UInteger[] VALUES
      Cached values
    • MIN_VALUE

      public static final long MIN_VALUE
      A constant holding the minimum value an unsigned int can have, 0.
      See Also:
    • MAX_VALUE

      public static final long MAX_VALUE
      A constant holding the maximum value an unsigned int can have, 232-1.
      See Also:
    • MIN

      public static final UInteger MIN
      A constant holding the minimum value an unsigned int can have as UInteger, 0.
    • MAX

      public static final UInteger MAX
      A constant holding the maximum value an unsigned int can have as UInteger, 232-1.
    • value

      private final long value
      The value modelling the content of this unsigned int
  • Constructor Details

    • UInteger

      private UInteger(long value, boolean unused)
      Unchecked internal constructor. This serves two purposes: first it allows UInteger(long) to stay deprecated without warnings and second constructor without unnecessary value checks.
      Parameters:
      value - The value to wrap
      unused - Unused parameter to distinguish between this and the deprecated public constructor.
    • UInteger

      private UInteger(long value) throws NumberFormatException
      Create an unsigned int
      Throws:
      NumberFormatException - If value is not in the range of an unsigned int
    • UInteger

      private UInteger(int value)
      Create an unsigned int by masking it with 0xFFFFFFFF i.e. (int) -1 becomes (uint) 4294967295
    • UInteger

      private UInteger(String value) throws NumberFormatException
      Create an unsigned int
      Throws:
      NumberFormatException - If value does not contain a parsable unsigned 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_PROPERTY or DEFAULT_PRECACHE_SIZE if the property is not set, not a number or retrieving results in a SecurityException. If the parsed value is zero or negative no cache will be created. If the value is larger than Integer.MAX_VALUE then Integer#MAX_VALUE will be used.
    • mkValues

      private static final UInteger[] mkValues()
      Generate a cached value for initial unsigned integer values.
      Returns:
      Array of cached values for UInteger
    • getCached

      private static UInteger getCached(long value)
      Retrieve a cached value.
      Parameters:
      value - Cached value to retrieve
      Returns:
      Cached value if one exists. Null otherwise.
    • valueOfUnchecked

      private static UInteger valueOfUnchecked(long value)
      Get the value of a long without checking the value.
    • valueOf

      public static UInteger valueOf(String value) throws NumberFormatException
      Create an unsigned int
      Throws:
      NumberFormatException - If value does not contain a parsable unsigned int.
    • valueOf

      public static UInteger valueOf(int value)
      Create an unsigned int by masking it with 0xFFFFFFFF i.e. (int) -1 becomes (uint) 4294967295
    • valueOf

      public static UInteger valueOf(long value) throws NumberFormatException
      Create an unsigned int
      Throws:
      NumberFormatException - If value is not in the range of an unsigned byte
    • rangeCheck

      private static long rangeCheck(long value) throws NumberFormatException
      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

      private Object readResolve() throws ObjectStreamException
      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

      public int intValue()
      Specified by:
      intValue in class Number
    • longValue

      public long longValue()
      Specified by:
      longValue in class Number
    • floatValue

      public float floatValue()
      Specified by:
      floatValue in class Number
    • doubleValue

      public double doubleValue()
      Specified by:
      doubleValue in class Number
    • toBigInteger

      public BigInteger toBigInteger()
      Description copied from class: UNumber
      Get this number as a BigInteger. This is a convenience method for calling new BigInteger(toString())
      Overrides:
      toBigInteger in class UNumber
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(UInteger o)
      Specified by:
      compareTo in interface Comparable<UInteger>
    • add

      public UInteger add(UInteger val)
    • add

      public UInteger add(int val)
    • subtract

      public UInteger subtract(UInteger val)
    • subtract

      public UInteger subtract(int val)