Interface TransformerData
-
- All Superinterfaces:
DSData
,DSPacket
,DSSerializable
,java.lang.Iterable<DSField>
,TransformerFlags
- All Known Subinterfaces:
TransformerContainer
,TransformerPermission
,TransformerRecord
- All Known Implementing Classes:
TransformerContainerImpl
,TransformerDataImpl
,TransformerPermissionImpl
,TransformerRecordImpl
public interface TransformerData extends DSData, TransformerFlags
Represents an update for a particular object. An update may be received by a Transformer module if it has subscribed to some data using either the
Subscriber.addSubscriptionListener(String, SubscriptionListener)
or theSubscriber.addSubscriptionListener(ObjectType, SubscriptionListener)
methods. Alternatively, the Transformer module can create an update using one of theDSFactory.createTransformerData(java.lang.String, com.caplin.transformer.module.ObjectType)
methods, and can send the update to the Transformer core for processing.The option to create instances of a TransformerData is vital for any Transformer module that wants to act as a
DataProvider
, or to process an update for one DataSource object, and publish the results of the processing on a different DataSource object.As soon as the update is sent, its memory is freed by the Transformer core. Any further attempts to use the object will result in IllegalStateExceptions being thrown. If the update needs to be sent, then further changes made to the object, the
DSFactory.createTransformerData(TransformerData)
method should be used to create a copy of the object before the update is sent.- See Also:
DSFactory
-
-
Field Summary
-
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.transformer.module.TransformerFlags
MAINTAIN_TIMESTAMP, NO_FLAGS, NO_PERSISTENCE, PUBLISH_TO_PEERS, SILENT_SEND, STORE_IN_CACHE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description long
getDSDataPointer()
Gets the pointer to the C ds_data struct that holds the state information for the update.ObjectType
getObjectType()
Gets the update's object type.int
getSequenceNumber()
Gets the update's sequence number.int
merge(TransformerData transformerDataToMerge)
Merges the fields from the specified TransformerData with those in this TransformerData.void
send(int flags)
Sends the update to the Transformer core.void
setType(ObjectType objectType)
Sets the update's object type to the specified type.-
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
-
-
-
-
Method Detail
-
getDSDataPointer
long getDSDataPointer()
Gets the pointer to the C ds_data struct that holds the state information for the update. This method is used internally by the TransformerData.
Once the update has been sent, pointer is nulled down, and this method will throw a IllegalStateException.
- Returns:
- The pointer to the ds_data struct.
- Throws:
java.lang.IllegalStateException
- If the update has already been sent using either theDSPacket.send()
orsend(int)
methods.
-
setType
void setType(ObjectType objectType)
Sets the update's object type to the specified type.
- Parameters:
objectType
- The type of object.- Throws:
java.lang.NullPointerException
- If the objectType is null.
-
getObjectType
ObjectType getObjectType()
Gets the update's object type.
- Returns:
- The ObjectType that represents the object type for this update.
-
getSequenceNumber
int getSequenceNumber()
Gets the update's sequence number.
- Returns:
- the sequence number of the update.
-
merge
int merge(TransformerData transformerDataToMerge)
Merges the fields from the specified TransformerData with those in this TransformerData. If a field does not exist within this TransformerData then the field will be added to it. If the field already exists, then its value will be updated.
If a field exists multiple times (as occurs with type 2 and type 3 records), only the first occurrence will be merged.
- Parameters:
transformerDataToMerge
- The TransformerData from which the fields should be merged from.- Returns:
- The number of fields that were updated.
-
send
void send(int flags)
Sends the update to the Transformer core. The specified flags will determine what the core does with the update.
As soon as the update is sent, its memory is freed by the Transformer core. Any further attempts to use the object will result in IllegalStateExceptions being thrown. If the update needs to be sent, then further changes made to the object, the
DSFactory.createTransformerData(TransformerData)
method should be used to create a copy of the object before the update is sent.The valid flags are:
- NO_FLAGS
- STORE_IN_CACHE
- PUBLISH_TO_PEERS
- SILENT_SEND
- MAINTAIN_TIMESTAMP
- Parameters:
flags
- The flags that should be passed to the Transformer core to tell it how to process the update.- Throws:
java.lang.IllegalStateException
- If the update has already been sent.
-
-