Class UnsignedShort

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<UnsignedShort>

    public final class UnsignedShort
    extends java.lang.Number
    implements java.lang.Comparable<UnsignedShort>
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      UnsignedShort​(short underlying)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static int compare​(short left, short right)
      Compares two short values numerically treating the values as unsigned.
      int compareTo​(short value)
      Compares the give short value to this unsigned short numerically treating the given value as unsigned.
      int compareTo​(UnsignedShort value)  
      double doubleValue()  
      boolean equals​(java.lang.Object o)  
      float floatValue()  
      int hashCode()  
      int intValue()  
      long longValue()  
      short shortValue()  
      java.lang.String toString()  
      static int toUnsignedInt​(short value)
      Returns a int that represents the unsigned view of the given short value.
      static long toUnsignedLong​(short value)
      Returns a long that represents the unsigned view of the given short value.
      static UnsignedShort valueOf​(int value)
      Returns an UnsignedShort instance representing the specified int value.
      static UnsignedShort valueOf​(short value)
      Returns an UnsignedShort instance representing the specified short value.
      static UnsignedShort valueOf​(java.lang.String value)
      Returns an UnsignedShort instance representing the specified String value.
      • Methods inherited from class java.lang.Number

        byteValue
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • UnsignedShort

        public UnsignedShort​(short underlying)
    • Method Detail

      • shortValue

        public short shortValue()
        Overrides:
        shortValue 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
      • floatValue

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

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

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • compareTo

        public int compareTo​(short value)
        Compares the give short value to this unsigned short numerically treating the given value as unsigned.
        Parameters:
        value - the short to compare to this unsigned short instance.
        Returns:
        the value 0 if this == value; a value less than 0 if this < value as unsigned values; and a value greater than 0 if this > value as unsigned values
      • compareTo

        public int compareTo​(UnsignedShort value)
        Specified by:
        compareTo in interface java.lang.Comparable<UnsignedShort>
      • compare

        public static int compare​(short left,
                                  short right)
        Compares two short values numerically treating the values as unsigned.
        Parameters:
        left - the left hand side short to compare
        right - the right hand side short to compare
        Returns:
        the value 0 if left == right; a value less than 0 if left < right as unsigned values; and a value greater than 0 if left > right as unsigned values
      • hashCode

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

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

        public static UnsignedShort valueOf​(short value)
        Returns an UnsignedShort instance representing the specified short value. This method always returns a cached UnsignedShort instance for values in the range [0...255] which can save space and time over calling the constructor UnsignedShort(short) which will always create a new instance of the UnsignedShort type.
        Parameters:
        value - The short value to return as an UnsignedShort instance.
        Returns:
        an UnsignedShort instance representing the unsigned view of the given short.
      • valueOf

        public static UnsignedShort valueOf​(int value)
        Returns an UnsignedShort instance representing the specified int value. This method always returns a cached UnsignedShort instance for values in the range [0...255] which can save space and time over calling the constructor UnsignedShort(short) which will always create a new instance of the UnsignedShort type.
        Parameters:
        value - The short value to return as an UnsignedShort instance.
        Returns:
        an UnsignedShort instance representing the unsigned view of the given short.
        Throws:
        java.lang.NumberFormatException - if the given value is greater than the max UnsignedShort value possible.
      • valueOf

        public static UnsignedShort valueOf​(java.lang.String value)
        Returns an UnsignedShort instance representing the specified String value. This method always returns a cached UnsignedShort instance for values in the range [0...255] which can save space and time over calling the constructor UnsignedShort(short) which will always create a new instance of the UnsignedShort type.
        Parameters:
        value - The String value to return as an UnsignedShort instance.
        Returns:
        an UnsignedShort instance representing the unsigned view of the given String.
        Throws:
        java.lang.NumberFormatException - if the given value is greater than the max UnsignedShort value possible or the String value given cannot be converted to a numeric value.
      • toUnsignedInt

        public static int toUnsignedInt​(short value)
        Returns a int that represents the unsigned view of the given short value.
        Parameters:
        value - The integer whose unsigned value should be converted to a long.
        Returns:
        a positive long value that represents the given short as unsigned.
      • toUnsignedLong

        public static long toUnsignedLong​(short value)
        Returns a long that represents the unsigned view of the given short value.
        Parameters:
        value - The integer whose unsigned value should be converted to a long.
        Returns:
        a positive long value that represents the given short as unsigned.