public class TransformerDataImpl extends Object implements TransformerData
Implementation of the TransformerData interface.
Modifier and Type | Field and Description |
---|---|
protected int |
modCount
Counts the number of times a new field is added to, or a field
is removed from, the update.
|
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
MAINTAIN_TIMESTAMP, NO_FLAGS, NO_PERSISTENCE, PUBLISH_TO_PEERS, SILENT_SEND, STORE_IN_CACHE
Modifier | Constructor and 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.
|
Modifier and Type | Method and 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(DSField dsField)
Adds the DSField.
|
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.
|
protected void |
addString(int fieldNumber,
String value)
Adds the String value for the specified field number with
the default flag 0.
|
protected void |
addString(int fieldNumber,
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.
|
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.
|
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.
|
String |
getSubject()
Gets this object's subject.
|
int |
getType()
Gets this object's type.
|
Enumeration<?> |
getValues()
Returns as
Enumeration of Strings
indicating the field values . |
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(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,
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 the specified
field number.
|
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.
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).
dsDataPointer
- The pointer to the C ds_data struct that
holds the state information for the update.protected TransformerDataImpl(long dsDataPointer, boolean freeDsDataPointer)
Constructor is protected to prevent a TransformerData being instantiated except by the DSFactory class.
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.public long getDSDataPointer()
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.
getDSDataPointer
in interface TransformerData
public void setFlags(int flags)
DSData
Sets the flags to be sent with this packet.
The flags that can be set are:
DSData.F_CREATEOBJECT
DSData.F_CREATEPARENT
DSData.F_IMAGE
DSData.F_NONACTIVE
DSData.F_AUTH_UPDATE
DSData.F_FILTER_TYPE2
DSData.F_FILTER_TYPE3
DSData.F_CLEAR_TYPE2
DSData.F_CLEAR_TYPE3
Multiple flags can be set by bitwise ORing them together (e.g. F_CREATEOBJECT|F_CREATEPARENT|F_IMAGE).
public int getFlags()
DSData
Gets the flags that are going to be sent with this packet.
public void setType(int type)
DSData
Sets the object type of this DSData to the specified value.
Valid object types are:
public void setType(ObjectType objectType)
TransformerData
Sets the update's object type to the specified type.
setType
in interface TransformerData
objectType
- The type of object.public int getType()
DSData
Gets this object's type.
public ObjectType getObjectType()
TransformerData
Gets the update's object type.
getObjectType
in interface TransformerData
public int getSequenceNumber()
TransformerData
Gets the update's sequence number.
getSequenceNumber
in interface TransformerData
public void setSubject(String subject)
DSData
Sets this object's subject.
setSubject
in interface DSData
subject
- The subject, or object, name.public String getSubject()
DSData
Gets this object's subject.
getSubject
in interface DSData
public int count()
DSData
Gets the number of fields that are present in this packet.
public Enumeration<DSField> elements()
DSData
Returns an enumeration of the fields for this DSData. Each
field is represented by a DSField
.
public Iterator<DSField> iterator()
DSData
Returns an iterator of the fields for this DSData. Each field
is represented by a DSField
.
public Enumeration<?> getKeys()
DSData
Returns as Enumeration
of Integers
indicating the field number .
public Enumeration<?> getValues()
DSData
Returns as Enumeration
of Strings
indicating the field values .
public DSField getFieldByFieldNumber(int fieldNumber)
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).
getFieldByFieldNumber
in interface DSData
fieldNumber
- The field identifier number.public DSField getFieldByFieldNumber(int fieldNumber, int occurrence)
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".
getFieldByFieldNumber
in interface DSData
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.public boolean removeField(DSField dsField)
DSData
Removes the specified field from the DSData.
removeField
in interface DSData
dsField
- The field to remove.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.NullPointerException
- If the dsField argument is null.public boolean updateData(int fieldNumber, 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".
updateData
in interface DSData
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.NullPointerException
- If the value argument is null.public boolean updateData(int fieldNumber, String value)
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).
updateData
in interface DSData
fieldNumber
- The field identifier number.value
- The new value for the field.NullPointerException
- If the value argument is null.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.
merge
in interface TransformerData
transformerDataToMerge
- The TransformerData from which the
fields should be merged from.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).
send
in interface DSPacket
IllegalStateException
- If the update has already been sent.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:
send
in interface TransformerData
flags
- The flags that should be passed to the Transformer
core to tell it how to process the update.IllegalStateException
- If the update has already been sent.public void sendDirect()
Invokes the send
method.
sendDirect
in interface DSPacket
public void sendToPeer(int peer)
Invokes the send
method.
sendToPeer
in interface DSPacket
peer
- the DataSource
peer.public byte[] toBytes()
Returns null.
toBytes
in interface DSSerializable
null
.public void clearFields()
DSData
Removes all the fields.
clearFields
in interface DSData
public void addData(int fieldNumber, String value)
DSData
Adds the String value for the specified field number.
addData
in interface DSData
fieldNumber
- The field identifier number.value
- The value to be stored in the field.NullPointerException
- If the value argument is null.public void addData(int fieldNumber, char value)
DSData
Adds the String representation of the character value for the specified field number.
public void addData(int fieldNumber, char[] value)
DSData
Adds the String representation of the character array for the specified field number.
addData
in interface DSData
fieldNumber
- The field identifier number.value
- The value to be stored in the field.NullPointerException
- If the value argument is null.public void addData(int fieldNumber, double value)
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.
public void addData(int fieldNumber, float value)
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.
public void addData(int fieldNumber, int value)
DSData
Adds the String representation of the integer value for the specified field number.
public void addData(int fieldNumber, long value)
DSData
Adds the String representation of the long value for the specified field number.
public void addData(DSField dsField)
DSData
Adds the DSField.
public void addBinaryData(int fieldNumber, byte value)
DSData
Adds the byte value for the specified field number. This method Base64 encodes the value before storing it.
addBinaryData
in interface DSData
fieldNumber
- The field identifier number.value
- The byte value to be stored in the field.public void addBinaryData(int fieldNumber, short value)
DSData
Adds the short value for the specified field number. This method Base64 encodes the value before storing it.
addBinaryData
in interface DSData
fieldNumber
- The field identifier number.value
- The value to be stored in the field.public void addBinaryData(int fieldNumber, int value)
DSData
Adds the integer value for the specified field number. This method Base64 encodes the value before storing it.
addBinaryData
in interface DSData
fieldNumber
- The field identifier number.value
- The value to be stored in the field.public void addBinaryData(int fieldNumber, long value)
DSData
Adds the long value for the specified field number. This method Base64 encodes the value before storing it.
addBinaryData
in interface DSData
fieldNumber
- The field identifier number.value
- The value to be stored in the field.public void addBinaryData(int fieldNumber, float value)
DSData
Adds the float value for the specified field number. This method Base64 encodes the value before storing it.
addBinaryData
in interface DSData
fieldNumber
- The field identifier number.value
- The value to be stored in the field.public void addBinaryData(int fieldNumber, double value)
DSData
Adds the double value for the specified field number. This method Base64 encodes the value before storing it.
addBinaryData
in interface DSData
fieldNumber
- The field identifier number.value
- The value to be stored in the field.public void addBinaryData(int fieldNumber, byte[] value)
DSData
Adds the byte array value for the specified field number. This method Base64 encodes the value before storing it.
addBinaryData
in interface DSData
fieldNumber
- The field identifier number.value
- The array of bytes to be stored in the field.NullPointerException
- If the value argument is null.public void addBinaryData(int fieldNumber, String value)
DSData
Adds the String value for the specified field number. This method Base64 encodes the value before storing it.
addBinaryData
in interface DSData
fieldNumber
- The field identifier number.value
- The value to be stored in the field.NullPointerException
- If the value argument is null.protected void addString(int fieldNumber, String value)
Adds the String value for the specified field number with the default flag 0.
fieldNumber
- The field identifier number.value
- The value to be stored in the field.NullPointerException
- If the value argument is null.protected void addString(int fieldNumber, String value, int flags)
Adds the String value for the specified field number with the specified flags.
fieldNumber
- The field identifier number.value
- The value to be stored in the field.flags
- The flags to apply to the field.NullPointerException
- If the value argument is null.Please send bug reports and comments to Caplin support