Package org.xrpl.xrpl4j.codec.addresses
Class UnsignedByte
java.lang.Object
org.xrpl.xrpl4j.codec.addresses.UnsignedByte
- All Implemented Interfaces:
Destroyable
Unsigned byte where value can be 0 to 255.
-
Method Summary
Modifier and TypeMethodDescriptionbyteasByte()Converts theUnsignedByteto a signed byte.intasInt()Converts theUnsignedByteto a signed int.voiddestroy()booleanintGets the 4 high order bits of the underlyingUnsignedByte.intGets the 4 low order bits of the underlyingUnsignedByte.inthashCode()hexValue()Encodes thisUnsignedByteas a hexadecimalString.booleanbooleanisNthBitSet(int nth) Checks if the nth bit (1-based index from left to right) is set.static UnsignedByteof(byte value) Construct anUnsignedBytefrom abyte.static UnsignedByteof(byte highBits, byte lowBits) Construct anUnsignedBytefrom high bits and low bits.static UnsignedByteof(int value) Construct anUnsignedBytefrom anint.static UnsignedByteConstruct anUnsignedBytefrom a hexadecimalString.static UnsignedByteof(UnsignedByte value) Copy constructor.or(UnsignedByte unsignedByte) Does a bitwise OR on thisUnsignedByteand the givenUnsignedByte, and returns a newUnsignedByteas the result.
-
Method Details
-
of
Copy constructor. Constructs anUnsignedBytefrom anUnsignedByte.- Parameters:
value- Anintvalue.- Returns:
- An
UnsignedByte.
-
of
Construct anUnsignedBytefrom anint.- Parameters:
value- Anintvalue.- Returns:
- An
UnsignedByte.
-
of
Construct anUnsignedBytefrom abyte.- Parameters:
value- Abytevalue.- Returns:
- An
UnsignedByte.
-
of
Construct anUnsignedBytefrom high bits and low bits.- Parameters:
highBits- Abyteof the high bits.lowBits- Abyteof the low bits.- Returns:
- An
UnsignedByte.
-
of
Construct anUnsignedBytefrom a hexadecimalString.- Parameters:
hex- A hexadecimal encodedString.- Returns:
- An
UnsignedByte.
-
asInt
public int asInt()Converts theUnsignedByteto a signed int. Necessary if theUnsignedBytehas a value greater than 127 and the result needs to be used for numeric purposes.- Returns:
- This
UnsignedByte's value as a signed int.
-
asByte
public byte asByte()Converts theUnsignedByteto a signed byte. Note that this can be unsafe to do if the underlying value is greater than 127 which is the max value for signed byte in Java AND the byte is being used for numerical purposes.- Returns:
- This
UnsignedByte's value as a signed byte.
-
getHighBits
public int getHighBits()Gets the 4 high order bits of the underlyingUnsignedByte.- Returns:
- The 4 high order bits of this
UnsignedByte.
-
getLowBits
public int getLowBits()Gets the 4 low order bits of the underlyingUnsignedByte.- Returns:
- The 4 low order bits of this
UnsignedByte.
-
isNthBitSet
public boolean isNthBitSet(int nth) Checks if the nth bit (1-based index from left to right) is set.- Parameters:
nth- The index of the bit to check.- Returns:
trueif the nth bit is set, otherwisefalse.
-
or
Does a bitwise OR on thisUnsignedByteand the givenUnsignedByte, and returns a newUnsignedByteas the result.- Parameters:
unsignedByte- TheUnsignedByteto perform a bitwise OR on.- Returns:
- The result of the bitwise OR operation.
-
hexValue
Encodes thisUnsignedByteas a hexadecimalString.- Returns:
- The hex
Stringvalue of thisUnsignedByte.
-
equals
-
hashCode
public int hashCode() -
destroy
public void destroy()- Specified by:
destroyin interfaceDestroyable
-
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyedin interfaceDestroyable
-