Class TransformerDataImpl

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected TransformerDataImpl​(long dsDataPointer)
      Constructor is protected to prevent a TransformerData being instantiated except by the DSFactory class.
      protected TransformerDataImpl​(long dsDataPointer, boolean freeDsDataPointer)
      Constructor is protected to prevent a TransformerData being instantiated except by the DSFactory class.
    • Method Summary

      All Methods Instance Methods Concrete 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, java.lang.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, java.lang.String value)
      Adds the String value for the specified field number.
      void addData​(DSField dsField)
      Adds the DSField.
      protected void addString​(int fieldNumber, java.lang.String value)
      Adds the String value for the specified field number with the default flag 0.
      protected void addString​(int fieldNumber, java.lang.String value, int flags)
      Adds the String value for the specified field number with the specified flags.
      void clearFields()
      Removes all the fields.
      int count()
      Gets the number of fields that are present in this packet.
      java.util.Enumeration<DSField> elements()
      Returns an enumeration of the fields for this DSData.
      void finalize()
      Frees the memory for the underlying C ds_data struct stored within the Transformer core.
      long getDSDataPointer()
      Gets the pointer to the C ds_data struct that holds the state information for the update.
      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.
      java.util.Enumeration<?> getKeys()
      Returns as Enumeration of Integers indicating the field number .
      ObjectType getObjectType()
      Gets the update's object type.
      int getSequenceNumber()
      Gets the update's sequence number.
      java.lang.String getSubject()
      Gets this object's subject.
      int getType()
      Gets this object's type.
      java.util.Enumeration<?> getValues()
      Returns as Enumeration of Strings indicating the field values .
      java.util.Iterator<DSField> iterator()
      Returns an iterator of the fields for this DSData.
      int merge​(TransformerData transformerDataToMerge)
      Merges the fields from the specified TransformerData with those in this TransformerData.
      boolean removeField​(DSField dsField)
      Removes the specified field from the DSData.
      void send()
      Sends the update to the Transformer core.
      void send​(int flags)
      Sends the update to the Transformer core.
      void sendDirect()
      Invokes the send method.
      void sendToPeer​(int peer)
      Invokes the send method.
      void setFlags​(int flags)
      Sets the flags to be sent with this packet.
      void setSubject​(java.lang.String subject)
      Sets this object's subject.
      void setType​(int type)
      Sets the object type of this DSData to the specified value.
      void setType​(ObjectType objectType)
      Sets the update's object type to the specified type.
      byte[] toBytes()
      Returns null.
      boolean updateData​(int fieldNumber, java.lang.String value)
      Sets the value of the first occurrence for the specified field number.
      boolean updateData​(int fieldNumber, java.lang.String value, int occurrence)
      Sets the value of the specified occurrence for the specified field number.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • modCount

        protected int modCount

        Counts the number of times a new field is added to, or a field is removed from, the update. This is used by the FieldIterator to determine whether a concurrent modification has been made.

    • Constructor Detail

      • TransformerDataImpl

        protected TransformerDataImpl​(long dsDataPointer)

        Constructor is protected to prevent a TransformerData being instantiated except by the DSFactory class.

        A TransformerData created with this constructor will be responsible for freeing the memory for the underlying C ds_data struct.

        This is equivalent to calling TransformerData(dsDataPointer, true).

        Parameters:
        dsDataPointer - The pointer to the C ds_data struct that holds the state information for the update.
      • TransformerDataImpl

        protected TransformerDataImpl​(long dsDataPointer,
                                      boolean freeDsDataPointer)

        Constructor is protected to prevent a TransformerData 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 TransformerData is responsible for freeing up the memory for the C ds_data struct, or false if the Transformer core is responsible.
    • Method Detail

      • getDSDataPointer

        public long getDSDataPointer()
        Description copied from interface: TransformerData

        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.

        Specified by:
        getDSDataPointer in interface TransformerData
        Returns:
        The pointer to the ds_data struct.
      • getFlags

        public int getFlags()
        Description copied from interface: DSData

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

        Specified by:
        getFlags in interface DSData
        Returns:
        The flags that are going to be sent.
      • setType

        public void setType​(ObjectType objectType)
        Description copied from interface: TransformerData

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

        Specified by:
        setType in interface TransformerData
        Parameters:
        objectType - The type of object.
      • getType

        public int getType()
        Description copied from interface: DSData

        Gets this object's type.

        Specified by:
        getType in interface DSData
        Returns:
        The object's type.
      • getObjectType

        public ObjectType getObjectType()
        Description copied from interface: TransformerData

        Gets the update's object type.

        Specified by:
        getObjectType in interface TransformerData
        Returns:
        The ObjectType that represents the object type for this update.
      • getSequenceNumber

        public int getSequenceNumber()
        Description copied from interface: TransformerData

        Gets the update's sequence number.

        Specified by:
        getSequenceNumber in interface TransformerData
        Returns:
        the sequence number of the update.
      • setSubject

        public void setSubject​(java.lang.String subject)
        Description copied from interface: DSData

        Sets this object's subject.

        Specified by:
        setSubject in interface DSData
        Parameters:
        subject - The subject, or object, name.
      • getSubject

        public java.lang.String getSubject()
        Description copied from interface: DSData

        Gets this object's subject.

        Specified by:
        getSubject in interface DSData
        Returns:
        The subject, or object, name.
      • count

        public int count()
        Description copied from interface: DSData

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

        Specified by:
        count in interface DSData
        Returns:
        The number of fields in this packet.
      • elements

        public java.util.Enumeration<DSField> elements()
        Description copied from interface: DSData

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

        Specified by:
        elements in interface DSData
        Returns:
        An enumeration of the fields for this DSData.
      • iterator

        public java.util.Iterator<DSField> iterator()
        Description copied from interface: DSData

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

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

        public java.util.Enumeration<?> getKeys()
        Description copied from interface: DSData

        Returns as Enumeration of Integers indicating the field number .

        Specified by:
        getKeys in interface DSData
        Returns:
        null.
      • getValues

        public java.util.Enumeration<?> getValues()
        Description copied from interface: DSData

        Returns as Enumeration of Strings indicating the field values .

        Specified by:
        getValues in interface DSData
        Returns:
        null.
      • getFieldByFieldNumber

        public DSField getFieldByFieldNumber​(int fieldNumber)
        Description copied from interface: DSData

        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).

        Specified by:
        getFieldByFieldNumber in interface DSData
        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

        public DSField getFieldByFieldNumber​(int fieldNumber,
                                             int occurrence)
        Description copied from interface: DSData

        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".

        Specified by:
        getFieldByFieldNumber in interface DSData
        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

        public boolean removeField​(DSField dsField)
        Description copied from interface: DSData

        Removes the specified field from the DSData.

        Specified by:
        removeField in interface DSData
        Parameters:
        dsField - The field to remove.
        Returns:
        true if the field was successfully removed, or false if the field has already been removed.
        Throws:
        java.util.ConcurrentModificationException - If the any modifications have been made to the fields since the specified field was obtained. This prevents any unexpected behaviour from this method.
        java.lang.NullPointerException - If the dsField argument is null.
      • updateData

        public boolean updateData​(int fieldNumber,
                                  java.lang.String value,
                                  int occurrence)

        Sets the value of the specified occurrence for the specified field number. The occurrence parameter is ignored in this version.

        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 "76", "75.5" and "75.25".

        Specified by:
        updateData in interface DSData
        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:
        Always true. If the specified field does not exist, it will be added.
        Throws:
        java.lang.NullPointerException - If the value argument is null.
      • updateData

        public boolean updateData​(int fieldNumber,
                                  java.lang.String value)
        Description copied from interface: DSData

        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).

        Specified by:
        updateData in interface DSData
        Parameters:
        fieldNumber - The field identifier number.
        value - The new value for the field.
        Returns:
        Always true. If the specified field does not exist, it will be added.
        Throws:
        java.lang.NullPointerException - If the value argument is null.
      • merge

        public 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.

        Specified by:
        merge in interface TransformerData
        Parameters:
        transformerDataToMerge - The TransformerData from which the fields should be merged from.
        Returns:
        The number of fields that were updated.
      • send

        public void send()

        Sends the update to the Transformer core. The data will be cached by the core and will be published to the DataSource peers, as well as to any Transformer modules that have subscribed to it.

        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.

        This method is equivalent to calling send(STORE_IN_CACHE|PUBLISH_TO_PEERS).

        Specified by:
        send in interface DSPacket
        Throws:
        java.lang.IllegalStateException - If the update has already been sent.
      • send

        public 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
        Specified by:
        send in interface TransformerData
        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.
      • sendDirect

        public void sendDirect()

        Invokes the send method.

        Specified by:
        sendDirect in interface DSPacket
      • sendToPeer

        public void sendToPeer​(int peer)

        Invokes the send method.

        Specified by:
        sendToPeer in interface DSPacket
        Parameters:
        peer - the DataSource peer.
      • toBytes

        public byte[] toBytes()

        Returns null.

        Specified by:
        toBytes in interface DSSerializable
        Returns:
        null.
      • clearFields

        public void clearFields()
        Description copied from interface: DSData

        Removes all the fields.

        Specified by:
        clearFields in interface DSData
      • addData

        public void addData​(int fieldNumber,
                            java.lang.String value)
        Description copied from interface: DSData

        Adds the String value for the specified field number.

        Specified by:
        addData in interface DSData
        Parameters:
        fieldNumber - The field identifier number.
        value - The value to be stored in the field.
        Throws:
        java.lang.NullPointerException - If the value argument is null.
      • addData

        public void addData​(int fieldNumber,
                            char value)
        Description copied from interface: DSData

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

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

        public void addData​(int fieldNumber,
                            char[] value)
        Description copied from interface: DSData

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

        Specified by:
        addData in interface DSData
        Parameters:
        fieldNumber - The field identifier number.
        value - The value to be stored in the field.
        Throws:
        java.lang.NullPointerException - If the value argument is null.
      • addData

        public void addData​(int fieldNumber,
                            double value)
        Description copied from interface: DSData

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

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

        public void addData​(int fieldNumber,
                            float value)
        Description copied from interface: DSData

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

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

        public void addData​(int fieldNumber,
                            int value)
        Description copied from interface: DSData

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

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

        public void addData​(int fieldNumber,
                            long value)
        Description copied from interface: DSData

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

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

        public void addData​(DSField dsField)
        Description copied from interface: DSData

        Adds the DSField.

        Specified by:
        addData in interface DSData
        Parameters:
        dsField - the DSField to be added.
      • addBinaryData

        public void addBinaryData​(int fieldNumber,
                                  byte value)
        Description copied from interface: DSData

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

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

        public void addBinaryData​(int fieldNumber,
                                  short value)
        Description copied from interface: DSData

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

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

        public void addBinaryData​(int fieldNumber,
                                  int value)
        Description copied from interface: DSData

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

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

        public void addBinaryData​(int fieldNumber,
                                  long value)
        Description copied from interface: DSData

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

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

        public void addBinaryData​(int fieldNumber,
                                  float value)
        Description copied from interface: DSData

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

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

        public void addBinaryData​(int fieldNumber,
                                  double value)
        Description copied from interface: DSData

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

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

        public void addBinaryData​(int fieldNumber,
                                  byte[] value)
        Description copied from interface: DSData

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

        Specified by:
        addBinaryData in interface DSData
        Parameters:
        fieldNumber - The field identifier number.
        value - The array of bytes to be stored in the field.
        Throws:
        java.lang.NullPointerException - If the value argument is null.
      • addBinaryData

        public void addBinaryData​(int fieldNumber,
                                  java.lang.String value)
        Description copied from interface: DSData

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

        Specified by:
        addBinaryData in interface DSData
        Parameters:
        fieldNumber - The field identifier number.
        value - The value to be stored in the field.
        Throws:
        java.lang.NullPointerException - If the value argument is null.
      • addString

        protected void addString​(int fieldNumber,
                                 java.lang.String value)

        Adds the String value for the specified field number with the default flag 0.

        Parameters:
        fieldNumber - The field identifier number.
        value - The value to be stored in the field.
        Throws:
        java.lang.NullPointerException - If the value argument is null.
      • addString

        protected void addString​(int fieldNumber,
                                 java.lang.String value,
                                 int flags)

        Adds the String value for the specified field number with the specified flags.

        Parameters:
        fieldNumber - The field identifier number.
        value - The value to be stored in the field.
        flags - The flags to apply to the field.
        Throws:
        java.lang.NullPointerException - If the value argument is null.
      • finalize

        public void finalize()

        Frees the memory for the underlying C ds_data struct stored within the Transformer core. If the send(int) method has been invoked, this method does nothing.

        Overrides:
        finalize in class java.lang.Object