Package org.polkadot.types.codec
Class Compact
- java.lang.Object
-
- org.polkadot.types.codec.Base<Compactable>
-
- org.polkadot.types.codec.Compact
-
- All Implemented Interfaces:
Codec
- Direct Known Subclasses:
NonceCompact
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 Summary
Constructors Constructor Description Compact(Types.ConstructorCodec<? extends Compactable> type, java.lang.Object value)
-
Method Summary
Modifier and Type Method Description intbitLength()Returns the number of bits in the valuebooleaneq(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()Checks if the value is an empty valuejava.math.BigIntegertoBn()Returns the BN representation of the numberjava.lang.StringtoHex()Returns a hex string representation of the valuejava.lang.ObjecttoJson()Converts the Object to JSON, typically used for RPC transferslongtoNumber()Returns the number representation for the valuejava.lang.StringtoString()Returns the string representation of the valuebyte[]toU8a(boolean isBare)Encodes the value as a Uint8Array as per the parity-codec specificationsstatic Types.ConstructorCodec<Compact>with(Types.ConstructorCodec<? extends Compactable> type)
-
-
-
Constructor Detail
-
Compact
public Compact(Types.ConstructorCodec<? extends Compactable> type, java.lang.Object value)
-
-
Method Detail
-
with
public static Types.ConstructorCodec<Compact> with(Types.ConstructorCodec<? extends Compactable> type)
-
toBn
public java.math.BigInteger toBn()
Returns the BN representation of the number
-
getEncodedLength
public int getEncodedLength()
The length of the value when encoded as a Uint8Array- Specified by:
getEncodedLengthin interfaceCodec
-
isEmpty
public boolean isEmpty()
Checks if the value is an empty value
-
bitLength
public int bitLength()
Returns the number of bits in the value
-
eq
public boolean eq(java.lang.Object other)
Compares the value of the input to see if there is a match
-
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
-
toNumber
public long toNumber()
Returns the number representation for the value
-
toString
public java.lang.String toString()
Returns the string representation of the value- Overrides:
toStringin classjava.lang.Object
-
-