Package org.apache.qpid.protonj2.types
Class UnsignedByte
- java.lang.Object
-
- java.lang.Number
-
- org.apache.qpid.protonj2.types.UnsignedByte
-
- All Implemented Interfaces:
Serializable,Comparable<UnsignedByte>
public final class UnsignedByte extends Number implements Comparable<UnsignedByte>
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description UnsignedByte(byte underlying)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description bytebyteValue()static intcompare(byte left, byte right)Compares two short values numerically treating the values as unsigned.intcompareTo(byte value)Compares the give byte value to this unsigned byte numerically treating the given value as unsigned.intcompareTo(UnsignedByte o)doubledoubleValue()booleanequals(Object o)floatfloatValue()inthashCode()intintValue()longlongValue()shortshortValue()StringtoString()static inttoUnsignedInt(byte value)Returns aintthat represents the unsigned view of the givenbytevalue.static longtoUnsignedLong(byte value)Returns alongthat represents the unsigned view of the givenbytevalue.static shorttoUnsignedShort(byte value)Returns ashortthat represents the unsigned view of the givenbytevalue.static UnsignedBytevalueOf(byte value)Returns an UnsignedByte instance representing the specified byte value.static UnsignedBytevalueOf(String value)Returns anUnsignedByteinstance representing the specifiedStringvalue.
-
-
-
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(byte value)
Compares the give byte value to this unsigned byte numerically treating the given value as unsigned.- Parameters:
value- the byte to compare to this unsigned byte 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(UnsignedByte o)
- Specified by:
compareToin interfaceComparable<UnsignedByte>
-
compare
public static int compare(byte left, byte 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 UnsignedByte valueOf(byte value)
Returns an UnsignedByte instance representing the specified byte value. This method always returns a cachedUnsignedByteinstance for values in the range [0...255] which can save space and time over calling the constructorUnsignedByte(byte)which will always create a new instance of theUnsignedBytetype.- Parameters:
value- The byte value to return as anUnsignedByteinstance.- Returns:
- an
UnsignedByteinstance representing the unsigned view of the given byte.
-
valueOf
public static UnsignedByte valueOf(String value) throws NumberFormatException
Returns anUnsignedByteinstance representing the specifiedStringvalue. This method always returns a cachedUnsignedByteinstance for values in the range [0...255] which can save space and time over calling the constructorUnsignedByte(byte)which will always create a new instance of theUnsignedBytetype.- Parameters:
value- The byte value to return as anUnsignedByteinstance.- Returns:
- an
UnsignedByteinstance representing the unsigned view of the given byte. - Throws:
NumberFormatException- if the givenStringvalue given cannot be converted to a numeric value.
-
toUnsignedShort
public static short toUnsignedShort(byte value)
Returns ashortthat represents the unsigned view of the givenbytevalue.- Parameters:
value- Theshortwhose unsigned value should be converted to a long.- Returns:
- a positive
shortvalue that represents the givenbyteas unsigned.
-
toUnsignedInt
public static int toUnsignedInt(byte value)
Returns aintthat represents the unsigned view of the givenbytevalue.- Parameters:
value- Theintwhose unsigned value should be converted to a long.- Returns:
- a positive
intvalue that represents the givenshortas unsigned.
-
toUnsignedLong
public static long toUnsignedLong(byte value)
Returns alongthat represents the unsigned view of the givenbytevalue.- Parameters:
value- Thelongwhose unsigned value should be converted to a long.- Returns:
- a positive
longvalue that represents the givenbyteas unsigned.
-
-