public class MapListenerSupport extends Base
Modifier and Type | Class and Description |
---|---|
static class |
MapListenerSupport.FilterEvent
An extension of the CacheEvent which may carry no values (old or new), but
instead holds on an array of Filter objects being the "cause" of the event.
|
static interface |
MapListenerSupport.PrimingListener<K,V>
A tag interface indicating that this listener is registered as a
synchronous listener for lite events (carrying only a key) and generates
a "priming" event when registered.
|
static interface |
MapListenerSupport.SynchronousListener<K,V>
A tag interface indicating that tagged MapListener implementation
has to receive the MapEvent notifications in a synchronous manner.
|
static class |
MapListenerSupport.WrapperListener<K,V>
A base class for various wrapper listener classes.
|
static class |
MapListenerSupport.WrapperPrimingListener
A wrapper class that turns the specified MapListener into
a priming listener.
|
static class |
MapListenerSupport.WrapperSynchronousListener<K,V>
A wrapper class that turns the specified MapListener into
a synchronous listener.
|
Base.LoggingWriter, Base.StackFrame
Modifier and Type | Field and Description |
---|---|
protected Listeners |
m_listenersCached
A cached set of Listeners.
|
protected Map |
m_mapKeyListeners
The collections of MapListener objects that have signed up for key based
notifications from an ObservableMap implementation keyed by the
corresponding key objects.
|
protected Map |
m_mapListeners
The collections of MapListener objects that have signed up for
notifications from an ObservableMap implementation keyed by the
corresponding Filter objects.
|
protected Map |
m_mapStandardKeyListeners
The subset of standard (not lite) key listeners.
|
protected Map |
m_mapStandardListeners
The subset of standard (not lite) global listeners.
|
protected int |
m_nOptimizationPlan
The optimization plan which indicates the fastest way to put together a
set of listeners.
|
protected Listeners |
NO_LISTENERS
An empty set of Listeners.
|
protected static int |
PLAN_ALL_LISTENER
There is one all-keys non-filtered listener.
|
protected static int |
PLAN_KEY_LISTENER
There is one key listener (even if for multiple keys).
|
protected static int |
PLAN_NO_LISTENERS
There are no listeners.
|
protected static int |
PLAN_NO_OPTIMIZE
There is no optimized plan, so just use the default approach.
|
protected static int |
PLAN_NONE
A plan has not yet been formed.
|
Constructor and Description |
---|
MapListenerSupport()
Constructs a new MapListenerSupport object.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(MapListener listener,
Filter filter,
boolean fLite)
Add a map listener that receives events based on a filter evaluation.
|
void |
addListener(MapListener listener,
Object oKey,
boolean fLite)
Add a map listener for a specific key.
|
void |
addListener(MapListener listener,
Set setKey,
boolean fLite)
Add a map listener for a set of keys.
|
protected static void |
addListenerState(Map mapStandardListeners,
Object anyKey,
MapListener listener,
boolean fLite)
Add a state information (lite or standard) associated with
specified key and listener.
|
boolean |
addListenerWithCheck(MapListener listener,
Filter filter,
boolean fLite)
Add a map listener that receives events based on a filter evaluation.
|
boolean |
addListenerWithCheck(MapListener listener,
Object oKey,
boolean fLite)
Add a map listener for a specific key.
|
void |
addListenerWithCheck(MapListener listener,
Set setKey,
boolean fLite)
Add a map listener for a set of keys.
|
protected static void |
addSafeListener(Map mapListeners,
Filter anyFilter,
MapListener listener)
Ensure that the specified map has a Listeners object associated
with the specified Filter and add the specified listener to it.
|
protected static void |
addSafeListener(Map mapListeners,
Object anyKey,
MapListener listener)
Ensure that the specified map has a Listeners object associated
with the specified key and add the specified listener to it.
|
void |
clear()
Remove all signed up listeners.
|
Listeners |
collectListeners(MapEvent event)
Collect all Listeners that should be notified for a given event.
|
boolean |
containsStandardListeners(Filter filter)
Checks whether or not this MapListenerSupport object contains
any standard (not lite) listeners for a given filter.
|
boolean |
containsStandardListeners(Object oKey)
Checks whether or not this MapListenerSupport object contains
any standard (not lite) listeners for a given key.
|
static MapEvent |
convertEvent(MapEvent event,
ObservableMap mapConv,
Converter convKey,
Converter convVal)
Convert the specified map event into another MapEvent that ensures the
lazy event data conversion using the specified converters.
|
static MapEvent |
enrichEvent(MapEvent event,
Listeners listeners)
Transform the given MapEvent into a FilterEvent if it is not already a
FilterEvent and there are matching filters associated with the
specified Listeners object.
|
protected boolean |
evaluateEvent(Filter filter,
MapEvent event)
Evaluate whether or not the specified event should be delivered to the
listener associated with the specified filter.
|
void |
fireEvent(MapEvent event,
boolean fStrict)
Fire the specified map event.
|
Set |
getFilterSet()
Obtain a set of all filters that have associated global listeners.
|
Set |
getKeySet()
Obtain a set of all keys that have associated key listeners.
|
Listeners |
getListeners(Filter filter)
Obtain the Listeners object for a given filter.
|
Listeners |
getListeners(Object oKey)
Obtain the Listeners object for a given key.
|
boolean |
isEmpty()
Checks whether or not this MapListenerSupport object contains
any listeners.
|
boolean |
isEmpty(Filter filter)
Checks whether or not this MapListenerSupport object contains
any listeners for a given filter.
|
boolean |
isEmpty(Object oKey)
Checks whether or not this MapListenerSupport object contains
any listeners for a given key.
|
static boolean |
isPrimingListener(MapListener listener)
Check if the given listener is a PrimingListener or if it wraps one.
|
protected boolean |
isTransformedEvent(MapEvent event)
Return true iff the specified event represents a transformed CacheEvent.
|
void |
removeListener(MapListener listener,
Filter filter)
Remove a map listener that previously signed up for events based on a
filter evaluation.
|
void |
removeListener(MapListener listener,
Object oKey)
Remove a map listener that previously signed up for events about a
specific key.
|
void |
removeListener(MapListener listener,
Set setKey)
Remove a map listener that previously signed up for events about
specific keys.
|
protected static void |
removeListenerState(Map mapStandardListeners,
Object anyKey,
MapListener listener)
Remove a state information (lite or standard) associated with
specified key and listener.
|
boolean |
removeListenerWithCheck(MapListener listener,
Filter filter)
Remove a map listener that previously signed up for events based on a
filter evaluation.
|
boolean |
removeListenerWithCheck(MapListener listener,
Object oKey)
Remove a map listener that previously signed up for events about a
specific key.
|
void |
removeListenerWithCheck(MapListener listener,
Set setKey)
Remove a map listener that previously signed up for events about specific
keys.
|
protected static void |
removeSafeListener(Map mapListeners,
Object anyKey,
MapListener listener)
Remove the specified listener from the Listeners object associated
with the specified key.
|
String |
toString()
Provide a string representation of the MapListenerSupport object.
|
static MapEvent |
unwrapEvent(MapEvent evt)
Unwrap the specified map event and return the underlying source event.
|
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
protected static final int PLAN_NONE
protected static final int PLAN_NO_LISTENERS
protected static final int PLAN_ALL_LISTENER
protected static final int PLAN_KEY_LISTENER
protected static final int PLAN_NO_OPTIMIZE
protected final Listeners NO_LISTENERS
protected Map m_mapListeners
protected Map m_mapKeyListeners
protected Map m_mapStandardListeners
protected Map m_mapStandardKeyListeners
protected int m_nOptimizationPlan
protected Listeners m_listenersCached
public MapListenerSupport()
public void addListener(MapListener listener, Filter filter, boolean fLite)
listener
- the 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; null is equivalent to a filter
that always 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 boolean addListenerWithCheck(MapListener listener, Filter filter, boolean fLite)
listener
- the 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; null is equivalent to a filter
that always 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 addListener(MapListener listener, Object oKey, boolean fLite)
listener
- the listener to addoKey
- the key that identifies the entry for which to register
the event listenerfLite
- true to indicate that the MapEvent objects do
not have to include the OldValue and NewValue
property values in order to allow optimizationspublic boolean addListenerWithCheck(MapListener listener, Object oKey, boolean fLite)
listener
- the listener to addoKey
- the key that identifies the entry for which to register
the event listenerfLite
- true to indicate that the MapEvent objects do
not have to include the OldValue and NewValue
property values in order to allow optimizationspublic void addListener(MapListener listener, Set setKey, boolean fLite)
listener
- the listener to addsetKey
- the key set for which to register the event listenerfLite
- true to indicate that the MapEvent objects do
not have to include the OldValue and NewValue
property values in order to allow optimizationspublic void addListenerWithCheck(MapListener listener, Set setKey, boolean fLite)
listener
- the listener to addsetKey
- the key set for which to register the event listenerfLite
- true to indicate that the MapEvent objects do
not have to include the OldValue and NewValue
property values in order to allow optimizationspublic void removeListener(MapListener listener, Filter filter)
listener
- the listener to removefilter
- a filter used to evaluate eventspublic boolean removeListenerWithCheck(MapListener listener, Filter filter)
listener
- the listener to removefilter
- a filter used to evaluate eventspublic void removeListener(MapListener listener, Object oKey)
listener
- the listener to removeoKey
- the key that identifies the entry for which to unregister
the event listenerpublic boolean removeListenerWithCheck(MapListener listener, Object oKey)
listener
- the listener to removeoKey
- the key that identifies the entry for which to unregister
the event listenerpublic void removeListener(MapListener listener, Set setKey)
listener
- the listener to removesetKey
- the set of keys for which to unregister the event listenerpublic void removeListenerWithCheck(MapListener listener, Set setKey)
listener
- the listener to removesetKey
- the set of keys for which to unregister the event listenerpublic void clear()
public boolean isEmpty()
public boolean isEmpty(Filter filter)
filter
- the filterpublic boolean isEmpty(Object oKey)
oKey
- the keypublic boolean containsStandardListeners(Filter filter)
filter
- the filterpublic boolean containsStandardListeners(Object oKey)
oKey
- the keypublic Set getFilterSet()
Note: The returned value must be treated as an immutable.
public Set getKeySet()
Note: The returned value must be treated as an immutable.
public Listeners getListeners(Filter filter)
Note: The returned value must be treated as an immutable.
filter
- the filterpublic Listeners getListeners(Object oKey)
Note: The returned value must be treated as an immutable.
oKey
- the keypublic Listeners collectListeners(MapEvent event)
Note: The returned value must be treated as an immutable.
event
- the MapEvent objectpublic void fireEvent(MapEvent event, boolean fStrict)
event
- the map eventfStrict
- if true then any RuntimeException thrown by event
handlers stops all further event processing and the
exception is re-thrown; if false then all exceptions
are logged and the process continuespublic static MapEvent convertEvent(MapEvent event, ObservableMap mapConv, Converter convKey, Converter convVal)
event
- the map eventmapConv
- the source for the converted eventconvKey
- (optional) the key ConverterconvVal
- (optional) the value converterpublic static MapEvent enrichEvent(MapEvent event, Listeners listeners)
event
- the MapEvent to transform, if necessarylisteners
- the Listeners objectpublic static MapEvent unwrapEvent(MapEvent evt)
evt
- the event to unwrappublic static boolean isPrimingListener(MapListener listener)
listener
- Map listener to checkprotected boolean evaluateEvent(Filter filter, MapEvent event)
filter
- the filterevent
- the eventprotected boolean isTransformedEvent(MapEvent event)
event
- the event to testprotected static void addSafeListener(Map mapListeners, Object anyKey, MapListener listener)
protected static void addSafeListener(Map mapListeners, Filter anyFilter, MapListener listener)
protected static void removeSafeListener(Map mapListeners, Object anyKey, MapListener listener)
protected static void addListenerState(Map mapStandardListeners, Object anyKey, MapListener listener, boolean fLite)
protected static void removeListenerState(Map mapStandardListeners, Object anyKey, MapListener listener)