Interface TransformerData

All Superinterfaces:
DSData, DSPacket, DSSerializable, 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 the Subscriber.addSubscriptionListener(ObjectType, SubscriptionListener) methods. Alternatively, the Transformer module can create an update using one of the DSFactory.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:
  • Method Details

    • 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:
      IllegalStateException - If the update has already been sent using either the DSPacket.send() or send(int) methods.
    • setType

      void setType(ObjectType objectType)

      Sets the update's object type to the specified type.

      Parameters:
      objectType - The type of object.
      Throws:
      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:
      IllegalStateException - If the update has already been sent.