K
- the type of the Map entry keyV
- the type of the Map entry valuepublic class MapEvent<K,V> extends EventObject implements PortableObject
Modifier and Type | Field and Description |
---|---|
static int |
ENTRY_DELETED
This event indicates that an entry has been removed from the map.
|
static int |
ENTRY_INSERTED
This event indicates that an entry has been added to the map.
|
static int |
ENTRY_UPDATED
This event indicates that an entry has been updated in the map.
|
protected int |
m_nId
The event's id.
|
protected K |
m_oKey
A key.
|
protected V |
m_oValueNew
A new value.
|
protected V |
m_oValueOld
A previous value.
|
source
Constructor and Description |
---|
MapEvent()
Default constructor for serialization.
|
MapEvent(ObservableMap<K,V> map,
int nId,
K oKey,
V oValueOld,
V oValueNew)
Constructs a new MapEvent.
|
Modifier and Type | Method and Description |
---|---|
void |
dispatch(Listeners listeners)
Dispatch this event to the specified listeners collection.
|
void |
dispatch(Listeners listeners,
boolean fStrict)
Dispatch this event to the specified listeners collection.
|
void |
dispatch(MapListener<? super K,? super V> listener)
Dispatch this event to the specified MapListener.
|
protected String |
getDescription()
Get the event's description.
|
static String |
getDescription(int nId)
Convert an event ID into a human-readable string.
|
int |
getId()
Return this event's id.
|
K |
getKey()
Return a key associated with this event.
|
ObservableMap |
getMap()
Return an ObservableMap object on which this event has actually
occurred.
|
Map.Entry<K,V> |
getNewEntry()
Return a Map Entry that represents the state of the Entry after the
change occurred that generated this event.
|
V |
getNewValue()
Return a new value associated with this event.
|
Map.Entry<K,V> |
getOldEntry()
Return a Map Entry that represents the state of the Entry before the
change occurred that generated this event.
|
V |
getOldValue()
Return an old value associated with this event.
|
boolean |
isDelete()
Determine whether this event is a delete event.
|
boolean |
isInsert()
Determine whether this event is an insert event.
|
boolean |
isUpdate()
Determine whether this event is an update event.
|
void |
readExternal(PofReader in)
Restore the contents of a user type instance by reading its state using
the specified PofReader object.
|
protected boolean |
shouldDispatch(MapListener listener)
Return true if the provided
MapListener should receive this
event. |
String |
toString()
Return a String representation of this MapEvent object.
|
void |
writeExternal(PofWriter out)
Save the contents of a POF user type instance by writing its state using
the specified PofWriter object.
|
getSource
public static final int ENTRY_INSERTED
public static final int ENTRY_UPDATED
public static final int ENTRY_DELETED
protected int m_nId
protected K m_oKey
protected V m_oValueOld
protected V m_oValueNew
public MapEvent()
public MapEvent(ObservableMap<K,V> map, int nId, K oKey, V oValueOld, V oValueNew)
map
- the ObservableMap object that fired the eventnId
- this event's id, one of ENTRY_INSERTED
,
ENTRY_UPDATED
or ENTRY_DELETED
oKey
- the key into the mapoValueOld
- the old value (for update and delete events)oValueNew
- the new value (for insert and update events)public ObservableMap getMap()
public int getId()
public K getKey()
public V getOldValue()
The old value represents a value deleted from or updated in a map. It is always null for "insert" notifications.
public V getNewValue()
The new value represents a new value inserted into or updated in a map. It is always null for "delete" notifications.
public Map.Entry<K,V> getOldEntry()
public Map.Entry<K,V> getNewEntry()
public boolean isInsert()
true
if this event is an insert eventpublic boolean isUpdate()
true
if this event is an update eventpublic boolean isDelete()
true
if this event is a delete eventpublic void readExternal(PofReader in) throws IOException
PortableObject
readExternal
in interface PortableObject
in
- the PofReader from which to read the object's stateIOException
- if an I/O error occurspublic void writeExternal(PofWriter out) throws IOException
PortableObject
writeExternal
in interface PortableObject
out
- the PofWriter to which to write the object's stateIOException
- if an I/O error occurspublic String toString()
toString
in class EventObject
public void dispatch(Listeners listeners)
This call is equivalent to
dispatch(listeners, true);
listeners
- the listeners collectionClassCastException
- if any of the targets is not
an instance of MapListener interfacepublic void dispatch(Listeners listeners, boolean fStrict)
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 continuesClassCastException
- if any of the targets is not
an instance of MapListener interfacepublic void dispatch(MapListener<? super K,? super V> listener)
listener
- the listenerprotected boolean shouldDispatch(MapListener listener)
MapListener
should receive this
event.listener
- the MapListener to dispatch this event toprotected String getDescription()
public static String getDescription(int nId)
nId
- an event ID, one of the ENTRY_* enumerated values