Class CalltableSerializationEnvelopeBuilder
- java.lang.Object
-
- com.casper.sdk.model.transaction.field.CalltableSerializationEnvelopeBuilder
-
- All Implemented Interfaces:
CasperSerializableObject,DeserializableObject,SerializableObject
public class CalltableSerializationEnvelopeBuilder extends java.lang.Object implements CasperSerializableObject, DeserializableObject
The call table serialization envelope builder used to serialize and deserialize transaction fields
-
-
Constructor Summary
Constructors Constructor Description CalltableSerializationEnvelopeBuilder(Target target)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> CalltableSerializationEnvelopeBuilderaddField(int index, T value)Add a mandatory field to the envelope.CalltableSerializationEnvelopeBuilderaddField(Field field)Adds a field to the envelope.CalltableSerializationEnvelopeBuilderaddFieldBytes(int index, byte[] value)Add a field to the envelope.<T> CasperSerializableObjectaddOptionField(int index, T value)Add an optional field to the envelope.voiddeserialize(DeserializerBuffer deserializerBuffer)Called when the object's values must be deserializedbyte[]getFieldBytes(int index)Obtains the field's value bytes.<T> TgetFieldValue(int index, java.lang.Class<T> clazz)Obtains the fields and converts its byte value to the specified type.voidserialize(SerializerBuffer ser, Target target)Called when the object's values must be serializedvoidsetCurrentFieldIndex(long currentFieldIndex)The current field indexvoidsetFields(java.util.List<Field> fields)The fields to serializevoidsetOffset(long offset)The offset of the current field om the serialized bytesvoidsetSize(long size)The total size of all field values when serializedvoidsetTarget(Target target)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.casper.sdk.model.clvalue.serde.CasperSerializableObject
serialize
-
-
-
-
Constructor Detail
-
CalltableSerializationEnvelopeBuilder
public CalltableSerializationEnvelopeBuilder(Target target)
-
-
Method Detail
-
addField
public <T> CalltableSerializationEnvelopeBuilder addField(int index, T value) throws ValueSerializationException, NoSuchTypeException
Add a mandatory field to the envelope.- Parameters:
index- the zero based indexvalue- the value to be serialized to value bytes of the field- Throws:
ValueSerializationExceptionNoSuchTypeException
-
addOptionField
public <T> CasperSerializableObject addOptionField(int index, T value) throws ValueSerializationException, NoSuchTypeException
Add an optional field to the envelope.- Parameters:
index- the zero based indexvalue- the value to be serialized to value bytes of the field- Throws:
ValueSerializationExceptionNoSuchTypeException
-
addFieldBytes
public CalltableSerializationEnvelopeBuilder addFieldBytes(int index, byte[] value)
Add a field to the envelope.- Parameters:
index- the zero based indexvalue- the bytes of the value to add
-
addField
public CalltableSerializationEnvelopeBuilder addField(Field field)
Adds a field to the envelope.- Parameters:
field- the field to add
-
getFieldValue
public <T> T getFieldValue(int index, java.lang.Class<T> clazz) throws ValueDeserializationExceptionObtains the fields and converts its byte value to the specified type.- Type Parameters:
T- the type to convert the field value to- Parameters:
index- the index of the fieldclazz- the tye to convert the field value to- Returns:
- the field value as the specified type
- Throws:
ValueDeserializationException- if the field value cannot be converted to the specified type
-
getFieldBytes
public byte[] getFieldBytes(int index)
Obtains the field's value bytes.- Parameters:
index- the index of the field- Returns:
- the fields value bytes
-
serialize
public void serialize(SerializerBuffer ser, Target target) throws ValueSerializationException
Description copied from interface:CasperSerializableObjectCalled when the object's values must be serialized- Specified by:
serializein interfaceCasperSerializableObject- Parameters:
ser- the serializer to be usedtarget- target serialization standard- Throws:
ValueSerializationException- exception holding information of failure to serialize a value
-
deserialize
public void deserialize(DeserializerBuffer deserializerBuffer) throws ValueDeserializationException
Description copied from interface:DeserializableObjectCalled when the object's values must be deserialized- Specified by:
deserializein interfaceDeserializableObject- Parameters:
deserializerBuffer- the deserializer buffer to be used- Throws:
ValueDeserializationException- exception holding information of failure to deserialize a value
-
setFields
public void setFields(java.util.List<Field> fields)
The fields to serialize
-
setCurrentFieldIndex
public void setCurrentFieldIndex(long currentFieldIndex)
The current field index
-
setOffset
public void setOffset(long offset)
The offset of the current field om the serialized bytes
-
setSize
public void setSize(long size)
The total size of all field values when serialized
-
setTarget
public void setTarget(Target target)
-
-