Package com.tangosol.util
Class MapEvent<K,V>
java.lang.Object
java.util.EventObject
com.tangosol.util.MapEvent<K,V>
- Type Parameters:
K- the type of the Map entry keyV- the type of the Map entry value
- All Implemented Interfaces:
PortableObject,Serializable
- Direct Known Subclasses:
CacheEvent
An event which indicates that the content of a map has changed:
- an entry has been added
- an entry has been removed
- an entry has been changed
- Author:
- gg 2002.02.11
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThis event indicates that an entry has been removed from the map.static final intThis event indicates that an entry has been added to the map.static final intThis event indicates that an entry has been updated in the map.protected KA key.protected intThe event's id.protected intThe partition this MapEvent was emitted from.protected longThe partition version of this MapEvent.protected VA new value.protected VA previous value.Fields inherited from class java.util.EventObject
source -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDispatch this event to the specified listeners collection.voidDispatch this event to the specified listeners collection.voiddispatch(MapListener<? super K, ? super V> listener) Dispatch this event to the specified MapListener.protected StringGet the event's description.static StringgetDescription(int nId) Convert an event ID into a human-readable string.intgetId()Return this event's id.getKey()Return a key associated with this event.getMap()Return an ObservableMap object on which this event has actually occurred.Return a Map Entry that represents the state of the Entry after the change occurred that generated this event.Return a new value associated with this event.Return a Map Entry that represents the state of the Entry before the change occurred that generated this event.Return an old value associated with this event.intReturn the partition this MapEvent represents or -1 if the event source is not partition aware.longReturn the version that represents the change that caused this MapEvent.booleanisDelete()Determine whether this event is a delete event.booleanisInsert()Determine whether this event is an insert event.booleanisUpdate()Determine whether this event is an update event.voidRestore the contents of a user type instance by reading its state using the specified PofReader object.protected booleanshouldDispatch(MapListener listener) Return true if the providedMapListenershould receive this event.toString()Return a String representation of this MapEvent object.with(int nPartition, long lVersion) Return a MapEvent that is enriched with the provided partition and version.voidwriteExternal(PofWriter out) Save the contents of a POF user type instance by writing its state using the specified PofWriter object.Methods inherited from class java.util.EventObject
getSource
-
Field Details
-
ENTRY_INSERTED
public static final int ENTRY_INSERTEDThis event indicates that an entry has been added to the map.- See Also:
-
ENTRY_UPDATED
public static final int ENTRY_UPDATEDThis event indicates that an entry has been updated in the map.- See Also:
-
ENTRY_DELETED
public static final int ENTRY_DELETEDThis event indicates that an entry has been removed from the map.- See Also:
-
m_nId
protected int m_nIdThe event's id. -
m_key
A key. -
m_valueOld
A previous value. May be null if not known. -
m_valueNew
A new value. May be null if not known. -
m_nPartition
protected int m_nPartitionThe partition this MapEvent was emitted from. -
m_nVersion
protected long m_nVersionThe partition version of this MapEvent.
-
-
Constructor Details
-
MapEvent
public MapEvent()Default constructor for serialization. -
MapEvent
Constructs a new MapEvent.- Parameters:
map- the ObservableMap object that fired the eventnId- this event's id, one ofENTRY_INSERTED,ENTRY_UPDATEDorENTRY_DELETEDkey- the key into the mapvalueOld- the old value (for update and delete events)valueNew- the new value (for insert and update events)
-
-
Method Details
-
getMap
Return an ObservableMap object on which this event has actually occurred.- Returns:
- an ObservableMap object
-
getId
public int getId()Return this event's id. The event id is one of the ENTRY_* enumerated constants.- Returns:
- an id
-
getKey
Return a key associated with this event.- Returns:
- a key
-
getOldValue
Return an old value associated with this event.The old value represents a value deleted from or updated in a map. It is always null for "insert" notifications.
- Returns:
- an old value
-
getNewValue
Return a new value associated with this event.The new value represents a new value inserted into or updated in a map. It is always null for "delete" notifications.
- Returns:
- a new value
-
getOldEntry
Return a Map Entry that represents the state of the Entry before the change occurred that generated this event.- Returns:
- a Map Entry representing the pre-event state of the Entry
- Since:
- Coherence 3.6
-
getNewEntry
Return a Map Entry that represents the state of the Entry after the change occurred that generated this event.- Returns:
- a Map Entry representing the post-event state of the Entry
- Since:
- Coherence 3.6
-
getPartition
public int getPartition()Return the partition this MapEvent represents or -1 if the event source is not partition aware.- Returns:
- the partition this MapEvent represents or -1 if the event source is not partition aware
-
getVersion
public long getVersion()Return the version that represents the change that caused this MapEvent. The meaning of this version, and therefore causality of versions, is defined by the event source.- Returns:
- the version that represents the change that caused this MapEvent
-
isInsert
public boolean isInsert()Determine whether this event is an insert event.- Returns:
trueif this event is an insert event
-
isUpdate
public boolean isUpdate()Determine whether this event is an update event.- Returns:
trueif this event is an update event
-
isDelete
public boolean isDelete()Determine whether this event is a delete event.- Returns:
trueif this event is a delete event
-
with
Return a MapEvent that is enriched with the provided partition and version.- Parameters:
nPartition- the partition this MapEventlVersion- the version that caused this change- Returns:
- a MapEvent that is enriched with the provided partition and version
-
readExternal
Description copied from interface:PortableObjectRestore the contents of a user type instance by reading its state using the specified PofReader object.- Specified by:
readExternalin interfacePortableObject- Parameters:
in- the PofReader from which to read the object's state- Throws:
IOException- if an I/O error occurs
-
writeExternal
Description copied from interface:PortableObjectSave the contents of a POF user type instance by writing its state using the specified PofWriter object.- Specified by:
writeExternalin interfacePortableObject- Parameters:
out- the PofWriter to which to write the object's state- Throws:
IOException- if an I/O error occurs
-
toString
Return a String representation of this MapEvent object.- Overrides:
toStringin classEventObject- Returns:
- a String representation of this MapEvent object
-
dispatch
Dispatch this event to the specified listeners collection.This call is equivalent to
dispatch(listeners, true);
- Parameters:
listeners- the listeners collection- Throws:
ClassCastException- if any of the targets is not an instance of MapListener interface
-
dispatch
Dispatch this event to the specified listeners collection.- Parameters:
listeners- the listeners collectionfStrict- 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 continues- Throws:
ClassCastException- if any of the targets is not an instance of MapListener interface
-
dispatch
Dispatch this event to the specified MapListener.- Parameters:
listener- the listener
-
shouldDispatch
Return true if the providedMapListenershould receive this event.- Parameters:
listener- the MapListener to dispatch this event to- Returns:
- true if the provided MapListener should receive the event
-
getDescription
Get the event's description.- Returns:
- this event's description
-
getDescription
Convert an event ID into a human-readable string.- Parameters:
nId- an event ID, one of the ENTRY_* enumerated values- Returns:
- a corresponding human-readable string, for example "inserted"
-