Class CLValueEncoder
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.ByteArrayOutputStream
-
- com.syntifi.casper.sdk.model.clvalue.encdec.CLValueEncoder
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class CLValueEncoder extends java.io.ByteArrayOutputStream
Casper CLValue Encoding methods- Since:
- 0.0.1
- See Also:
AbstractCLValue
-
-
Field Summary
Fields Modifier and Type Field Description static java.math.BigInteger
MAX_U128
static java.math.BigInteger
MAX_U256
static java.math.BigInteger
MAX_U512
static java.math.BigInteger
MAX_U64
static java.math.BigInteger
ONE
static java.math.BigInteger
TWO
static java.math.BigInteger
ZERO
-
Constructor Summary
Constructors Constructor Description CLValueEncoder()
Initializes buffer as zero-length
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
writeAny(CLValueAny clValue)
protected void
writeBigInteger(AbstractCLValue<java.math.BigInteger,?> clValue, CLTypeData type)
Writes a BigInteger/U128-U256-U512 to the CLValue byte bufferbyte[]
writeBigInteger(java.math.BigInteger bigInteger)
Writes a BigInteger to the CLValue byte buffervoid
writeBool(CLValueBool clValue)
Writes a boolean value to the CLValue byte buffervoid
writeByteArray(CLValueByteArray clValue)
Writes a byte array value to the CLValue byte buffervoid
writeI32(CLValueI32 clValue)
Writes an Integer/I32 value to the CLValue byte buffervoid
writeI64(CLValueI64 clValue)
Writes a Long/I64 value to the CLValue byte bufferbyte[]
writeInt(java.lang.Integer value)
Writes an Integer value to byte buffervoid
writeKey(CLValueKey clValue)
Writes a Tag/Key Hex string to CLValue byte bufferbyte[]
writeLong(java.lang.Long value)
Writes a Long value to byte buffervoid
writePublicKey(CLValuePublicKey clValue)
Writes a AlgorithmTag/Key Hex string to CLValue byte buffervoid
writeString(CLValueString clValue)
Writes a String/String to the CLValue byte bufferbyte[]
writeString(java.lang.String string)
Writes a String to the byte buffervoid
writeU128(CLValueU128 clValue)
Writes a BigInteger/U128 to the CLValue byte buffervoid
writeU256(CLValueU256 clValue)
Writes a BigInteger/U256 to the CLValue byte buffervoid
writeU32(CLValueU32 clValue)
Writes an Unsigned Integer (Long)/U32 value to the CLValue byte buffervoid
writeU512(CLValueU512 clValue)
Writes a BigInteger/U512 to the CLValue byte buffervoid
writeU64(CLValueU64 clValue)
Writes an Unsigned Long (BigInteger)/U64 to the CLValue byte buffervoid
writeU8(CLValueU8 clValue)
Writes a single byte value to the CLValue byte buffer
-
-
-
Field Detail
-
ZERO
public static final java.math.BigInteger ZERO
-
ONE
public static final java.math.BigInteger ONE
-
TWO
public static final java.math.BigInteger TWO
-
MAX_U64
public static final java.math.BigInteger MAX_U64
-
MAX_U128
public static final java.math.BigInteger MAX_U128
-
MAX_U256
public static final java.math.BigInteger MAX_U256
-
MAX_U512
public static final java.math.BigInteger MAX_U512
-
-
Method Detail
-
writeBool
public void writeBool(CLValueBool clValue) throws java.io.IOException
Writes a boolean value to the CLValue byte buffer- Parameters:
clValue
-CLValueBool
value to encode- Throws:
java.io.IOException
- thrown when an error occurs while writing bytes
-
writeU8
public void writeU8(CLValueU8 clValue)
Writes a single byte value to the CLValue byte buffer- Parameters:
clValue
-CLValueU8
value to encode
-
writeByteArray
public void writeByteArray(CLValueByteArray clValue) throws java.io.IOException
Writes a byte array value to the CLValue byte buffer- Parameters:
clValue
-CLValueByteArray
value to encode- Throws:
java.io.IOException
- thrown when an error occurs while writing bytes
-
writeI32
public void writeI32(CLValueI32 clValue) throws java.io.IOException
Writes an Integer/I32 value to the CLValue byte buffer- Parameters:
clValue
-CLValueI32
value to encode- Throws:
java.io.IOException
- thrown when an error occurs while writing bytes
-
writeU32
public void writeU32(CLValueU32 clValue) throws java.io.IOException
Writes an Unsigned Integer (Long)/U32 value to the CLValue byte buffer- Parameters:
clValue
-CLValueU32
value to encode- Throws:
java.io.IOException
- thrown when an error occurs while writing bytes
-
writeInt
public byte[] writeInt(java.lang.Integer value) throws java.io.IOException
Writes an Integer value to byte buffer- Parameters:
value
- the value to write- Returns:
- byte[]
- Throws:
java.io.IOException
- thrown when an error occurs while writing bytes
-
writeI64
public void writeI64(CLValueI64 clValue) throws java.io.IOException
Writes a Long/I64 value to the CLValue byte buffer- Parameters:
clValue
-CLValueI64
value to encode- Throws:
java.io.IOException
- thrown when an error occurs while writing bytes
-
writeLong
public byte[] writeLong(java.lang.Long value) throws java.io.IOException
Writes a Long value to byte buffer- Parameters:
value
- the value to write- Returns:
- byte[]
- Throws:
java.io.IOException
- thrown when an error occurs while writing bytes
-
writeU64
public void writeU64(CLValueU64 clValue) throws java.io.IOException, CLValueEncodeException
Writes an Unsigned Long (BigInteger)/U64 to the CLValue byte buffer- Parameters:
clValue
-CLValueU64
value to encode- Throws:
java.io.IOException
- thrown when an error occurs while writing bytesCLValueEncodeException
- thrown when a clvalue encoding throws an error
-
writeU128
public void writeU128(CLValueU128 clValue) throws java.io.IOException, CLValueEncodeException
Writes a BigInteger/U128 to the CLValue byte buffer- Parameters:
clValue
-CLValueU128
value to encode- Throws:
java.io.IOException
- thrown when an error occurs while writing bytesCLValueEncodeException
- thrown when a clvalue encoding throws an error
-
writeU256
public void writeU256(CLValueU256 clValue) throws java.io.IOException, CLValueEncodeException
Writes a BigInteger/U256 to the CLValue byte buffer- Parameters:
clValue
-CLValueU256
value to encode- Throws:
java.io.IOException
- thrown when an error occurs while writing bytesCLValueEncodeException
- thrown when a clvalue encoding throws an error
-
writeU512
public void writeU512(CLValueU512 clValue) throws java.io.IOException, CLValueEncodeException
Writes a BigInteger/U512 to the CLValue byte buffer- Parameters:
clValue
-CLValueU512
value to encode- Throws:
java.io.IOException
- thrown when an error occurs while writing bytesCLValueEncodeException
- thrown when a clvalue encoding throws an error
-
writeBigInteger
protected void writeBigInteger(AbstractCLValue<java.math.BigInteger,?> clValue, CLTypeData type) throws java.io.IOException, CLValueEncodeException
Writes a BigInteger/U128-U256-U512 to the CLValue byte buffer- Parameters:
clValue
-AbstractCLValue
value to encodetype
-CLTypeData
CLTypeData of BigInteger- Throws:
java.io.IOException
- thrown when an error occurs while writing bytesCLValueEncodeException
- thrown when a clvalue encoding throws an error
-
writeBigInteger
public byte[] writeBigInteger(java.math.BigInteger bigInteger) throws java.io.IOException
Writes a BigInteger to the CLValue byte buffer- Parameters:
bigInteger
- the biginteger to write- Returns:
- a byte array
- Throws:
java.io.IOException
- thrown when an error occurs while writing bytes
-
writeString
public void writeString(CLValueString clValue) throws java.io.IOException
Writes a String/String to the CLValue byte buffer- Parameters:
clValue
-CLValueString
value to encode- Throws:
java.io.IOException
- thrown when an error occurs while writing bytes
-
writeString
public byte[] writeString(java.lang.String string) throws java.io.IOException
Writes a String to the byte buffer- Parameters:
string
- to encode- Returns:
- byte[]
- Throws:
java.io.IOException
- thrown when an error occurs while writing bytes
-
writePublicKey
public void writePublicKey(CLValuePublicKey clValue) throws java.io.IOException
Writes a AlgorithmTag/Key Hex string to CLValue byte buffer- Parameters:
clValue
-CLValuePublicKey
value to encode- Throws:
java.io.IOException
-
writeKey
public void writeKey(CLValueKey clValue)
Writes a Tag/Key Hex string to CLValue byte buffer- Parameters:
clValue
-CLValueKey
value to encode
-
writeAny
public void writeAny(CLValueAny clValue) throws java.io.IOException
- Throws:
java.io.IOException
-
-