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>
public final class UnsignedShort extends Number implements Comparable<UnsignedShort>
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static UnsignedShortMAX_VALUE
-
Constructor Summary
Constructors Constructor Description UnsignedShort(short underlying)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intcompare(short left, short right)Compares two short values numerically treating the values as unsigned.intcompareTo(short value)Compares the give short value to this unsigned short numerically treating the given value as unsigned.intcompareTo(UnsignedShort value)doubledoubleValue()booleanequals(Object o)floatfloatValue()inthashCode()intintValue()longlongValue()shortshortValue()StringtoString()static inttoUnsignedInt(short value)Returns aintthat represents the unsigned view of the givenshortvalue.static longtoUnsignedLong(short value)Returns alongthat represents the unsigned view of the givenshortvalue.static UnsignedShortvalueOf(int value)Returns an UnsignedShort instance representing the specified int value.static UnsignedShortvalueOf(short value)Returns an UnsignedShort instance representing the specified short value.static UnsignedShortvalueOf(String value)Returns an UnsignedShort instance representing the specifiedStringvalue.
-
-
-
Field Detail
-
MAX_VALUE
public static final UnsignedShort MAX_VALUE
-
-
Method Detail
-
shortValue
public short shortValue()
- Overrides:
shortValuein classNumber
-
floatValue
public float floatValue()
- Specified by:
floatValuein classNumber
-
doubleValue
public double doubleValue()
- Specified by:
doubleValuein classNumber
-
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:
compareToin 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
-
valueOf
public static UnsignedShort valueOf(short value)
Returns an UnsignedShort instance representing the specified short value. This method always returns a cachedUnsignedShortinstance 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 theUnsignedShorttype.- Parameters:
value- The short value to return as anUnsignedShortinstance.- Returns:
- an
UnsignedShortinstance 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 cachedUnsignedShortinstance 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 theUnsignedShorttype.- Parameters:
value- The short value to return as anUnsignedShortinstance.- Returns:
- an
UnsignedShortinstance representing the unsigned view of the given short. - Throws:
NumberFormatException- if the given value is greater than the maxUnsignedShortvalue possible.
-
valueOf
public static UnsignedShort valueOf(String value)
Returns an UnsignedShort instance representing the specifiedStringvalue. This method always returns a cachedUnsignedShortinstance 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 theUnsignedShorttype.- Parameters:
value- The String value to return as anUnsignedShortinstance.- Returns:
- an
UnsignedShortinstance representing the unsigned view of the given String. - Throws:
NumberFormatException- if the given value is greater than the maxUnsignedShortvalue possible or theStringvalue given cannot be converted to a numeric value.
-
toUnsignedInt
public static int toUnsignedInt(short value)
Returns aintthat represents the unsigned view of the givenshortvalue.- Parameters:
value- The integer whose unsigned value should be converted to a long.- Returns:
- a positive long value that represents the given
shortas unsigned.
-
toUnsignedLong
public static long toUnsignedLong(short value)
Returns alongthat represents the unsigned view of the givenshortvalue.- Parameters:
value- The integer whose unsigned value should be converted to a long.- Returns:
- a positive long value that represents the given
shortas unsigned.
-
-