public class ObservableElementList<E> extends TransformedList<E,E>
ObservableElementList.Connector
in the constructor
which contains the necessary logic for registering and unregistering a
listener capable of detecting modifications to an observable list element.
Warning: This class is
thread ready but not thread safe. See EventList
for an example
of thread safe code.
EventList Overview | |
Writable: | yes |
Concurrency: | thread ready, not thread safe; elementChanged(), however, is thread ready |
Performance: | inserts: O(1), deletes: O(1), updates: O(1), elementChanged: O(n) |
Memory: | 8 bytes per element |
Unit Tests: | ObservableElementListTest |
Issues: | N/A |
GlazedLists.beanConnector(Class)
,
GlazedLists.beanConnector(Class, String, String)
,
RFE 157Modifier and Type | Class and Description |
---|---|
static interface |
ObservableElementList.Connector<E>
An interface defining the methods required for registering and
unregistering change listeners on list elements within an
ObservableElementList . |
source
publisher, readWriteLock, updates
Constructor and Description |
---|
ObservableElementList(EventList<E> source,
ObservableElementList.Connector<? super E> elementConnector)
Constructs an
ObservableElementList which wraps the given
source and uses the given elementConnector to
register/unregister change listeners on elements of the
source . |
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Releases the resources consumed by this
TransformedList so that
it may eventually be garbage collected. |
void |
elementChanged(java.lang.Object listElement)
Handle a listener being notified for the specified
listElement . |
protected boolean |
isWritable()
Gets whether the source
EventList is writable via this API. |
void |
listChanged(ListEvent<E> listChanges)
When the underlying list changes, this notification allows the
object to repaint itself or update itself as necessary.
|
add, addAll, clear, get, getSourceIndex, remove, removeAll, retainAll, set, size
add, addAll, addListEventListener, contains, containsAll, equals, getPublisher, getReadWriteLock, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeListEventListener, subList, toArray, toArray, toString
public ObservableElementList(EventList<E> source, ObservableElementList.Connector<? super E> elementConnector)
ObservableElementList
which wraps the given
source
and uses the given elementConnector
to
register/unregister change listeners on elements of the
source
.source
- the EventList
to transformelementConnector
- the ObservableElementList.Connector
to consult when list
elements are added or removed and thus element listeners must be
registered or unregistered. Note that this constructor attachs
this list to the given elementConnector
by calling
ObservableElementList.Connector.setObservableElementList(ObservableElementList)
.public void listChanged(ListEvent<E> listChanges)
TransformedList
It is mandatory that the calling thread has obtained the write lock on the source list. This is because the calling thread will have written to the source list to cause this event. This condition guarantees that no writes can occur while the listener is handling this event. It is an error to write to the source list while processing an event.
listChanged
in interface ListEventListener<E>
listChanged
in class TransformedList<E,E>
listChanges
- a ListEvent
describing the changes to the listprotected boolean isWritable()
TransformedList
EventList
is writable via this API.
Extending classes must override this method in order to make themselves writable.
isWritable
in class TransformedList<E,E>
public void dispose()
TransformedList
so that
it may eventually be garbage collected.
In this case of this TransformedList
, it uses the
ObservableElementList.Connector
to remove all listeners from their associated list
elements and finally removes the reference to this list from the
Connector by calling
ObservableElementList.Connector.setObservableElementList(ObservableElementList)
with a
null
argument.
Warning: It is an error
to call any method on a TransformedList
after it has been disposed.
public void elementChanged(java.lang.Object listElement)
listElement
.
This method causes a ListEvent to be fired from this EventList indicating
an update occurred at all locations of the given listElement
.
Note that listElement must be the exact object located within this list
(i.e. listElement == get(i) for some i >= 0
).
This method acquires the write lock for this list before locating the
listElement
and broadcasting its update. It is assumed that
this method may be called on any Thread, so to decrease the burdens of
the caller in achieving multi-threaded correctness, this method is
Thread ready.
listElement
- the list element which has been modifiedGlazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by builder at 2016-02-12 23:17