Class UnsignedByte

java.lang.Object
org.xrpl.xrpl4j.codec.addresses.UnsignedByte
All Implemented Interfaces:
Destroyable

public class UnsignedByte extends Object implements Destroyable
Unsigned byte where value can be 0 to 255.
  • Method Details

    • of

      public static UnsignedByte of(UnsignedByte value)
      Copy constructor. Constructs an UnsignedByte from an UnsignedByte.
      Parameters:
      value - An int value.
      Returns:
      An UnsignedByte.
    • of

      public static UnsignedByte of(int value)
      Construct an UnsignedByte from an int.
      Parameters:
      value - An int value.
      Returns:
      An UnsignedByte.
    • of

      public static UnsignedByte of(byte value)
      Construct an UnsignedByte from a byte.
      Parameters:
      value - A byte value.
      Returns:
      An UnsignedByte.
    • of

      public static UnsignedByte of(byte highBits, byte lowBits)
      Construct an UnsignedByte from high bits and low bits.
      Parameters:
      highBits - A byte of the high bits.
      lowBits - A byte of the low bits.
      Returns:
      An UnsignedByte.
    • of

      public static UnsignedByte of(String hex)
      Construct an UnsignedByte from a hexadecimal String.
      Parameters:
      hex - A hexadecimal encoded String.
      Returns:
      An UnsignedByte.
    • asInt

      public int asInt()
      Converts the UnsignedByte to a signed int. Necessary if the UnsignedByte has 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 the UnsignedByte to 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 underlying UnsignedByte.
      Returns:
      The 4 high order bits of this UnsignedByte.
    • getLowBits

      public int getLowBits()
      Gets the 4 low order bits of the underlying UnsignedByte.
      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:
      true if the nth bit is set, otherwise false.
    • or

      public UnsignedByte or(UnsignedByte unsignedByte)
      Does a bitwise OR on this UnsignedByte and the given UnsignedByte, and returns a new UnsignedByte as the result.
      Parameters:
      unsignedByte - The UnsignedByte to perform a bitwise OR on.
      Returns:
      The result of the bitwise OR operation.
    • hexValue

      public String hexValue()
      Encodes this UnsignedByte as a hexadecimal String.
      Returns:
      The hex String value of this UnsignedByte.
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • destroy

      public void destroy()
      Specified by:
      destroy in interface Destroyable
    • isDestroyed

      public boolean isDestroyed()
      Specified by:
      isDestroyed in interface Destroyable