| org.apache.commons.events.observable.CollectionChangeEventFactory
All known Subclasses: org.apache.commons.events.observable.DefaultCollectionChangeEventFactory,
CollectionChangeEventFactory | public interface CollectionChangeEventFactory extends Cloneable(Code) | |
This interface defines a factory for the production of
CollectionChangeEvents. The purpose of this factory is to provide a means
of instantiating custom, user-defined CollectionChangeEvents without
modification to the BoundCollection or ConstrainedCollection classes.
Should users decide to write their own CollectionChangeEvents which
provide more information than the supplied classes, they would need to
implement this interface and supply an instance to the appropriate
ObservedCollection class.
See Also: CollectionChangeEvent See Also: CollectionChangeType See Also: BoundCollection See Also: ConstrainedCollection author: Bryce Nordgren / USDA Forest Service since: 0.1 |
Method Summary | |
public Object | clone()
Clones a CollectionChangeEventFactory by
constructing a copy of the existing factory, without copying the
event source. | public CollectionChangeEvent | createAdd(Object element, boolean changed) Instantiates and returns a CollectionChangeEvent
of type ADD . | public CollectionChangeEvent | createAddAll(Collection element, boolean changed) Instantiates and returns a CollectionChangeEvent
of type ADD_ALL . | public CollectionChangeEvent | createAddAllIndexed(int index, Collection element, boolean changed) Instantiates and returns a CollectionChangeEvent
of type ADD_ALL_INDEXED . | public CollectionChangeEvent | createAddIndexed(int index, Object element, boolean changed) Instantiates and returns a CollectionChangeEvent
of type ADD_INDEXED . | public CollectionChangeEvent | createAddIterated(int index, Object element, boolean changed) Instantiates and returns a CollectionChangeEvent
of type ADD_ITERATED . | public CollectionChangeEvent | createAddNCopies(int copies, Object element, boolean changed) Instantiates and returns a CollectionChangeEvent
of type ADD_NCOPIES . | public CollectionChangeEvent | createClear(boolean changed) Instantiates and returns a CollectionChangeEvent
of type CLEAR . | public CollectionChangeEvent | createPut(Object key, Object value, Object oldValue, boolean changed) Instantiates and returns a CollectionChangeEvent
of type PUT . | public CollectionChangeEvent | createPutAll(Map newElements, boolean changed) Instantiates and returns a CollectionChangeEvent
of type PUT_ALL . | public CollectionChangeEvent | createRemove(Object element, boolean changed) Instantiates and returns a CollectionChangeEvent
of type REMOVE . | public CollectionChangeEvent | createRemoveAll(Collection element, boolean changed) Instantiates and returns a CollectionChangeEvent
of type REMOVE_ALL . | public CollectionChangeEvent | createRemoveIndexed(int index, Object element, boolean changed) Instantiates and returns a CollectionChangeEvent
of type REMOVE_INDEXED . | public CollectionChangeEvent | createRemoveIterated(int index, Object element, boolean changed) Instantiates and returns a CollectionChangeEvent
of type REMOVE_ITERATED . | public CollectionChangeEvent | createRemoveNCopies(int copies, Object element, boolean changed) Instantiates and returns a CollectionChangeEvent
of type REMOVE_NCOPIES . | public CollectionChangeEvent | createRemoveNext(Object element, boolean changed) Instantiates and returns a CollectionChangeEvent
of type REMOVE_NEXT . | public CollectionChangeEvent | createRetainAll(Collection element, boolean changed) Instantiates and returns a CollectionChangeEvent
of type RETAIN_ALL . | public CollectionChangeEvent | createSetIndexed(int index, Object oldValue, Object element, boolean changed) Instantiates and returns a CollectionChangeEvent
of type SET_INDEXED . | public CollectionChangeEvent | createSetIterated(int index, Object oldValue, Object element, boolean changed) Instantiates and returns a CollectionChangeEvent
of type SET_ITERATED . | public Object | getCollection() Returns the collection responsible for events constructed by this
factory. | public void | setCollection(Object source) Sets the collection responsible for events constructed by this
factory. |
clone | public Object clone()(Code) | |
Clones a CollectionChangeEventFactory by
constructing a copy of the existing factory, without copying the
event source. The user must call setCollection()
on the returned factory prior to use. In effect, this event factory
suffers from inadequate separation of concerns because it is required to
know the details of event construction as well as the specific object
which caused the event. This clone method causes duplication of the
event construction logic while permitting the caller to specify a
different event source. As such, implementors should ensure that all
configuration and setup from the original object is duplicated in the
returned object except for the event source.
This method exists so that sub lists (and other derivative collections)
can use the same event factory as the original list.
A duplicate of this factory, except the event source is not set. |
createAdd | public CollectionChangeEvent createAdd(Object element, boolean changed)(Code) | | Instantiates and returns a CollectionChangeEvent
of type ADD .
Parameters: element - The element added to the collection. Parameters: changed - True if the element was added to the collecton, false otherwise. A new event, properly initialized and ready to fire. |
createAddAll | public CollectionChangeEvent createAddAll(Collection element, boolean changed)(Code) | | Instantiates and returns a CollectionChangeEvent
of type ADD_ALL .
Parameters: element - The collection containing all the elements to be added. Parameters: changed - True if the element was added to the collecton, false otherwise. A new event, properly initialized and ready to fire. |
createAddAllIndexed | public CollectionChangeEvent createAddAllIndexed(int index, Collection element, boolean changed)(Code) | | Instantiates and returns a CollectionChangeEvent
of type ADD_ALL_INDEXED . The "parameter"
property is initialized to contain the index.
Parameters: element - The collection containing all the elements to be added. Parameters: index - The index at which the collection is added. Parameters: changed - True if the element was added to the collecton, false otherwise. A new event, properly initialized and ready to fire. |
createAddIndexed | public CollectionChangeEvent createAddIndexed(int index, Object element, boolean changed)(Code) | | Instantiates and returns a CollectionChangeEvent
of type ADD_INDEXED . The "parameter"
property is initialized to contain the index.
Parameters: element - The element added to the collection. Parameters: index - The index at which the item is added. Parameters: changed - True if the element was added to the collecton, false otherwise. A new event, properly initialized and ready to fire. |
createAddIterated | public CollectionChangeEvent createAddIterated(int index, Object element, boolean changed)(Code) | | Instantiates and returns a CollectionChangeEvent
of type ADD_ITERATED . The "parameter"
property is initialized to contain the index.
Parameters: element - The element added to the collection. Parameters: index - The index at which the item is added. Parameters: changed - True if the element was added to the collecton, false otherwise. A new event, properly initialized and ready to fire. |
createAddNCopies | public CollectionChangeEvent createAddNCopies(int copies, Object element, boolean changed)(Code) | | Instantiates and returns a CollectionChangeEvent
of type ADD_NCOPIES . The "parameter"
property is initialized to contain the specified number of copies.
Parameters: element - The element added to the collection. Parameters: copies - How many copies to add. Parameters: changed - True if the element was added to the collecton, false otherwise. A new event, properly initialized and ready to fire. |
createClear | public CollectionChangeEvent createClear(boolean changed)(Code) | | Instantiates and returns a CollectionChangeEvent
of type CLEAR .
Parameters: changed - True if the collection was nonempty before it was cleared, false otherwise. A new event, properly initialized and ready to fire. |
createPut | public CollectionChangeEvent createPut(Object key, Object value, Object oldValue, boolean changed)(Code) | | Instantiates and returns a CollectionChangeEvent
of type PUT . This is unique among the
CollectionChangeEvents in that a single addition
involves two objects, namely a key-value pair. Additionally,
the if the key was already present in the map, the former
value is returned. The former and present "values" are
stored in oldValue and newValue properties,
respectively. The element property is set to the key.
Parameters: key - The key provided to the put() method. Parameters: value - The value provided to the put() method. Parameters: oldValue - The value returned by the call to put() . Parameters: changed - True if the element was changed,false otherwise. A new event, properly initialized and ready to fire. |
createPutAll | public CollectionChangeEvent createPutAll(Map newElements, boolean changed)(Code) | | Instantiates and returns a CollectionChangeEvent
of type PUT_ALL . The element property
is set to the Map containing all the entries to be added.
Parameters: newElements - The map containing the entries to add. Parameters: changed - True if the element was changed,false otherwise. A new event, properly initialized and ready to fire. |
createRemove | public CollectionChangeEvent createRemove(Object element, boolean changed)(Code) | | Instantiates and returns a CollectionChangeEvent
of type REMOVE .
Parameters: element - The element removed from the collection. Parameters: changed - True if the element was removed from the collecton, false otherwise. A new event, properly initialized and ready to fire. |
createRemoveAll | public CollectionChangeEvent createRemoveAll(Collection element, boolean changed)(Code) | | Instantiates and returns a CollectionChangeEvent
of type REMOVE_ALL .
Parameters: element - The collection containing all items to remove fromthis collection. Parameters: changed - True if the element was removed from the collecton, false otherwise. A new event, properly initialized and ready to fire. |
createRemoveIndexed | public CollectionChangeEvent createRemoveIndexed(int index, Object element, boolean changed)(Code) | | Instantiates and returns a CollectionChangeEvent
of type REMOVE_INDEXED . The "parameter"
property is initialized to contain the index.
Parameters: element - The element removed from the collection. Parameters: index - The index of the removed item. Parameters: changed - True if the element was removed from the collecton, false otherwise. A new event, properly initialized and ready to fire. |
createRemoveIterated | public CollectionChangeEvent createRemoveIterated(int index, Object element, boolean changed)(Code) | | Instantiates and returns a CollectionChangeEvent
of type REMOVE_ITERATED . The "parameter"
property is initialized to contain the index.
Parameters: element - The element removed from the collection. Parameters: index - The index of the iterator when remove was called. Parameters: changed - True if the element was removed from the collecton, false otherwise. A new event, properly initialized and ready to fire. |
createRemoveNCopies | public CollectionChangeEvent createRemoveNCopies(int copies, Object element, boolean changed)(Code) | | Instantiates and returns a CollectionChangeEvent
of type REMOVE_NCOPIES . The "parameter"
property is initialized to contain the index.
Parameters: element - The element removed from the collection. Parameters: copies - The number of copies to remove. Parameters: changed - True if the element was removed from the collecton, false otherwise. A new event, properly initialized and ready to fire. |
createRemoveNext | public CollectionChangeEvent createRemoveNext(Object element, boolean changed)(Code) | | Instantiates and returns a CollectionChangeEvent
of type REMOVE_NEXT . The "parameter"
property is initialized to contain the index. This event
applies to a buffer.
Parameters: element - The element removed from the buffer. Parameters: changed - True if the element was removed from the collecton, false otherwise. A new event, properly initialized and ready to fire. |
createRetainAll | public CollectionChangeEvent createRetainAll(Collection element, boolean changed)(Code) | | Instantiates and returns a CollectionChangeEvent
of type RETAIN_ALL .
Parameters: element - The Collection containing all elements to be retained. Parameters: changed - True if the observed collection was changed. A new event, properly initialized and ready to fire. |
createSetIndexed | public CollectionChangeEvent createSetIndexed(int index, Object oldValue, Object element, boolean changed)(Code) | | Instantiates and returns a CollectionChangeEvent
of type SET_INDEXED . The "parameter"
property is initialized to contain the index. Additionally, the
oldValue and newValue properties are
set to the former and current values of the element at the index,
respectively.
Parameters: element - The new value of the element at index . This is stored in the element and newValue properties. Parameters: oldValue - The former value of the element at index .This is stored in the oldValue property. Parameters: index - The index of the changed item. Parameters: changed - True if the element was changed,false otherwise. A new event, properly initialized and ready to fire. |
createSetIterated | public CollectionChangeEvent createSetIterated(int index, Object oldValue, Object element, boolean changed)(Code) | | Instantiates and returns a CollectionChangeEvent
of type SET_ITERATED . The "parameter"
property is initialized to contain the index. Additionally, the
oldValue and newValue properties are
set to the former and current values of the element at the index,
respectively.
Parameters: element - The new value of the element at index . This is stored in the element and newValue properties. Parameters: oldValue - The former value of the element at index .This is stored in the oldValue property. Parameters: index - The index of the changed item. Parameters: changed - True if the element was changed,false otherwise. A new event, properly initialized and ready to fire. |
getCollection | public Object getCollection()(Code) | | Returns the collection responsible for events constructed by this
factory. This must be one of the decorator classes defined in
this package.
source of CollectionChangeEvents. |
setCollection | public void setCollection(Object source)(Code) | | Sets the collection responsible for events constructed by this
factory. This must be one of the decorator classes defined in
this package. The type of this property is Object
because java.util.Map , while part of the Collections
framework, does not share a common parentage with
java.util.Collection . Legal values are instances or
subclasses of:
- BoundCollection
- ConstrainedCollection
- BoundMap
This method is only allowed to be called
once. Subsequent calls should result in an
UnsupportedOperationException.
Parameters: source - The source of CollectionChangeEvents. throws: IllegalArgumentException - if source is not a BoundCollection or a ConstrainedCollection. throws: UnsupportedOperationException - if the source has already been set. |
|
|