public abstract class AbstractTable extends java.lang.Object implements java.lang.Iterable<java.util.Map.Entry<java.lang.String,RowValue>>
If the distributed store implementation provides a ConcurrentMap, then it is recommended that implementers of Apama distributed store drivers create subclasses of ConcurrentMapAdapter instead of subclassing AbstractTable directly, for ease of development and maintenance.
Implementations of this class must be thread-safe.
Drivers may optionally provide support for 'row changed' notifications. To do this, subclasses must
create an implementation of RowChangedSubscriptionManager and return it from
getRowChangedSubscriptionManager()
, as well as calling fireRowChanged when changes are detected.
Calls to subscribeRowChanged and unsubscribe are passed to this instance.
ConcurrentMapAdapter
Constructor and Description |
---|
AbstractTable()
Creates a table.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
clear()
Removes all of the mappings from this map (optional operation).
|
void |
close()
Closes resources allocated by this table such as the RowChangedSubscriptionManager.
|
abstract boolean |
containsKey(java.lang.String key)
Returns true if this map contains a mapping for the specified
key.
|
abstract RowValue |
get(java.lang.String key)
Returns the value to which the specified key is mapped,
or
null if this map contains no mapping for the key. |
RowChangedSubscriptionManager |
getRowChangedSubscriptionManager()
Retrieves the
RowChangedSubscriptionManager instance for this table if row changed notifications are
supported. |
abstract java.util.Iterator<java.util.Map.Entry<java.lang.String,RowValue>> |
iterator()
Returns an iterator over all the rows of this table.
|
abstract RowValue |
putIfAbsent(java.lang.String key,
RowValue value)
If the specified key is not already associated
with a value, associates it with the given value.
|
abstract RowValue |
remove(java.lang.String key)
Removes the mapping for a key from this map if it is present.
|
abstract boolean |
remove(java.lang.String key,
RowValue value)
Removes the entry for a key only if currently mapped to a given value.
|
abstract boolean |
replace(java.lang.String key,
RowValue oldValue,
RowValue newValue)
Replaces the entry for a key only if it is currently mapped to a given value.
|
abstract int |
size()
Returns the number of key-value mappings in this map.
|
public abstract RowValue get(java.lang.String key)
null
if this map contains no mapping for the key.key
- the key whose associated value is to be returnednull
if this map contains no mapping for the keyjava.lang.NullPointerException
- if the specified key is null and this map
does not permit null keyspublic abstract void clear()
java.lang.UnsupportedOperationException
- if the clear operation
is not supported by this mappublic abstract RowValue remove(java.lang.String key)
(key==null ? k==null : key.equals(k))
, that mapping
is removed. (The map can contain at most one such mapping.)
Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.
key
- key whose mapping is to be removed from the mapjava.lang.UnsupportedOperationException
- if the remove operation
is not supported by this mappublic abstract boolean remove(java.lang.String key, RowValue value)
key
- key with which the specified value is associatedvalue
- value expected to be associated with the specified keyjava.lang.UnsupportedOperationException
- if the remove operation
is not supported by this mappublic abstract boolean replace(java.lang.String key, RowValue oldValue, RowValue newValue)
key
- key with which the specified value is associatedoldValue
- value expected to be associated with the specified keynewValue
- value to be associated with the specified keyjava.lang.UnsupportedOperationException
- if the put operation
is not supported by this mapjava.lang.ClassCastException
- if the class of a specified key or value
prevents it from being stored in this mapjava.lang.NullPointerException
- if a specified key or value is null,
and this map does not permit null keys or valuesjava.lang.IllegalArgumentException
- if some property of a specified key
or value prevents it from being stored in this mappublic abstract RowValue putIfAbsent(java.lang.String key, RowValue value)
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keyjava.lang.UnsupportedOperationException
- if the put operation
is not supported by this mapjava.lang.NullPointerException
- if the specified key or value is null,
and this map does not permit null keys or valuesjava.lang.IllegalArgumentException
- if some property of the specified key
or value prevents it from being stored in this mappublic abstract boolean containsKey(java.lang.String key)
key
- key whose presence in this map is to be testedpublic abstract int size()
public abstract java.util.Iterator<java.util.Map.Entry<java.lang.String,RowValue>> iterator()
Note: a simple way to construct a Map.Entry is to use the AbstractMap.SimpleEntry class.
iterator
in interface java.lang.Iterable<java.util.Map.Entry<java.lang.String,RowValue>>
public RowChangedSubscriptionManager getRowChangedSubscriptionManager()
RowChangedSubscriptionManager
instance for this table if row changed notifications are
supported.
The default implementation of this method will return null, indicating that row changed notifications are not supported. Subclasses that implement notifications should override this method and have it return the instance of RowChangedSubscriptionManager for this table that provides implementations of addRowChangedListener and removeRowChangedListener and calls fireRowChanged when changes are detected. Calls to subscribeRowChanged and unsubscribe are passed to this instance. If null, the subscribe and unsubscribe EPL methods will fail with an error.
This method may be called from any thread, so to ensure thread-safety the field holding the subscription manager returned by this method should usually be marked 'final'.
public void close()
AbstractStore.registerCloseHandlerForTable(AbstractTable)
when creating the
table then this method will automatically called by the owning store during AbstractStore.close to clear up
any table-specific resources such as the notifications manager; otherwise, the driver must do this manually.Submit a bug or feature
Copyright (c) 2013-2015 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors. Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.