Package org.apache.qpid.protonj2.types
Class UnsignedShort
java.lang.Object
java.lang.Number
org.apache.qpid.protonj2.types.UnsignedShort
- All Implemented Interfaces:
Serializable
,Comparable<UnsignedShort>
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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
boolean
float
int
hashCode()
int
intValue()
long
short
toString()
static int
toUnsignedInt
(short value) Returns aint
that represents the unsigned view of the givenshort
value.static long
toUnsignedLong
(short value) Returns along
that represents the unsigned view of the givenshort
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
Returns an UnsignedShort instance representing the specifiedString
value.
-
Field Details
-
MAX_VALUE
-
-
Constructor Details
-
UnsignedShort
public UnsignedShort(short underlying)
-
-
Method Details
-
shortValue
public short shortValue()- Overrides:
shortValue
in classNumber
-
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
-
equals
-
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
- Specified by:
compareTo
in interfaceComparable<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 compareright
- 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() -
toString
-
valueOf
Returns an UnsignedShort instance representing the specified short value. This method always returns a cachedUnsignedShort
instance for values in the range [0...255] which can save space and time over calling the constructorUnsignedShort(short)
which will always create a new instance of theUnsignedShort
type.- Parameters:
value
- The short value to return as anUnsignedShort
instance.- Returns:
- an
UnsignedShort
instance representing the unsigned view of the given short.
-
valueOf
Returns an UnsignedShort instance representing the specified int value. This method always returns a cachedUnsignedShort
instance for values in the range [0...255] which can save space and time over calling the constructorUnsignedShort(short)
which will always create a new instance of theUnsignedShort
type.- Parameters:
value
- The short value to return as anUnsignedShort
instance.- Returns:
- an
UnsignedShort
instance representing the unsigned view of the given short. - Throws:
NumberFormatException
- if the given value is greater than the maxUnsignedShort
value possible.
-
valueOf
Returns an UnsignedShort instance representing the specifiedString
value. This method always returns a cachedUnsignedShort
instance for values in the range [0...255] which can save space and time over calling the constructorUnsignedShort(short)
which will always create a new instance of theUnsignedShort
type.- Parameters:
value
- The String value to return as anUnsignedShort
instance.- Returns:
- an
UnsignedShort
instance representing the unsigned view of the given String. - Throws:
NumberFormatException
- if the given value is greater than the maxUnsignedShort
value possible or theString
value given cannot be converted to a numeric value.
-
toUnsignedInt
public static int toUnsignedInt(short value) Returns aint
that represents the unsigned view of the givenshort
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 along
that represents the unsigned view of the givenshort
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.
-