Package org.polkadot.types.codec
Class U8a
- java.lang.Object
-
- org.polkadot.types.codec.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 booleaneq(java.lang.Object other)Compares the value of the input to see if there is a matchintgetEncodedLength()The length of the value when encoded as a Uint8ArraybooleanisEmpty()Returns true if the type wraps an empty/default all-0 valueintlength()The length of the valueU8asubarray(int begin, int end)java.lang.StringtoHex()Returns a hex string representation of the valuejava.lang.ObjecttoJson()Converts the Object to JSON, typically used for RPC transfersjava.lang.StringtoString()Returns the string representation of the valuebyte[]toU8a(boolean isBare)
-
-
-
Method Detail
-
getEncodedLength
public int getEncodedLength()
The length of the value when encoded as a Uint8Array- Specified by:
getEncodedLengthin interfaceCodec
-
isEmpty
public boolean isEmpty()
Returns true if the type wraps an empty/default all-0 value
-
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
-
subarray
public U8a subarray(int begin, int end)
- Parameters:
begin- The position to start atend- 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
-
toJson
public java.lang.Object toJson()
Converts the Object to JSON, typically used for RPC transfers
-
toString
public java.lang.String toString()
Returns the string representation of the value- Overrides:
toStringin classjava.lang.Object
-
-