Interface DataCache
-
- All Superinterfaces:
TransformerFlags
public interface DataCache extends TransformerFlags
Allows a Transformer module to retrieve or remove data from the Transformer core's cache.
-
-
Field Summary
Fields Modifier and Type Field Description static int
TIME_UNAVAILABLE
Value returned bygetLastUpdateTime(java.lang.String)
if the last update time for the specified object name was unavailable.-
Fields inherited from interface com.caplin.transformer.module.TransformerFlags
MAINTAIN_TIMESTAMP, NO_FLAGS, NO_PERSISTENCE, PUBLISH_TO_PEERS, SILENT_SEND, STORE_IN_CACHE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
deleteType2(java.lang.String objectName)
Deletes all the type 2 data from the Transformer core for the specified object name.void
deleteType2(java.lang.String objectName, java.lang.String type2Index)
Deletes the type 2 entry from the Transformer core for the specified object name and type 2 index.void
deleteType2(java.lang.String objectName, java.lang.String type2Index, int indexFieldNumber)
Deletes the type 2 entry from the Transformer core for the specified object name, type 2 index and index field number.TransformerData
get(java.lang.String objectName)
Gets the data cached within the Transformer core for the specified object name.java.lang.String
getField(java.lang.String objectName, int fieldNumber)
Gets the latest value from the Transformer core for the specified object name and field number.java.lang.String
getField(java.lang.String objectName, java.lang.String fieldName)
Gets the latest value from the Transformer core for the specified object and field names.long
getLastUpdateTime(java.lang.String objectName)
Gets the time the last update was received by the Transformer core for the specified object name.java.lang.String[]
getObjectNames(java.lang.String objectNamePattern)
Gets an array of object names that were found in the Transformer core cache that match the specified object name pattern.ObjectType
getObjectType(java.lang.String objectName)
Gets the type code for the object with the specified name from the Transformer core cache.TransformerData
getPermission(java.lang.String objectName, java.lang.String key)
Gets the permission data cached within the Transformer core for the specified object name and key.java.lang.String[]
getPermissionKeys(java.lang.String objectName)
Gets a list of permission keys that are available from the Transformer core cache for the specified object name.ObjectStatus
getStatus(java.lang.String objectName)
Gets the current status for the object with the specified name from the Transformer core cache.TransformerData
getType2(java.lang.String objectName, java.lang.String type2Index)
Gets the type 2 data cached within the Transformer core for the specified object name and type 2 index.java.lang.String[]
getType2Indices(java.lang.String objectName)
Gets a list of type 2 indices that are available from the Transformer core cache for the specified object name.java.lang.String[]
getType3Field(java.lang.String objectName, int fieldNumber)
Gets an array of values for the specified object name and type 3 field number.void
put(java.lang.String objectName)
Sets the flags for the specified object to STORE_IN_CACHE and PUBLISH_TO_PEERS.void
put(java.lang.String objectName, int flags)
Updates the flags for the specified object.void
remove(java.lang.String objectName)
Removes the object with the specified name from the Transformer core cache.void
setStatus(java.lang.String objectName, ObjectStatus status)
Set the status of an object within the Transformer cache.
-
-
-
Field Detail
-
TIME_UNAVAILABLE
static final int TIME_UNAVAILABLE
Value returned by
getLastUpdateTime(java.lang.String)
if the last update time for the specified object name was unavailable.- See Also:
- Constant Field Values
-
-
Method Detail
-
put
void put(java.lang.String objectName) throws DataCachePutException
Sets the flags for the specified object to STORE_IN_CACHE and PUBLISH_TO_PEERS. If an object with the specified object name does not exist in the Transformer's cache, then a new object will be created with that name, and with the STORE_IN_CACHE and PUBLISH_TO_PEERS flags set.
Calling this method is equivalent to calling put(objectName, STORE_IN_CACHE|PUBLISH_TO_PEERS).
- Parameters:
objectName
- The name of the object. This must be an exact object name - it cannot be an object name pattern.- Throws:
DataCachePutException
- Thrown if the put failed.
-
put
void put(java.lang.String objectName, int flags) throws DataCachePutException
Updates the flags for the specified object. If an object with the specified name does not exist in the Transformer's cache, then a new object will be created with that name and the specified flags.
The possible flags are:
- Parameters:
objectName
- The name of the object. This must be an exact object name - it cannot be an object name pattern.flags
- The flags the object is going to have set.- Throws:
DataCachePutException
- Thrown if the put failed.java.lang.NullPointerException
- If the objectName argument is null.
-
get
TransformerData get(java.lang.String objectName)
Gets the data cached within the Transformer core for the specified object name.
- Parameters:
objectName
- The name of the object. This must be an exact object name - it cannot be an object name pattern.- Returns:
- The TransformerData that represents the data that is cached for the specified object name, or null if an object with that name was not found in the cache.
- Throws:
java.lang.NullPointerException
- If the objectName argument is null.
-
getLastUpdateTime
long getLastUpdateTime(java.lang.String objectName)
Gets the time the last update was received by the Transformer core for the specified object name.
- Parameters:
objectName
- The name of the object. This must be an exact object name - it cannot be an object name pattern.- Returns:
- The time the last update for the specified object name was received by the Transformer core. This is represented as the number of seconds since 1st January 1970, 00:00:00. TIME_UNAVAILABLE will be returned if the object does not exist.
- Throws:
java.lang.NullPointerException
- If the objectName argument is null.
-
getType2
TransformerData getType2(java.lang.String objectName, java.lang.String type2Index)
Gets the type 2 data cached within the Transformer core for the specified object name and type 2 index.
The table below shows some sample type 2 data that may be cached for the object /LO/CAPLIN. In this case, the MarketMakerId field contains the type 2 indices. To get the data for the MarketMaker GBN, the Transformer module should call getType2("/LO/CAPLIN", "GBN").
MarketMakerId BidSize Bid Ask AskSize BRC 1000 52 1/2 54 750 GBN 500 53 54 1000 TLT 1000 53 53 3/4 1000 - Parameters:
objectName
- The name of the object. This must be an exact object name - it cannot be an object name pattern.type2Index
- The index for the type 2 data that is required.- Returns:
- The type 2 data of the specified object and type 2 index, or null if the data is not found in the cache. If null is returned, it could be because the object was not found in the cache, or because the object did not have any type 2 data for specified index.
- Throws:
java.lang.NullPointerException
- If either the objectName or type2Index arguments are null.
-
getType2Indices
java.lang.String[] getType2Indices(java.lang.String objectName)
Gets a list of type 2 indices that are available from the Transformer core cache for the specified object name.
The table below shows some sample type 2 data that may be cached for the object /LO/CAPLIN. In this case, the MarketMakerId field contains the type 2 indices. If the Transformer module calls getType2Indices("/LO/CAPLIN"), an array containing "BRC", "GBN" and "TLT" will be returned.
MarketMakerId BidSize Bid Ask AskSize BRC 1000 52 1/2 54 750 GBN 500 53 54 1000 TLT 1000 53 53 3/4 1000 - Parameters:
objectName
- The name of the object. This must be an exact object name - it cannot be an object name pattern.- Returns:
- An array of the type 2 indices for the specified object, or an empty array null if the data is not found in the cache. If an empty array is returned, it could be because the object was not found in the cache, or because the object did not contain any type 2 data.
- Throws:
java.lang.NullPointerException
- If the objectName argument is null.
-
getPermission
TransformerData getPermission(java.lang.String objectName, java.lang.String key)
Gets the permission data cached within the Transformer core for the specified object name and key.
See getType2 for structure information. Permission objects have the same structure as type 2 records.
- Parameters:
objectName
- The name of the object. This must be an exact object name - it cannot be an object name pattern.key
- The key for the permission data that is required.- Returns:
- The permission data of the specified object and key, or null if the data is not found in the cache. If null is returned, it could be because the object was not found in the cache, or because the object did not have any permission data for specified index.
- Throws:
java.lang.NullPointerException
- If either the objectName or key arguments are null.
-
getPermissionKeys
java.lang.String[] getPermissionKeys(java.lang.String objectName)
Gets a list of permission keys that are available from the Transformer core cache for the specified object name.
See getType2Indices for structure information. Permission objects have the same structure as type 2 records.
- Parameters:
objectName
- The name of the object. This must be an exact object name - it cannot be an object name pattern.- Returns:
- An array of the permission keys for the specified object, or an empty array if the data is not found in the cache. If an empty array is returned, it could be because the object was not found in the cache, or because the object did not contain any permission data.
- Throws:
java.lang.NullPointerException
- If the objectName argument is null.
-
getField
java.lang.String getField(java.lang.String objectName, java.lang.String fieldName)
Gets the latest value from the Transformer core for the specified object and field names.
- Parameters:
objectName
- The name of the object. This must be an exact object name - it cannot be an object name pattern.fieldName
- The name of the field.- Returns:
- The current value from the cache for the specified object and field names, or null if the value is not found. If null is returned, it could be because the object was not found in the cache, or because the object does not contain the specified field.
- Throws:
java.lang.NullPointerException
- If either the objectName of fieldName arguments are null.
-
getField
java.lang.String getField(java.lang.String objectName, int fieldNumber)
Gets the latest value from the Transformer core for the specified object name and field number.
- Parameters:
objectName
- The name of the object. This must be an exact object name - it cannot be object name pattern.fieldNumber
- The field number.- Returns:
- The current value from the cache for the specified object name and field number, or null if the value is not found. If null is returned, it could be because the object was not found in the cache, or because the object does not contain the specified field.
- Throws:
java.lang.NullPointerException
- If the objectName argument is null.
-
getType3Field
java.lang.String[] getType3Field(java.lang.String objectName, int fieldNumber)
Gets an array of values for the specified object name and type 3 field number. The array is in chronological order, with the most recent value at the start, and the oldest value at the end.
The table below shows some sample type 3 data that may be cached for the object /LO/CAPLIN. In this case, the TradePrice, TradeTime and TradeVolume fields are all type 3 fields. If the TradePrice field number is 18, then if the Transformer module calls getType3Field("/LO/CAPLIN", 18), an array containing "53 3/4", "54 1/2", "54 1/4". "54" and "53 1/2" will be returned.
TradePrice TradeTime TradeVolume 53 3/4 10:19 10000 54 1/2 10:19 600 54 1/4 10:18 1000 54 10:17 1233 53 1/2 10:17 67 - Parameters:
objectName
- The name of the object. This must be an exact object name - it cannot be an object name pattern.fieldNumber
- The type 3 field number.- Returns:
- An array of values from the cache for the specified object name and field number, or an empty array if no data is found. If an empty array is returned, it could be because the object was not found in the cache, or because the object does not contain the specified field.
- Throws:
java.lang.NullPointerException
- If the objectName argument is null.
-
getObjectNames
java.lang.String[] getObjectNames(java.lang.String objectNamePattern)
Gets an array of object names that were found in the Transformer core cache that match the specified object name pattern.
- Parameters:
objectNamePattern
- The object name pattern that will be matched against the objects within the Transformer core cache.- Returns:
- An array of object names that matched the specified pattern, or an empty array if no matches are found.
- Throws:
java.lang.NullPointerException
- If the objectNamePattern argument is null.
-
deleteType2
void deleteType2(java.lang.String objectName)
Deletes all the type 2 data from the Transformer core for the specified object name.
- Parameters:
objectName
- The name of the object. This must be an exact object name - it cannot be an object name pattern.- Throws:
java.lang.NullPointerException
- If the objectName argument is null.
-
deleteType2
void deleteType2(java.lang.String objectName, java.lang.String type2Index)
Deletes the type 2 entry from the Transformer core for the specified object name and type 2 index. This method assumes that the type 2 entries are indices under the field MktMkrId. If the type 2 entries are indexed by a different field, the
deleteType2(String, String, int)
method should be used instead.The tables below show some sample type 2 data that may be cached for the object /LO/CAPLIN. In this case, the MktMkrId field contains the type 2 indices. The first table shows the type 2 data that is available before the call deleteType2("/LO/CAPLIN", "GBN") is made. The second table shows the data that is available afterwards.
Before deleteType2("/LO/CAPLIN", "GBN") is called:
MktMkrId BidSize Bid Ask AskSize BRC 1000 52 1/2 54 750 GBN 500 53 54 1000 TLT 1000 53 53 3/4 1000 After deleteType2("/LO/CAPLIN", "GBN") is called:
MktMkrId BidSize Bid Ask AskSize BRC 1000 52 1/2 54 750 TLT 1000 53 53 3/4 1000 - Parameters:
objectName
- The name of the object. This must be an exact object name - it cannot be an object name pattern.type2Index
- The index for the type 2 entry that should be deleted.- Throws:
java.lang.NullPointerException
- If either the objectName or type2Index arguments are null.
-
deleteType2
void deleteType2(java.lang.String objectName, java.lang.String type2Index, int indexFieldNumber)
Deletes the type 2 entry from the Transformer core for the specified object name, type 2 index and index field number.
The tables below show some sample type 2 data that may be cached for the object /LO/CAPLIN, with the type 2 indices stored under the field MARKET_MAKER_ID (field number 212). The first table shows the type 2 data that is available before the call deleteType2("/LO/CAPLIN", "BRC", 212) is made. The second table shows the data that is available afterwards.
Before deleteType2("/LO/CAPLIN", "BRC", 212) is called:
MARKET_MAKER_ID BIDSIZE BID ASK ASKSIZE BRC 1000 52 1/2 54 750 GBN 500 53 54 1000 TLT 1000 53 53 3/4 1000 After deleteType2("/LO/CAPLIN", "BRC", 212) is called:
MARKET_MAKER_ID BidSize Bid Ask AskSize GBN 500 53 54 1000 TLT 1000 53 53 3/4 1000 - Parameters:
objectName
- The name of the object. This must be an exact object name - it cannot be an object name pattern.type2Index
- The index for the type 2 entry that should be deleted.indexFieldNumber
- The field number under which the type 2 entries are indexed.- Throws:
java.lang.NullPointerException
- If either the objectName or type2Index arguments are null.
-
remove
void remove(java.lang.String objectName)
Removes the object with the specified name from the Transformer core cache.
- Parameters:
objectName
- The name of the object. This must be an exact object name - it cannot be an object name pattern.- Throws:
java.lang.NullPointerException
- If the objectName argument is null.
-
getStatus
ObjectStatus getStatus(java.lang.String objectName)
Gets the current status for the object with the specified name from the Transformer core cache.
- Parameters:
objectName
- The name of the object the status is required for. This must be an exact object name - it cannot be an object name pattern.- Returns:
- The current status of the specified object. If the object is not
currently in the cache, this method will return
ServiceStatus.STALE
. - Throws:
java.lang.NullPointerException
- If the objectName argument is null.
-
setStatus
void setStatus(java.lang.String objectName, ObjectStatus status)
Set the status of an object within the Transformer cache. This status will be propagated to any interested peers or modules.
- Parameters:
objectName
- The name of the object the status is being changed on.status
- The new status for the object.- Throws:
java.lang.NullPointerException
- If the objectName or status arguments are null.
-
getObjectType
ObjectType getObjectType(java.lang.String objectName)
Gets the type code for the object with the specified name from the Transformer core cache.
- Parameters:
objectName
- The name of the object the status is required for. This must be an exact object name - it cannot be an object name pattern.- Returns:
- The current
ObjectType
of the specified object. If the object is not currently in the cache, this method will returnObjectType.UNDEFINED
. - Throws:
java.lang.NullPointerException
- If the objectName argument is null.
-
-