Class TransformerRecordImpl
- All Implemented Interfaces:
DSData
,DSPacket
,DSRecord
,DSSerializable
,TransformerData
,TransformerRecord
,TransformerFlags
,Iterable<DSField>
Implementation of the TransformerRecord interface.
-
Field Summary
Fields inherited from class com.caplin.transformer.module.datasrc.TransformerDataImpl
modCount
Fields inherited from interface com.caplin.datasrc.interfaces.DSData
CONTAINER_TYPE, F_AUTH_UPDATE, F_AUTHGLOBAL, F_CHANGEDFIELDS, F_CLEAR_PERMISSIONS, F_CLEAR_TYPE2, F_CLEAR_TYPE3, F_CREATEOBJECT, F_CREATEPARENT, F_DELETE_PERMISSION, F_FILTER_TYPE2, F_FILTER_TYPE3, F_IMAGE, F_NONACTIVE, GENERIC_TYPE, NEWS_TYPE, PAGE_TYPE, PERMISSION_TYPE, RECORD_TYPE, STORY_TYPE, TYPE2_RECORD_TYPE, TYPE3_RECORD_TYPE, UNKNOWN_TYPE
Fields inherited from interface com.caplin.datasrc.interfaces.DSRecord
DS_FIELDS_SEPARATOR, F_NOCACHE
Fields inherited from interface com.caplin.transformer.module.TransformerFlags
MAINTAIN_TIMESTAMP, NO_FLAGS, NO_PERSISTENCE, PUBLISH_TO_PEERS, SILENT_SEND, STORE_IN_CACHE
-
Constructor Summary
ModifierConstructorDescriptionprotected
TransformerRecordImpl
(long dsDataPointer) Constructor is protected to prevent a TransformerRecord being instantiated except by the DSFactory class.protected
TransformerRecordImpl
(long dsDataPointer, boolean freeDsDataPointer) Constructor is protected to prevent a TransformerRecord being instantiated except by the DSFactory class. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBinaryRecordData
(String fieldName, byte value) Adds the byte value for the specified field name.void
addBinaryRecordData
(String fieldName, byte[] value) Adds the byte array value for the specified field name.void
addBinaryRecordData
(String fieldName, double value) Adds the double value for the specified field name.void
addBinaryRecordData
(String fieldName, float value) Adds the float value for the specified field name.void
addBinaryRecordData
(String fieldName, int value) Adds the integer value for the specified field name.void
addBinaryRecordData
(String fieldName, long value) Adds the long value for the specified field name.void
addBinaryRecordData
(String fieldName, short value) Adds the short value for the specified field name.void
addBinaryRecordData
(String fieldName, String value) Adds the String value for the specified field name.void
Adds a separator field, with field numberDSRecord.DS_FIELDS_SEPARATOR
, to the TransformerRecord, allowing multiple type 2 and type 3 record entries to be contributed in a single update.void
addRecordData
(String fieldName, char value) Adds the String representation of the character value for the specified field name.void
addRecordData
(String fieldName, char[] value) Adds the String representation of the character array for the specified field name.void
addRecordData
(String fieldName, double value) Adds the String representation of the double value for the specified field name.void
addRecordData
(String fieldName, float value) Adds the String representation of the float value for the specified field name.void
addRecordData
(String fieldName, int value) Adds the String representation of the integer value for the specified field name.void
addRecordData
(String fieldName, long value) Adds the String representation of the long value for the specified field name.void
addRecordData
(String fieldName, String value) Adds the String value for the specified field name.getFieldByName
(String fieldName) Gets the first occurrence of the field with the specified field name.getFieldByName
(String fieldName, int occurrence) Gets the specified occurrence of the field with the specified field name.boolean
updateRecordData
(String fieldName, String value) Sets the value of the first occurrence for the specified field name.boolean
updateRecordData
(String fieldName, String value, int occurrence) Sets the value of the first occurrence for the specified field name.Methods inherited from class com.caplin.transformer.module.datasrc.TransformerDataImpl
addBinaryData, addBinaryData, addBinaryData, addBinaryData, addBinaryData, addBinaryData, addBinaryData, addBinaryData, addData, addData, addData, addData, addData, addData, addData, addData, addString, addString, clearFields, count, elements, finalize, getDSDataPointer, getFieldByFieldNumber, getFieldByFieldNumber, getFlags, getKeys, getObjectType, getSequenceNumber, getSubject, getType, getValues, iterator, merge, removeField, send, send, sendDirect, sendToPeer, setFlags, setSubject, setType, setType, toBytes, updateData, updateData
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.caplin.datasrc.interfaces.DSData
addBinaryData, addBinaryData, addBinaryData, addBinaryData, addBinaryData, addBinaryData, addBinaryData, addBinaryData, addData, addData, addData, addData, addData, addData, addData, addData, clearFields, count, elements, getFieldByFieldNumber, getFieldByFieldNumber, getFlags, getKeys, getSubject, getType, getValues, iterator, removeField, setFlags, setSubject, setType, updateData, updateData
Methods inherited from interface com.caplin.datasrc.interfaces.DSPacket
send, sendDirect, sendToPeer
Methods inherited from interface com.caplin.datasrc.interfaces.DSSerializable
toBytes
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface com.caplin.transformer.module.datasrc.TransformerData
getDSDataPointer, getObjectType, getSequenceNumber, merge, send, setType
-
Constructor Details
-
TransformerRecordImpl
protected TransformerRecordImpl(long dsDataPointer) Constructor is protected to prevent a TransformerRecord being instantiated except by the DSFactory class.
A TransformerRecord created with this constructor will be responsible for freeing the memory for the underlying C ds_data struct.
This is equivalent to calling TransformerRecord(dsDataPointer, false).
- Parameters:
dsDataPointer
- The pointer to the C ds_data struct that holds the state information for the update.
-
TransformerRecordImpl
protected TransformerRecordImpl(long dsDataPointer, boolean freeDsDataPointer) Constructor is protected to prevent a TransformerRecord being instantiated except by the DSFactory class.
- Parameters:
dsDataPointer
- The pointer to the C ds_data struct that holds the state information for the update.freeDsDataPointer
- true if the TransformerRecord is responsible for freeing up the memory for the C ds_data struct, or false if the Transformer core is responsible.
-
-
Method Details
-
updateRecordData
Sets the value of the first occurrence for the specified field name. The occurrence parameter is ignored in this version.
If there are three occurrences of the field Last, "75", "75.5" and "75.25", then calling updateRecordData("Last", "76", 2) will change occurrences to be "76", "75.5" and "75.25".
- Specified by:
updateRecordData
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.value
- The new value for the field.occurrence
- The occurrence of the field to be updated. The first field is occurrence 0, the next occurrence 1, and so on.- Returns:
- true if the value was successfully set for the specified field, otherwise false.
- Throws:
NullPointerException
- If the value argument is null.
-
updateRecordData
Description copied from interface:DSRecord
Sets the value of the first occurrence for the specified field name.
If there are three occurrences of the field Last, "75", "75.5" and "75.25", then calling updateRecordData("Last", "76") will change occurrences to be "76", "75.5" and "75.25".
This is equivalent to calling updateRecordData(fieldName, value, 0).
- Specified by:
updateRecordData
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.value
- The new value for the field.- Returns:
- true if the value was successfully set for the specified field, otherwise false.
- Throws:
NullPointerException
- If the value argument is null.
-
addRecordData
Description copied from interface:DSRecord
Adds the String value for the specified field name.
- Specified by:
addRecordData
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.value
- The value to be stored in the field.- Throws:
NullPointerException
- If the value argument is null.
-
addRecordData
Description copied from interface:DSRecord
Adds the String representation of the character value for the specified field name.
- Specified by:
addRecordData
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.value
- The value to be stored in the field.
-
addRecordData
Description copied from interface:DSRecord
Adds the String representation of the character array for the specified field name.
- Specified by:
addRecordData
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.value
- The value to be stored in the field.- Throws:
NullPointerException
- If the value argument is null.
-
addRecordData
Description copied from interface:DSRecord
Adds the String representation of the double value for the specified field name.
Warning: the underlying implementation will not guarantee any accuracy beyond 12 decimal places. If greater precision is required, the value should be formatted separately and added using the
DSRecord.addRecordData(String, String)
method.- Specified by:
addRecordData
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.value
- The value to be stored in the field.
-
addRecordData
Description copied from interface:DSRecord
Adds the String representation of the float value for the specified field name.
Warning: the underlying implementation will not guarantee any accuracy beyond 6 decimal places. If greater precision is required, the value should be formatted separately and added using the
DSRecord.addRecordData(String, String)
method.- Specified by:
addRecordData
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.value
- The value to be stored in the field.
-
addRecordData
Description copied from interface:DSRecord
Adds the String representation of the integer value for the specified field name.
- Specified by:
addRecordData
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.value
- The value to be stored in the field.
-
addRecordData
Description copied from interface:DSRecord
Adds the String representation of the long value for the specified field name.
- Specified by:
addRecordData
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.value
- The value to be stored in the field.
-
addBinaryRecordData
Description copied from interface:DSRecord
Adds the byte value for the specified field name. This method Base64 encodes the value before storing it.
- Specified by:
addBinaryRecordData
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.value
- The byte value to be stored in the field.
-
addBinaryRecordData
Description copied from interface:DSRecord
Adds the short value for the specified field name. This method Base64 encodes the value before storing it.
- Specified by:
addBinaryRecordData
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.value
- The value to be stored in the field.
-
addBinaryRecordData
Description copied from interface:DSRecord
Adds the integer value for the specified field name. This method Base64 encodes the value before storing it.
- Specified by:
addBinaryRecordData
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.value
- The value to be stored in the field.
-
addBinaryRecordData
Description copied from interface:DSRecord
Adds the long value for the specified field name. This method Base64 encodes the value before storing it.
- Specified by:
addBinaryRecordData
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.value
- The value to be stored in the field.
-
addBinaryRecordData
Description copied from interface:DSRecord
Adds the float value for the specified field name. This method Base64 encodes the value before storing it.
- Specified by:
addBinaryRecordData
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.value
- The value to be stored in the field.
-
addBinaryRecordData
Description copied from interface:DSRecord
Adds the double value for the specified field name. This method Base64 encodes the value before storing it.
- Specified by:
addBinaryRecordData
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.value
- The value to be stored in the field.
-
addBinaryRecordData
Description copied from interface:DSRecord
Adds the byte array value for the specified field name. This method Base64 encodes the value before storing it.
- Specified by:
addBinaryRecordData
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.value
- The array of bytes to be stored in the field.- Throws:
NullPointerException
- If the value argument is null.
-
addBinaryRecordData
Description copied from interface:DSRecord
Adds the String value for the specified field name. This method Base64 encodes the value before storing it.
- Specified by:
addBinaryRecordData
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.value
- The value to be stored in the field.- Throws:
NullPointerException
- If the value argument is null.
-
getFieldByName
Description copied from interface:DSRecord
Gets the first occurrence of the field with the specified field name.
If there are three occurrences of the field Last, with values "75", "75.5" and "75.25", then calling getFieldByFieldName("Last") will return the field that contains the value "75".
This is equivalent to calling getFieldByFieldName(fieldName, 0).
- Specified by:
getFieldByName
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.- Returns:
- The field for the first occurrence of the field name, or null if the specified field is not found.
-
getFieldByName
Description copied from interface:DSRecord
Gets the specified occurrence of the field with the specified field name.
If there are three occurrences of the field Last, with values "75", "75.5" and "75.25", then calling getFieldByFieldName("Last", 2) will return the field that contains the value "75.25".
- Specified by:
getFieldByName
in interfaceDSRecord
- Parameters:
fieldName
- The name of the field.occurrence
- The occurrence of the field to be got. The first field is occurrence 0, the next occurrence 1, and so on.- Returns:
- The field for the specified occurrence of the field name, or null if the specified field is not found.
-
addDataSeparator
public void addDataSeparator()Adds a separator field, with field number
DSRecord.DS_FIELDS_SEPARATOR
, to the TransformerRecord, allowing multiple type 2 and type 3 record entries to be contributed in a single update. Please see the examples below for how this works.Multiple type 2 entries contribution example
In this example, field "MktMkrId" is the type 2 index, whilst "Bid" is a type 2 price field. This example will send two type 2 entries, one for Caplin (with a Bid of 100) and one for Another Marker Maker (with a Bid of 102.5). Type 2 data can be retrieved from the Transformer core's cache using
DataCache.getType2Indices
andDataCache#getType2
.Note: The type 2 index field must be the first field in an update or after a separator field.
DSRecord type2Record = DSFactory.createTransformerRecord("/TYPE2/EXAMPLE"); type2Record.addRecordData("MktMkrId", "Caplin"); type2Record.addRecordData("Bid", 100.0); type2Record.addDataSeparator(); type2Record.addRecordData("MktMkrId", "Another Market Maker"); type2Record.addRecordData("Bid", 102.5); type2Record.send();
Multiple type 3 entries contribution example
This example will send the values 205, 210, 212.5 and 215 for the Last field, with the last one (215) interpreted as the most recent. Type 3 data can be retrieved from the Transformer core's cache using
DataCache.getType3Field
.DSRecord type3Record = DSFactory.createTransformerRecord("/TYPE3/EXAMPLE"); type3Record.addRecordData("Last", 205.0); type3Record.addDataSeparator(); type3Record.addRecordData("Last", 210.0); type3Record.addDataSeparator(); type3Record.addRecordData("Last", 212.5); type3Record.addDataSeparator(); type3Record.addRecordData("Last", 215.0); type3Record.send();
- Specified by:
addDataSeparator
in interfaceDSRecord
-