Interface DSData

  • All Superinterfaces:
    DSPacket, DSSerializable, Iterable<DSField>
    All Known Subinterfaces:
    DSContainer, DSNews, DSPage, DSPermission, DSRecord, DSStory

    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 int CONTAINER_TYPE
      A Container object type.
      static int F_AUTH_UPDATE
      Used to indicate to a Liberator that this update should be checked for client access using the auth module.
      static 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.
      static int F_CHANGEDFIELDS
      Indicates that this object should be delta compressed before sending on to the clients.
      static int F_CLEAR_PERMISSIONS
      Clear all permission entries for this object.
      static int F_CLEAR_TYPE2
      Clear all type 2 entries for this object.
      static int F_CLEAR_TYPE3
      Clear all type 3 entries for this object.
      static int F_CREATEOBJECT
      Creates this object if it does not exist.
      static int F_CREATEPARENT
      Creates the parent directory if it does not exist.
      static int F_DELETE_PERMISSION
      Delete any permission entries for this object with the same value as the first field in the update.
      static int F_FILTER_TYPE2
      Clear any type 2 entries for this object with the same value as the first field in the update.
      static int F_FILTER_TYPE3
      Clear all type 3 entries for this object with the same value as the first field in the update.
      static int F_IMAGE
      Indicates this packet is an image and not an update.
      static int F_NONACTIVE
      Indicates that this object should be treated in a non-active (ie broadcast) manner.
      static int GENERIC_TYPE
      A Generic Type object type.
      static int NEWS_TYPE
      A News Headline object type.
      static int PAGE_TYPE
      A Page object type.
      static int PERMISSION_TYPE
      A Permission object type.
      static int RECORD_TYPE
      A Record object type.
      static int STORY_TYPE
      A News Story object type.
      static int TYPE2_RECORD_TYPE
      A Type 2 Record object type.
      static int TYPE3_RECORD_TYPE
      A Type 3 Record object type.
      static int UNKNOWN_TYPE
      An uknown type.
    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      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 clearFields()
      Removes all the fields.
      int count()
      Gets the number of fields that are present in this packet.
      Enumeration elements()
      Returns an enumeration of the fields for this DSData.
      DSField getFieldByFieldNumber​(int fieldNumber)
      Gets the first occurrence of the field with the specified field number.
      DSField getFieldByFieldNumber​(int fieldNumber, int occurrence)
      Gets the specified occurrence of the field with the specified field number.
      int getFlags()
      Gets the flags that are going to be sent with this packet.
      Enumeration getKeys()
      Deprecated.
      use elements() or iterator().
      String getSubject()
      Gets this object's subject.
      int getType()
      Gets this object's type.
      Enumeration getValues()
      Deprecated.
      use elements() or iterator().
      Iterator<DSField> iterator()
      Returns an iterator of the fields for this DSData.
      boolean removeField​(DSField dsField)
      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.
    • Field Detail

      • F_CREATEOBJECT

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

        static final int F_CREATEPARENT
        Creates the parent directory if it does not exist.
        See Also:
        Constant Field Values
      • 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:
        Constant Field Values
      • 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:
        Constant Field Values
      • 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:
        Constant Field Values
      • 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:
        Constant Field Values
      • 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:
        Constant Field Values
      • 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:
        Constant Field Values
      • 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:
        Constant Field Values
      • 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:
        Constant Field Values
      • 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:
        Constant Field Values
      • 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:
        Constant Field Values
      • 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:
        Constant Field Values
      • UNKNOWN_TYPE

        static final int UNKNOWN_TYPE
        An uknown type. Used by CacheManager.
        See Also:
        Constant Field Values
      • TYPE2_RECORD_TYPE

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

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

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

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

        static final int GENERIC_TYPE
        A Generic Type object type.
        See Also:
        Constant Field Values
    • Method Detail

      • getFlags

        int getFlags()

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

        Returns:
        The flags that are going to be sent.
      • 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()
        Deprecated.
        use elements() or iterator().

        Returns as Enumeration of Integers indicating the field number .

        Returns:
        the Enumeration.
      • getValues

        Enumeration getValues()
        Deprecated.
        use elements() or iterator().

        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.