public class Compact extends Base<Compactable> implements Codec
Compact A compact length-encoding codec wrapper. It performs the same function as Length, however differs in that it uses a variable number of bytes to do the actual encoding. This is mostly used by other types to add length-prefixed encoding, or in the case of wrapped types, taking a number and making the compact representation thereof
Constructor and Description |
---|
Compact(Types.ConstructorCodec<? extends Compactable> type,
java.lang.Object value) |
Modifier and Type | Method and Description |
---|---|
int |
bitLength()
Returns the number of bits in the value
|
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()
Checks if the value is an empty value
|
java.math.BigInteger |
toBn()
Returns the BN representation of the number
|
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
|
long |
toNumber()
Returns the number representation for the value
|
java.lang.String |
toString()
Returns the string representation of the value
|
byte[] |
toU8a(boolean isBare)
Encodes the value as a Uint8Array as per the parity-codec specifications
|
static Types.ConstructorCodec<Compact> |
with(Types.ConstructorCodec<? extends Compactable> type) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getConstructorCodec, toU8a
public Compact(Types.ConstructorCodec<? extends Compactable> type, java.lang.Object value)
public static Types.ConstructorCodec<Compact> with(Types.ConstructorCodec<? extends Compactable> type)
public java.math.BigInteger toBn()
Returns the BN representation of the number
public int getEncodedLength()
The length of the value when encoded as a Uint8Array
getEncodedLength
in interface Codec
public boolean isEmpty()
Checks if the value is an empty value
public int bitLength()
Returns the number of bits in the value
public boolean eq(java.lang.Object other)
Compares the value of the input to see if there is a match
public java.lang.String toHex()
Returns a hex string representation of the value
public java.lang.Object toJson()
Converts the Object to JSON, typically used for RPC transfers
public long toNumber()
Returns the number representation for the value
public java.lang.String toString()
Returns the string representation of the value
toString
in class java.lang.Object