|
Oracle® Coherence Java API Reference Release 3.6.0.0 E15725-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
com.tangosol.util.Base
com.tangosol.util.AbstractKeyBasedMap
com.tangosol.util.AbstractKeySetBasedMap
com.tangosol.util.WrapperObservableMap
public class WrapperObservableMap
A simple implementation of ObservableMap interface built as a wrapper around any Map implementation. It also provides an implementation of CacheStatistics interface. <p/> Note: as of Coherence 3.0 the CacheStatistics implementation has to be turned on explicitly by calling the setCollectStats(boolean)
method. <p/> Note: if the underlying (wrapped) Map is an ObservableMap by itself, as of Coherence 3.2 the WrapperObservableMap implementation does not translate events generated the wrapped map by default. The translation can be turned on explicitly by calling the setTranslateEvents(boolean)
method.
Nested Class Summary | |
---|---|
protected class |
WrapperObservableMap.InternalListener An internal MapListener that listens to the wrapped map. |
Nested classes/interfaces inherited from class com.tangosol.util.AbstractKeySetBasedMap |
---|
AbstractKeySetBasedMap.EntrySet, AbstractKeySetBasedMap.KeyIterator, AbstractKeySetBasedMap.KeySet, AbstractKeySetBasedMap.ValuesCollection |
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry |
Field Summary | |
---|---|
protected boolean |
m_fTranslateEvents Specifies whether or not events are translated by this wrapper. |
protected MapListener |
m_listenerInternal The MapListener used to listen to the wrapped ObservableMap. |
protected MapListenerSupport |
m_listenerSupport The event listeners. |
protected Map |
m_map The (wrapped) map containing all the resources. |
protected SimpleCacheStatistics |
m_stats The CacheStatistics object maintained by this wrapper. |
Constructor Summary | |
---|---|
WrapperObservableMap(Map map) Construct an ObservableMap wrapper base on the specified map. |
Method Summary | |
---|---|
void |
addMapListener(MapListener listener) Add a standard map listener that will receive all events (inserts, updates, deletes) that occur against the map, with the key, old-value and new-value included. |
void |
addMapListener(MapListener listener, Filter filter, boolean fLite) Add a map listener that receives events based on a filter evaluation. |
void |
addMapListener(MapListener listener, Object oKey, boolean fLite) Add a map listener for a specific key. |
void |
clear() Clear all key/value mappings. |
boolean |
containsValue(Object oValue) Returns true if this Map maps one or more keys to the specified value. |
protected void |
dispatchEvent(MapEvent evt) Dispatch the passed event. |
protected void |
dispatchPendingEvent(Object oKey, int nId, Object oNewValue, boolean fSynthetic) Dispatch an event that has not yet occurred, allowing the cache to potentially avoid reading of the "original value" information. |
protected MapListener |
ensureInternalListener() Obtain the internal MapListener, creating one if necessary. |
protected MapListenerSupport |
ensureMapListenerSupport() Obtain the MapListenerSupport, creating it if necessary. |
Object |
get(Object oKey) Returns the value to which this map maps the specified key. |
CacheStatistics |
getCacheStatistics() Return the CacheStatistics for this cache. |
protected String |
getDescription() Assemble a human-readable description. |
protected Set |
getInternalKeySet() Obtain a set of keys that are represented by this Map. |
Map |
getMap() Get the Map that is wrapped by this wrapper. |
protected MapListenerSupport |
getMapListenerSupport() Accessor for the MapListenerSupport for sub-classes. |
protected boolean |
hasListeners() Determine if the OverflowMap has any listeners at all. |
protected MapListener |
instantiateInternalListener() Instantiate a MapListener to listen to the wrapped map. |
boolean |
isCollectStats() Check whether or not statistics are collected by the wrapper. |
protected boolean |
isEventFabricator() Determine if this ObservableMap has to fabricate events itself. |
protected boolean |
isInternalKeySetIteratorMutable() Determine if this Iterator should remove an iterated item by calling remove on the internal key Set Iterator, or by calling removeBlind on the map itself. |
protected static boolean |
isSynthetic(MapEvent evt) Helper method to determine if an event is synthetic. |
boolean |
isTranslateEvents() Check whether or not an event source has to be translated by the wrapper. |
Object |
put(Object oKey, Object oValue) Associates the specified value with the specified key in this map. |
void |
putAll(Map map) Copies all of the mappings from the specified map to this map. |
Object |
remove(Object oKey) Removes the mapping for this key from this map if present. |
protected boolean |
removeBlind(Object oKey) Removes the mapping for this key from this map if present. |
void |
removeMapListener(MapListener listener) Remove a standard map listener that previously signed up for all events. |
void |
removeMapListener(MapListener listener, Filter filter) Remove a map listener that previously signed up for events based on a filter evaluation. |
void |
removeMapListener(MapListener listener, Object oKey) Remove a map listener that previously signed up for events about a specific key. |
void |
setCollectStats(boolean fCollectStats) Specify whether or not statistics are to be collected by the wrapper. |
void |
setTranslateEvents(boolean fTranslate) Specify whether or not an event source has to be translated by the wrapper. |
String |
toString() Returns a string representation of this Map. |
Methods inherited from class com.tangosol.util.AbstractKeySetBasedMap |
---|
containsKey, instantiateEntrySet, instantiateKeyIterator, instantiateKeySet, instantiateValues, isEmpty, iterateKeys, size |
Methods inherited from class com.tangosol.util.AbstractKeyBasedMap |
---|
clone, entrySet, equals, getAll, hashCode, keySet, values |
Methods inherited from interface java.util.Map |
---|
containsKey, entrySet, equals, hashCode, isEmpty, keySet, size, values |
Field Detail |
---|
protected Map m_map
protected MapListenerSupport m_listenerSupport
protected MapListener m_listenerInternal
protected SimpleCacheStatistics m_stats
protected boolean m_fTranslateEvents
Constructor Detail |
---|
public WrapperObservableMap(Map map)
map
- the Map that will be wrapped by this WrapperObservableMapMethod Detail |
---|
public void clear()
clear
in interface Map
clear
in class AbstractKeyBasedMap
public boolean containsValue(Object oValue)
containsValue
in interface Map
containsValue
in class AbstractKeyBasedMap
oValue
- value whose presence in this map is to be tested.public Object get(Object oKey)
get
in interface Map
get
in class AbstractKeyBasedMap
oKey
- the key objectMap.containsKey(Object)
public Object put(Object oKey, Object oValue)
put
in interface Map
put
in class AbstractKeyBasedMap
oKey
- key with which the specified value is to be associatedoValue
- value to be associated with the specified keypublic void putAll(Map map)
AbstractKeyBasedMap.put(java.lang.Object, java.lang.Object)
on this map once for each mapping in the passed map. The behavior of this operation is unspecified if the passed map is modified while the operation is in progress.putAll
in interface Map
putAll
in class AbstractKeyBasedMap
map
- the Map containing the key/value pairings to put into this Mappublic Object remove(Object oKey)
remove
in interface Map
remove
in class AbstractKeyBasedMap
oKey
- key whose mapping is to be removed from the mapprotected Set getInternalKeySet()
getInternalKeySet
in class AbstractKeySetBasedMap
protected boolean isInternalKeySetIteratorMutable()
isInternalKeySetIteratorMutable
in class AbstractKeySetBasedMap
AbstractKeyBasedMap.removeBlind(Object)
methodprotected boolean removeBlind(Object oKey)
removeBlind
in class AbstractKeyBasedMap
oKey
- key whose mapping is to be removed from the mappublic void addMapListener(MapListener listener)
addMapListener(listener, (Filter) null, false);
addMapListener
in interface ObservableMap
listener
- the MapEvent
listener to addpublic void removeMapListener(MapListener listener)
removeMapListener(listener, (Filter) null);
removeMapListener
in interface ObservableMap
listener
- the listener to removepublic void addMapListener(MapListener listener, Object oKey, boolean fLite)
The listeners will receive MapEvent objects, but if fLite is passed as true, they might not contain the OldValue and NewValue properties.
To unregister the MapListener, use the ObservableMap.removeMapListener(MapListener, Object)
method.
addMapListener
in interface ObservableMap
listener
- the MapEvent
listener to addoKey
- the key that identifies the entry for which to raise eventsfLite
- true to indicate that the MapEvent
objects do not have to include the OldValue and NewValue property values in order to allow optimizationspublic void removeMapListener(MapListener listener, Object oKey)
removeMapListener
in interface ObservableMap
listener
- the listener to removeoKey
- the key that identifies the entry for which to raise eventspublic void addMapListener(MapListener listener, Filter filter, boolean fLite)
The listeners will receive MapEvent objects, but if fLite is passed as true, they might not contain the OldValue and NewValue properties.
To unregister the MapListener, use the ObservableMap.removeMapListener(MapListener, Filter)
method.
addMapListener
in interface ObservableMap
listener
- the MapEvent
listener to addfilter
- a filter that will be passed MapEvent objects to select from; a MapEvent will be delivered to the listener only if the filter evaluates to true for that MapEvent (see MapEventFilter
); null is equivalent to a filter that alway returns truefLite
- true to indicate that the MapEvent
objects do not have to include the OldValue and NewValue property values in order to allow optimizationspublic void removeMapListener(MapListener listener, Filter filter)
removeMapListener
in interface ObservableMap
listener
- the listener to removefilter
- the filter that was passed into the corresponding addMapListener() callpublic Map getMap()
public CacheStatistics getCacheStatistics()
public boolean isCollectStats()
public void setCollectStats(boolean fCollectStats)
fCollectStats
- true if this wrapper should collect cache statistics; false otherwisepublic boolean isTranslateEvents()
public void setTranslateEvents(boolean fTranslate)
fTranslate
- true if this wrapper should translate an event source; false otherwiseprotected String getDescription()
public String toString()
toString
in class AbstractKeyBasedMap
protected MapListenerSupport getMapListenerSupport()
protected MapListenerSupport ensureMapListenerSupport()
protected boolean hasListeners()
protected boolean isEventFabricator()
protected static boolean isSynthetic(MapEvent evt)
evt
- a Map Eventprotected void dispatchPendingEvent(Object oKey, int nId, Object oNewValue, boolean fSynthetic)
oKey
- the key which the event is related tonId
- the event IDoNewValue
- the new valuefSynthetic
- true if the event is syntheticprotected void dispatchEvent(MapEvent evt)
evt
- a CacheEvent objectprotected MapListener ensureInternalListener()
protected MapListener instantiateInternalListener()
|
Oracle® Coherence Java API Reference Release 3.6.0.0 E15725-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |