Interface DSData

All Superinterfaces:
DSPacket, DSSerializable, Iterable<DSField>
All Known Subinterfaces:
DSContainer, DSPage, DSPermission, DSRecord, TransformerContainer, TransformerData, TransformerPermission, TransformerRecord
All Known Implementing Classes:
TransformerContainerImpl, TransformerDataImpl, TransformerPermissionImpl, TransformerRecordImpl

public interface DSData extends DSPacket, Iterable<DSField>

This interface should be implemented by a class that needs to send data to DataSource peers (for example, a Caplin Liberator, or another DataSource-enabled application).

Peers identify instances of a class that implements DSData by their subject names. The peer can also determine the type of object (record, page, etc.) and whether it should take any special actions, indicated by the flags.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    A Container object type.
    static final int
    Used to indicate to a Liberator that this update should be checked for client access using the auth module.
    static final int
    Indicates that this object is a global permission object and that all updates for it should be passed through to the Auth module.
    static final int
    Indicates that this object should be delta compressed before sending on to the clients.
    static final int
    Clear all permission entries for this object.
    static final int
    Clear all type 2 entries for this object.
    static final int
    Clear all type 3 entries for this object.
    static final int
    Creates this object if it does not exist.
    static final int
    Creates the parent directory if it does not exist.
    static final int
    Delete any permission entries for this object with the same value as the first field in the update.
    static final int
    Clear any type 2 entries for this object with the same value as the first field in the update.
    static final int
    Clear all type 3 entries for this object with the same value as the first field in the update.
    static final int
    Indicates this packet is an image and not an update.
    static final int
    Indicates that this object should be treated in a non-active (ie broadcast) manner.
    static final int
    A Generic Type object type.
    static final int
    A News Headline object type.
    static final int
    A Page object type.
    static final int
    A Permission object type.
    static final int
    A Record object type.
    static final int
    A News Story object type.
    static final int
    A Type 2 Record object type.
    static final int
    A Type 3 Record object type.
    static final int
    An uknown type.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addBinaryData(int fieldNumber, byte value)
    Adds the byte value for the specified field number.
    void
    addBinaryData(int fieldNumber, byte[] value)
    Adds the byte array value for the specified field number.
    void
    addBinaryData(int fieldNumber, double value)
    Adds the double value for the specified field number.
    void
    addBinaryData(int fieldNumber, float value)
    Adds the float value for the specified field number.
    void
    addBinaryData(int fieldNumber, int value)
    Adds the integer value for the specified field number.
    void
    addBinaryData(int fieldNumber, long value)
    Adds the long value for the specified field number.
    void
    addBinaryData(int fieldNumber, short value)
    Adds the short value for the specified field number.
    void
    addBinaryData(int fieldNumber, String value)
    Adds the String value for the specified field number.
    void
    addData(int fieldNumber, char value)
    Adds the String representation of the character value for the specified field number.
    void
    addData(int fieldNumber, char[] value)
    Adds the String representation of the character array for the specified field number.
    void
    addData(int fieldNumber, double value)
    Adds the String representation of the double value for the specified field number.
    void
    addData(int fieldNumber, float value)
    Adds the String representation of the float value for the specified field number.
    void
    addData(int fieldNumber, int value)
    Adds the String representation of the integer value for the specified field number.
    void
    addData(int fieldNumber, long value)
    Adds the String representation of the long value for the specified field number.
    void
    addData(int fieldNumber, String value)
    Adds the String value for the specified field number.
    void
    addData(DSField dsField)
    Adds the DSField.
    void
    Removes all the fields.
    int
    Gets the number of fields that are present in this packet.
    Returns an enumeration of the fields for this DSData.
    getFieldByFieldNumber(int fieldNumber)
    Gets the first occurrence of the field with the specified field number.
    getFieldByFieldNumber(int fieldNumber, int occurrence)
    Gets the specified occurrence of the field with the specified field number.
    int
    Gets the flags that are going to be sent with this packet.
    Returns as Enumeration of Integers indicating the field number .
    Gets this object's subject.
    int
    Gets this object's type.
    Returns as Enumeration of Strings indicating the field values .
    Returns an iterator of the fields for this DSData.
    boolean
    Removes the specified field from the DSData.
    void
    setFlags(int flags)
    Sets the flags to be sent with this packet.
    void
    setSubject(String subject)
    Sets this object's subject.
    void
    setType(int type)
    Sets the object type of this DSData to the specified value.
    boolean
    updateData(int fieldNumber, String value)
    Sets the value of the first occurrence for the specified field number.
    boolean
    updateData(int fieldNumber, String value, int occurrence)
    Sets the value of the specified occurrence for a particular field number.

    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
  • Field Details

    • F_CREATEOBJECT

      static final int F_CREATEOBJECT
      Creates this object if it does not exist.
      See Also:
    • F_CREATEPARENT

      static final int F_CREATEPARENT
      Creates the parent directory if it does not exist.
      See Also:
    • F_IMAGE

      static final int F_IMAGE
      Indicates this packet is an image and not an update. Initial values should be sent using this flag. All exisiting fields will be replaced by those in this packet. Any existing fields that are not present in this update will be deleted.
      See Also:
    • F_NONACTIVE

      static final int F_NONACTIVE
      Indicates that this object should be treated in a non-active (ie broadcast) manner. Useful when an active source wishes to also send some broadcast data.
      See Also:
    • F_AUTH_UPDATE

      static final int F_AUTH_UPDATE
      Used to indicate to a Liberator that this update should be checked for client access using the auth module. Currently only applicable to NEWS_TYPE objects.
      See Also:
    • F_CHANGEDFIELDS

      static final int F_CHANGEDFIELDS
      Indicates that this object should be delta compressed before sending on to the clients. This means that the Liberator will check this packet for changes to the current values and only send on the values that have changed to all the clients. See the Liberator Admin Guide for more details.
      See Also:
    • F_FILTER_TYPE2

      static final int F_FILTER_TYPE2
      Clear any type 2 entries for this object with the same value as the first field in the update. Ignores any other fields in the packet.

      N.B. In the case of the first field being a type 2 identified (e.g. Market-Maker, Quote ID) it will delete that single entry. If the first field is a standard field then there may be multiple matching entries, all of which will be deleted.

      See Also:
    • F_FILTER_TYPE3

      static final int F_FILTER_TYPE3
      Clear all type 3 entries for this object with the same value as the first field in the update. Ignores any other fields.
      See Also:
    • F_CLEAR_TYPE2

      static final int F_CLEAR_TYPE2
      Clear all type 2 entries for this object. If further entries are included in this packet then these will be stored.
      See Also:
    • F_CLEAR_TYPE3

      static final int F_CLEAR_TYPE3
      Clear all type 3 entries for this object. If further entries are included in this packet then these will be stored.
      See Also:
    • F_AUTHGLOBAL

      static final int F_AUTHGLOBAL
      Indicates that this object is a global permission object and that all updates for it should be passed through to the Auth module.
      See Also:
    • F_DELETE_PERMISSION

      static final int F_DELETE_PERMISSION
      Delete any permission entries for this object with the same value as the first field in the update. Ignores any other fields in the packet.
      See Also:
    • F_CLEAR_PERMISSIONS

      static final int F_CLEAR_PERMISSIONS
      Clear all permission entries for this object. If further entries are included in this packet then these will be stored.
      See Also:
    • UNKNOWN_TYPE

      static final int UNKNOWN_TYPE
      An uknown type. Used by CacheManager.
      See Also:
    • PAGE_TYPE

      static final int PAGE_TYPE
      A Page object type.
      See Also:
    • RECORD_TYPE

      static final int RECORD_TYPE
      A Record object type.
      See Also:
    • NEWS_TYPE

      static final int NEWS_TYPE
      A News Headline object type.
      See Also:
    • STORY_TYPE

      static final int STORY_TYPE
      A News Story object type.
      See Also:
    • TYPE2_RECORD_TYPE

      static final int TYPE2_RECORD_TYPE
      A Type 2 Record object type.
      See Also:
    • TYPE3_RECORD_TYPE

      static final int TYPE3_RECORD_TYPE
      A Type 3 Record object type.
      See Also:
    • CONTAINER_TYPE

      static final int CONTAINER_TYPE
      A Container object type.
      See Also:
    • PERMISSION_TYPE

      static final int PERMISSION_TYPE
      A Permission object type.
      See Also:
    • GENERIC_TYPE

      static final int GENERIC_TYPE
      A Generic Type object type.
      See Also:
  • Method Details

    • setFlags

      void setFlags(int flags)

      Sets the flags to be sent with this packet.

      The flags that can be set are:

      Multiple flags can be set by bitwise ORing them together (e.g. F_CREATEOBJECT|F_CREATEPARENT|F_IMAGE).

      Parameters:
      flags - The flags to be sent with this packet.
    • getFlags

      int getFlags()

      Gets the flags that are going to be sent with this packet.

      Returns:
      The flags that are going to be sent.
    • setType

      void setType(int type)

      Sets the object type of this DSData to the specified value.

      Valid object types are:

      Parameters:
      type - this object's type.
    • getType

      int getType()

      Gets this object's type.

      Returns:
      The object's type.
    • setSubject

      void setSubject(String subject)

      Sets this object's subject.

      Parameters:
      subject - The subject name.
    • getSubject

      String getSubject()

      Gets this object's subject.

      Returns:
      The subject name.
    • count

      int count()

      Gets the number of fields that are present in this packet.

      Returns:
      The number of fields in this packet.
    • getKeys

      Enumeration getKeys()

      Returns as Enumeration of Integers indicating the field number .

      Returns:
      the Enumeration.
    • getValues

      Enumeration getValues()

      Returns as Enumeration of Strings indicating the field values .

      Returns:
      the Enumeration.
    • elements

      Enumeration elements()

      Returns an enumeration of the fields for this DSData. Each field is represented by a DSField.

      Returns:
      An enumeration of the fields for this DSData.
    • iterator

      Iterator<DSField> iterator()

      Returns an iterator of the fields for this DSData. Each field is represented by a DSField.

      Specified by:
      iterator in interface Iterable<DSField>
      Returns:
      An iterator of the fields for this DSData.
    • getFieldByFieldNumber

      DSField getFieldByFieldNumber(int fieldNumber)

      Gets the first occurrence of the field with the specified field number.

      If there are three occurrences of the field 12, with values "75", "75.5" and "75.25", then calling getFieldByFieldNumber(12) will return the field that contains the value "75".

      This is equivalent to calling getFieldByFieldNumber(fieldNumber, 0).

      Parameters:
      fieldNumber - The field identifier number.
      Returns:
      The field for the first occurrence of the field number, or null if the specified field is not found.
    • getFieldByFieldNumber

      DSField getFieldByFieldNumber(int fieldNumber, int occurrence)

      Gets the specified occurrence of the field with the specified field number.

      If there are three occurrences of the field 12, with values "75", "75.5" and "75.25", then calling getFieldByFieldNumber(12, 2) will return the field that contains the value "75.25".

      Parameters:
      fieldNumber - The field identifier number.
      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 number, or null if the specified field is not found.
    • removeField

      boolean removeField(DSField dsField)

      Removes the specified field from the DSData.

      Parameters:
      dsField - The field to remove.
      Returns:
      true if the field was successfully removed, or false if the field has already been removed.
    • updateData

      boolean updateData(int fieldNumber, String value, int occurrence)

      Sets the value of the specified occurrence for a particular field number.

      If there are three occurrences of the field 12, "75", "75.5" and "75.25", then calling updateData(12, "76", 2) will change occurrences to be "75", "75.5" and "76".

      Parameters:
      fieldNumber - The field identifier number.
      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:
      ArrayIndexOutOfBoundsException - If there are fewer occurrences of the field than the specified occurrence to update.
    • updateData

      boolean updateData(int fieldNumber, String value)

      Sets the value of the first occurrence for the specified field number.

      If there are three occurrences of the field 12, "75", "75.5" and "75.25", then calling updateData(12, "76") will change occurrences to be "76", "75.5" and "75.25".

      This is equivalent to calling updateData(fieldNumber, value, 0).

      Parameters:
      fieldNumber - The field identifier number.
      value - The new value for the field.
      Returns:
      true if the value was successfully set for the specified field, otherwise false.
    • clearFields

      void clearFields()

      Removes all the fields.

    • addData

      void addData(DSField dsField)

      Adds the DSField.

      Parameters:
      dsField - the DSField to be added.
    • addData

      void addData(int fieldNumber, String value)

      Adds the String value for the specified field number.

      Parameters:
      fieldNumber - The field identifier number.
      value - The value to be stored in the field.
    • addData

      void addData(int fieldNumber, char value)

      Adds the String representation of the character value for the specified field number.

      Parameters:
      fieldNumber - The field identifier number.
      value - The value to be stored in the field.
    • addData

      void addData(int fieldNumber, char[] value)

      Adds the String representation of the character array for the specified field number.

      Parameters:
      fieldNumber - The field identifier number.
      value - The value to be stored in the field.
    • addData

      void addData(int fieldNumber, double value)

      Adds the String representation of the double value for the specified field number.

      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 addData(int, String) method.

      Parameters:
      fieldNumber - The field identifier number.
      value - The value to be stored in the field.
    • addData

      void addData(int fieldNumber, float value)

      Adds the String representation of the float value for the specified field number.

      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 addData(int, String) method.

      Parameters:
      fieldNumber - The field identifier number.
      value - The value to be stored in the field.
    • addData

      void addData(int fieldNumber, int value)

      Adds the String representation of the integer value for the specified field number.

      Parameters:
      fieldNumber - The field identifier number.
      value - The value to be stored in the field.
    • addData

      void addData(int fieldNumber, long value)

      Adds the String representation of the long value for the specified field number.

      Parameters:
      fieldNumber - The field identifier number.
      value - The value to be stored in the field.
    • addBinaryData

      void addBinaryData(int fieldNumber, byte value)

      Adds the byte value for the specified field number. This method Base64 encodes the value before storing it.

      Parameters:
      fieldNumber - The field identifier number.
      value - The byte value to be stored in the field.
    • addBinaryData

      void addBinaryData(int fieldNumber, short value)

      Adds the short value for the specified field number. This method Base64 encodes the value before storing it.

      Parameters:
      fieldNumber - The field identifier number.
      value - The value to be stored in the field.
    • addBinaryData

      void addBinaryData(int fieldNumber, int value)

      Adds the integer value for the specified field number. This method Base64 encodes the value before storing it.

      Parameters:
      fieldNumber - The field identifier number.
      value - The value to be stored in the field.
    • addBinaryData

      void addBinaryData(int fieldNumber, long value)

      Adds the long value for the specified field number. This method Base64 encodes the value before storing it.

      Parameters:
      fieldNumber - The field identifier number.
      value - The value to be stored in the field.
    • addBinaryData

      void addBinaryData(int fieldNumber, float value)

      Adds the float value for the specified field number. This method Base64 encodes the value before storing it.

      Parameters:
      fieldNumber - The field identifier number.
      value - The value to be stored in the field.
    • addBinaryData

      void addBinaryData(int fieldNumber, double value)

      Adds the double value for the specified field number. This method Base64 encodes the value before storing it.

      Parameters:
      fieldNumber - The field identifier number.
      value - The value to be stored in the field.
    • addBinaryData

      void addBinaryData(int fieldNumber, byte[] value)

      Adds the byte array value for the specified field number. This method Base64 encodes the value before storing it.

      Parameters:
      fieldNumber - The field identifier number.
      value - The array of bytes to be stored in the field.
    • addBinaryData

      void addBinaryData(int fieldNumber, String value)

      Adds the String value for the specified field number. This method Base64 encodes the value before storing it.

      Parameters:
      fieldNumber - The field identifier number.
      value - The value to be stored in the field.