| org.apache.commons.events.observable.BoundMap
All known Subclasses: org.apache.commons.events.observable.BoundSortedMap,
BoundMap | public class BoundMap extends AbstractMapDecorator (Code) | |
Decorates a Map implementation with a bound
property named "collection".
Each modifying method call made on this Map is
handled as a change to the "collection" property. This
facility serves to notify subscribers of a change to the collection
but does not allow users the option of vetoing the change. To
gain the ability to veto the change, use a
ConstrainedMap decorater.
Due to the fact that a Map offers several "views" of the
same data, some confusion may arise as to what action caused a
particular event. For instance, entries in the map may be
deleted by Map.values().remove(object) . There is no
known method, short of digging into the implementation of a Map,
to determine which key-value pair was deleted by this operation,
particularly if there is more than one occurence of a specific
value. (Conversely, there is also no means of controlling which
key-value pair is deleted by this method; therefore it's not a
terribly smart thing to do.)
This implementation of a bound map makes no attempt to interpret
events generated by these alternate views of the data. It merely
ensures that registered listeners receive all events generated
by any view of the Map's data. It is left to the client
to interpret the events generated by their map's usage.
since: Commons Events 1.0 author: Bryce Nordgren / USDA Forest Service |
BoundMap | protected BoundMap(Map map)(Code) | | Constructor that wraps (not copies) and uses the
DefaultCollectionChangeEventFactory .
This should be used if the default change events are considered
adequate to the task of monitoring changes to the collection.
Parameters: map - the map to decorate, must not be null throws: IllegalArgumentException - if the map is null |
addPropertyChangeListener | public void addPropertyChangeListener(PropertyChangeListener l)(Code) | | Registers a listener with this decorator. The Listener must
implement the PropertyChangeListener interface.
Adding a listener more than once will result in more than
one notification for each change event.
Parameters: l - The listener to register with this decorator. |
clear | public void clear()(Code) | | |
createEventRepeater | EventRepeater createEventRepeater()(Code) | | Package private method to create an EventRepeater from within the
context of a particular BoundCollection object. This event repeater
will relay events to all property change listeners subscribed to this
bound collection.
the event repeater object. |
decorate | public static BoundMap decorate(Map map)(Code) | | Factory method to decorate an existing Map using the provided
DefaultCollectionChangeEventFactory .
This should be used if the default change events are considered
adequate to the task of monitoring changes to the collection.
Parameters: map - the map to decorate, must not be null throws: IllegalArgumentException - if the map is null |
entrySet | public Set entrySet()(Code) | |
Returns a Set view of the Map entries. This set is backed by the
map, so changes to either view is reflected in the other.
Accordingly, our CollectionChangeEvents are sent to the
Set's subscribers, and the Set's CollectionChangeEvents are sent
to our subscribers.
The interface contract for this method specifies that most
methods of removal are supported, but no methods of addition.
An entry set view decorated with a BoundSet. |
firePropertyChange | protected void firePropertyChange(PropertyChangeEvent evt)(Code) | | This is a utility method to allow subclasses to fire property change
events.
Parameters: evt - The pre-constructed event. |
keySet | public Set keySet()(Code) | |
Returns a Set view of the Map's keys. This set is backed by the
map, so changes to either view is reflected in the other.
Accordingly, our CollectionChangeEvents are sent to the
Set's subscribers, and the Set's CollectionChangeEvents are sent
to our subscribers.
The interface contract for this method specifies that most
methods of removal are supported, but no methods of addition.
A set view of the keys decorated with a BoundSet. |
removePropertyChangeListener | public void removePropertyChangeListener(PropertyChangeListener l)(Code) | | Unregisters a listener from this decorator. The Listener must
implement the PropertyChangeListener interface.
If the listener was registered more than once, calling this method
cancels out a single registration. If the listener is not
registered with this object, no action is taken.
Parameters: l - The listener to unregister with this decorator. |
values | public Collection values()(Code) | |
Returns a Collection view of the Map's values. This collection
is backed by the
map, so changes to either view is reflected in the other.
Accordingly, our CollectionChangeEvents are sent to the
Collection's subscribers, and the Collection's CollectionChangeEvents
are sent to our subscribers.
The interface contract for this method specifies that most
methods of removal are supported, but no methods of addition.
A collection view of the values decorated with a BoundCollection. |
|
|