Class Field
- java.lang.Object
-
- com.casper.sdk.model.transaction.field.Field
-
- All Implemented Interfaces:
CasperSerializableObject,DeserializableObject,SerializableObject
public class Field extends java.lang.Object implements CasperSerializableObject, DeserializableObject
An indexed field with an offset and value.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeserialize(DeserializerBuffer deser)Called when the object's values must be deserializedshortgetIndex()The field indexorg.slf4j.LoggergetLogger()longgetOffset()The offset of the field's value when written to bytesbyte[]getValue()The field value as bytes<T> TgetValue(java.lang.Class<T> clazz)Obtains the fields value converted to the specified type.booleanisOptional()Indicates if the field is written as an optional fieldvoidserialize(SerializerBuffer ser)Called when the object's values must be serializedvoidserialize(SerializerBuffer ser, Target target)Called when the object's values must be serializedvoidsetIndex(short index)The field indexvoidsetOffset(long offset)The offset of the field's value when written to bytesvoidsetOptional(boolean optional)Indicates if the field is written as an optional fieldvoidsetValue(byte[] value)The field value as bytes
-
-
-
Constructor Detail
-
Field
public Field(int index, long offset, byte[] value)
-
Field
public Field(int index, long offset, boolean optional, java.lang.Object value, Target target) throws ValueSerializationException, NoSuchTypeExceptionConstructs a field with the specified index, offset and value.- Parameters:
index- the index of the fieldoffset- the offset of the fields bytes within a CalltableSerializationEnvelopevalue- the value of the field- Throws:
ValueSerializationException- if the value cannot be serializedNoSuchTypeException
-
Field
public Field()
-
-
Method Detail
-
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
-
serialize
public void serialize(SerializerBuffer ser) throws ValueSerializationException
Description copied from interface:CasperSerializableObjectCalled when the object's values must be serializedAllows to use the default serialize with the custom casper serialize signature, defaulting encodeType to false
- Specified by:
serializein interfaceCasperSerializableObject- Specified by:
serializein interfaceSerializableObject- Parameters:
ser- the serializer to be used- Throws:
ValueSerializationException- exception holding information of failure to serialize a value
-
deserialize
public void deserialize(DeserializerBuffer deser) throws ValueDeserializationException
Description copied from interface:DeserializableObjectCalled when the object's values must be deserialized- Specified by:
deserializein interfaceDeserializableObject- Parameters:
deser- the deserializer buffer to be used- Throws:
ValueDeserializationException- exception holding information of failure to deserialize a value
-
getValue
public <T> T getValue(java.lang.Class<T> clazz) throws ValueDeserializationExceptionObtains the fields value converted to the specified type.- Type Parameters:
T- the expected type- Parameters:
clazz- the type to convert the value's bytes to- Returns:
- the bytes converted to value of type clazz
- Throws:
ValueDeserializationException- if the value cannot be converted to the specified type
-
getLogger
public org.slf4j.Logger getLogger()
-
getIndex
public short getIndex()
The field index
-
getOffset
public long getOffset()
The offset of the field's value when written to bytes
-
getValue
public byte[] getValue()
The field value as bytes
-
isOptional
public boolean isOptional()
Indicates if the field is written as an optional field
-
setIndex
public void setIndex(short index)
The field index
-
setOffset
public void setOffset(long offset)
The offset of the field's value when written to bytes
-
setValue
public void setValue(byte[] value)
The field value as bytes
-
setOptional
public void setOptional(boolean optional)
Indicates if the field is written as an optional field
-
-