|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object biz.chitec.quarterback.util.TalkingMap
Map featuring a property event sending mechanism on changing data. TalkingMap implements the Map interface and backs the complete map handling stuff to another map, either user-given or an internally created HashMap. TalkingMap's access methods are extended, however, by some calling means of an internally provided PropertyChangeSupport element. Any changes done in the internal map by the access methods of TalkingMap result in PropertyChangeEvents sent to all connected listeners. TalkingMap knows two modes for sending events. Either, the event is sent immediately after the change in the map or changes are collected in a "transaction" and a special event is sent at the end of the transaction. This mode is useful especially if many changes have to be done or some changes should be handled only together and not separatly. It is always guaranteed that the event is sent after the change took place. The old value is always sent within the event. For insertions, the old value is null. For deletions, the new value is null. Changes which do not change something do not raise an event, this is handled within the PropertyChangeSupport. The generated events contain the key of the changed property as property name. Therefore, map keys should be either String objects or provide meaningful representations via the toString() method. Events generated internally by the TalkingMap (e.g. start and end of a transaction) always begin with an underscore, "_", therefore the map's keys should not begin with an underscore. The current implementation of TalkingMap is incomplete as it does not provide encapsulations of the map's sets (entrySet, keySet). Changes to the map done through these sets are not recognized by the TalkingMap. Of course, if the map is user-defined and changed directly though its own methods, changed aren't recognized by the TalkingMap, either.
Nested Class Summary |
Nested classes inherited from class java.util.Map |
java.util.Map.Entry |
Field Summary | |
private boolean |
autocleartransaction
|
private boolean |
intransaction
|
private java.util.Map |
map
|
private java.beans.PropertyChangeSupport |
pcs
|
private java.util.Set |
transactionparts
|
Constructor Summary | |
TalkingMap()
Creates a new instance backing the data storage with an internally created, non synchronized HashMap. |
|
TalkingMap(java.util.Map delegate)
Creates a new instance backing the data storage by a user-provided map |
Method Summary | |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
|
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
|
void |
clear()
Clears the map with informing listeners. |
void |
commitTransaction()
Commits a transaction of several entry changes. |
boolean |
containsKey(java.lang.Object key)
|
boolean |
containsValue(java.lang.Object value)
|
java.util.Set |
entrySet()
|
java.lang.Object |
get(java.lang.Object key)
|
java.beans.PropertyChangeListener[] |
getPropertyChangeListeners()
|
java.beans.PropertyChangeListener[] |
getPropertyChangeListeners(java.lang.String propertyName)
|
boolean |
hasListeners(java.lang.String propertyName)
|
boolean |
isAutoClearTransaction()
Asks whether the clear method will encapsulate itself into a transaction automatically. |
boolean |
isEmpty()
|
boolean |
isInTransaction()
Returns whether a transaction is currently running |
java.util.Set |
keySet()
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
|
void |
putAll(java.util.Map t)
|
java.lang.Object |
remove(java.lang.Object key)
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
|
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
|
void |
setAutoClearTransaction(boolean b)
Sets whether the clear method should encapsulate itself into a transaction automatically. |
int |
size()
|
void |
startTransaction()
Starts an unnamed transaction. |
void |
startTransaction(java.lang.String name)
Starts a transaction cumulating several changes to the map without sending events. |
java.lang.String |
toString()
|
java.util.Collection |
values()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
equals, hashCode |
Field Detail |
private java.util.Map map
private java.beans.PropertyChangeSupport pcs
private boolean intransaction
private boolean autocleartransaction
private java.util.Set transactionparts
Constructor Detail |
public TalkingMap(java.util.Map delegate)
public TalkingMap()
Method Detail |
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
public java.beans.PropertyChangeListener[] getPropertyChangeListeners()
public java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String propertyName)
public boolean hasListeners(java.lang.String propertyName)
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
public void startTransaction(java.lang.String name)
name
- A transaction name which is sent as new value in the fired event.public void startTransaction()
public boolean isInTransaction()
public void commitTransaction()
public void setAutoClearTransaction(boolean b)
public boolean isAutoClearTransaction()
public int size()
size
in interface java.util.Map
public void clear()
clear
in interface java.util.Map
public boolean isEmpty()
isEmpty
in interface java.util.Map
public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map
public boolean containsValue(java.lang.Object value)
containsValue
in interface java.util.Map
public java.util.Collection values()
values
in interface java.util.Map
public void putAll(java.util.Map t)
putAll
in interface java.util.Map
public java.util.Set entrySet()
entrySet
in interface java.util.Map
public java.util.Set keySet()
keySet
in interface java.util.Map
public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map
public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface java.util.Map
public java.lang.String toString()
|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |