Class U8a

  • All Implemented Interfaces:
    Codec
    Direct Known Subclasses:
    Bytes, ExtrinsicEra, U8aFixed

    public class U8a
    extends java.lang.Object
    implements Codec
    A basic wrapper around Uint8Array, with no frills and no fuss. It does differ from other implementations wher it will consume the full Uint8Array as passed to it. As such it is meant to be subclassed where the wrapper takes care of the actual lengths instead of used directly.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      byte[] raw  
    • Constructor Summary

      Constructors 
      Constructor Description
      U8a​(java.lang.Object value)  
    • Method Summary

      Modifier and Type Method Description
      boolean eq​(java.lang.Object other)
      Compares the value of the input to see if there is a match
      int getEncodedLength()
      The length of the value when encoded as a Uint8Array
      boolean isEmpty()
      Returns true if the type wraps an empty/default all-0 value
      int length()
      The length of the value
      U8a subarray​(int begin, int end)  
      java.lang.String toHex()
      Returns a hex string representation of the value
      java.lang.Object toJson()
      Converts the Object to JSON, typically used for RPC transfers
      java.lang.String toString()
      Returns the string representation of the value
      byte[] toU8a​(boolean isBare)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.polkadot.types.Codec

        toU8a
    • Field Detail

      • raw

        public byte[] raw
    • Constructor Detail

      • U8a

        public U8a​(java.lang.Object value)
    • Method Detail

      • getEncodedLength

        public int getEncodedLength()
        The length of the value when encoded as a Uint8Array
        Specified by:
        getEncodedLength in interface Codec
      • isEmpty

        public boolean isEmpty()
        Returns true if the type wraps an empty/default all-0 value
        Specified by:
        isEmpty in interface Codec
      • length

        public int length()
        The length of the value
      • eq

        public boolean eq​(java.lang.Object other)
        Compares the value of the input to see if there is a match
        Specified by:
        eq in interface Codec
      • subarray

        public U8a subarray​(int begin,
                            int end)
        Parameters:
        begin - The position to start at
        end - The position to end at Create a new subarray from the actual buffer. This is needed for compat reasons since a new Uint8Array gets returned here
      • toHex

        public java.lang.String toHex()
        Returns a hex string representation of the value
        Specified by:
        toHex in interface Codec
      • toJson

        public java.lang.Object toJson()
        Converts the Object to JSON, typically used for RPC transfers
        Specified by:
        toJson in interface Codec
      • toString

        public java.lang.String toString()
        Returns the string representation of the value
        Overrides:
        toString in class java.lang.Object
      • toU8a

        public byte[] toU8a​(boolean isBare)
        Specified by:
        toU8a in interface Codec
        Parameters:
        isBare - true when the value has none of the type-specific prefixes (internal) Encodes the value as a Uint8Array as per the parity-codec specifications