Package org.apache.qpid.protonj2.types
Class UnsignedByte
- java.lang.Object
-
- java.lang.Number
-
- org.apache.qpid.protonj2.types.UnsignedByte
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<UnsignedByte>
public final class UnsignedByte extends java.lang.Number implements java.lang.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 byte
byteValue()
static int
compare(byte left, byte right)
Compares two short values numerically treating the values as unsigned.int
compareTo(byte value)
Compares the give byte value to this unsigned byte numerically treating the given value as unsigned.int
compareTo(UnsignedByte o)
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(byte value)
Returns aint
that represents the unsigned view of the givenbyte
value.static long
toUnsignedLong(byte value)
Returns along
that represents the unsigned view of the givenbyte
value.static short
toUnsignedShort(byte value)
Returns ashort
that represents the unsigned view of the givenbyte
value.static UnsignedByte
valueOf(byte value)
Returns an UnsignedByte instance representing the specified byte value.static UnsignedByte
valueOf(java.lang.String value)
Returns anUnsignedByte
instance representing the specifiedString
value.
-
-
-
Method Detail
-
byteValue
public byte byteValue()
- Overrides:
byteValue
in classjava.lang.Number
-
shortValue
public short shortValue()
- Overrides:
shortValue
in classjava.lang.Number
-
intValue
public int intValue()
- Specified by:
intValue
in classjava.lang.Number
-
longValue
public long longValue()
- Specified by:
longValue
in classjava.lang.Number
-
floatValue
public float floatValue()
- Specified by:
floatValue
in classjava.lang.Number
-
doubleValue
public double doubleValue()
- Specified by:
doubleValue
in classjava.lang.Number
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
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:
compareTo
in interfacejava.lang.Comparable<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
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
valueOf
public static UnsignedByte valueOf(byte value)
Returns an UnsignedByte instance representing the specified byte value. This method always returns a cachedUnsignedByte
instance 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 theUnsignedByte
type.- Parameters:
value
- The byte value to return as anUnsignedByte
instance.- Returns:
- an
UnsignedByte
instance representing the unsigned view of the given byte.
-
valueOf
public static UnsignedByte valueOf(java.lang.String value) throws java.lang.NumberFormatException
Returns anUnsignedByte
instance representing the specifiedString
value. This method always returns a cachedUnsignedByte
instance 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 theUnsignedByte
type.- Parameters:
value
- The byte value to return as anUnsignedByte
instance.- Returns:
- an
UnsignedByte
instance representing the unsigned view of the given byte. - Throws:
java.lang.NumberFormatException
- if the givenString
value given cannot be converted to a numeric value.
-
toUnsignedShort
public static short toUnsignedShort(byte value)
Returns ashort
that represents the unsigned view of the givenbyte
value.- Parameters:
value
- Theshort
whose unsigned value should be converted to a long.- Returns:
- a positive
short
value that represents the givenbyte
as unsigned.
-
toUnsignedInt
public static int toUnsignedInt(byte value)
Returns aint
that represents the unsigned view of the givenbyte
value.- Parameters:
value
- Theint
whose unsigned value should be converted to a long.- Returns:
- a positive
int
value that represents the givenshort
as unsigned.
-
toUnsignedLong
public static long toUnsignedLong(byte value)
Returns along
that represents the unsigned view of the givenbyte
value.- Parameters:
value
- Thelong
whose unsigned value should be converted to a long.- Returns:
- a positive
long
value that represents the givenbyte
as unsigned.
-
-