Interface DSData
- All Superinterfaces:
DSPacket
,DSSerializable
,Iterable<DSField>
- All Known Subinterfaces:
DSContainer
,DSNews
,DSPage
,DSPermission
,DSRecord
,DSStory
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
Modifier and TypeFieldDescriptionstatic 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 TypeMethodDescriptionvoid
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
Adds the String value for the specified field number.void
Adds the DSField.void
Removes all the fields.int
count()
Gets the number of fields that are present in this packet.elements()
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
getFlags()
Gets the flags that are going to be sent with this packet.getKeys()
Deprecated.Gets this object's subject.int
getType()
Gets this object's type.Deprecated.useelements()
oriterator()
.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 thisDSData
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.datasource.interfaces.DSPacket
send, sendDirect, sendToPeer
Methods inherited from interface com.caplin.datasource.interfaces.DSSerializable
toBytes
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
F_CREATEOBJECT
static final int F_CREATEOBJECTCreates this object if it does not exist.- See Also:
-
F_CREATEPARENT
static final int F_CREATEPARENTCreates the parent directory if it does not exist.- See Also:
-
F_IMAGE
static final int F_IMAGEIndicates 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_NONACTIVEIndicates 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_UPDATEUsed to indicate to a Liberator that this update should be checked for client access using the auth module. Currently only applicable toNEWS_TYPE
objects.- See Also:
-
F_CHANGEDFIELDS
static final int F_CHANGEDFIELDSIndicates 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_TYPE2Clear 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_TYPE3Clear 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_TYPE2Clear 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_TYPE3Clear 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_AUTHGLOBALIndicates 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_PERMISSIONDelete 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_PERMISSIONSClear 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_TYPEAn uknown type. Used by CacheManager.- See Also:
-
PAGE_TYPE
static final int PAGE_TYPEA Page object type.- See Also:
-
RECORD_TYPE
static final int RECORD_TYPEA Record object type.- See Also:
-
NEWS_TYPE
static final int NEWS_TYPEA News Headline object type.- See Also:
-
STORY_TYPE
static final int STORY_TYPEA News Story object type.- See Also:
-
TYPE2_RECORD_TYPE
static final int TYPE2_RECORD_TYPEA Type 2 Record object type.- See Also:
-
TYPE3_RECORD_TYPE
static final int TYPE3_RECORD_TYPEA Type 3 Record object type.- See Also:
-
CONTAINER_TYPE
static final int CONTAINER_TYPEA Container object type.- See Also:
-
PERMISSION_TYPE
static final int PERMISSION_TYPEA Permission object type.- See Also:
-
GENERIC_TYPE
static final int GENERIC_TYPEA 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:
F_CREATEOBJECT
F_CREATEPARENT
F_IMAGE
F_NONACTIVE
F_AUTH_UPDATE
F_FILTER_TYPE2
F_FILTER_TYPE3
F_CLEAR_TYPE2
F_CLEAR_TYPE3
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
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.useelements()
oriterator()
.Returns as
Enumeration
ofIntegers
indicating the field number .- Returns:
- the
Enumeration
.
-
getValues
Enumeration getValues()Deprecated.useelements()
oriterator()
.Returns as
Enumeration
ofStrings
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
Returns an iterator of the fields for this DSData. Each field is represented by a
DSField
. -
getFieldByFieldNumber
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
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
Removes the specified field from the DSData.
- Parameters:
dsField
- The field to remove.- Returns:
true
if the field was successfully removed, orfalse
if the field has already been removed.
-
updateData
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, otherwisefalse
.- Throws:
ArrayIndexOutOfBoundsException
- If there are fewer occurrences of the field than the specified occurrence to update.
-
updateData
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, otherwisefalse
.
-
clearFields
void clearFields()Removes all the fields.
-
addData
Adds the DSField.
- Parameters:
dsField
- the DSField to be added.
-
addData
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
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.
-
elements()
oriterator()
.