public final class ListEventAssembler<E> extends java.lang.Object implements IListEventAssembler<E>
Atomic sets of changes may involve many lines of changes and many blocks of changes. They are committed to the queue in one action. No other threads should be creating a change on the same list change queue when an atomic change is being created.
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
allowNestedEvents
whether to allow nested events
|
protected int |
eventLevel
the event level is the number of nested events
|
protected int[] |
reorderMap
the current reordering array if this change is a reorder
|
protected EventList<E> |
sourceList
the list that this tracks changes for
|
| Constructor and Description |
|---|
ListEventAssembler(EventList<E> sourceList,
ListEventPublisher publisher)
Creates a new ListEventAssembler that tracks changes for the specified list.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChange(int type,
int startIndex,
java.util.List<ObjectChange<E>> changeEvents)
Adds a block of changes to the set of list changes.
|
void |
addChange(int type,
int index,
ObjectChange<E> event)
Convenience method for appending a single change of the specified type.
|
void |
addListEventListener(ListEventListener<? super E> listChangeListener)
Registers the specified listener to be notified whenever new changes
are appended to this list change sequence.
|
static <T> void |
applyListEvent(ListEvent<T> event,
java.util.List<T> target) |
static <T> void |
applyListEvent(ListEvent<T> event,
java.util.List<T> target,
ListEventAssembler<T> targetAssembler) |
void |
beginEvent()
Starts a new atomic change to this list change queue.
|
void |
beginEvent(boolean allowNestedEvents)
Starts a new atomic change to this list change queue.
|
void |
commitEvent()
Commits the current atomic change to this list change queue.
|
static ListEventPublisher |
createListEventPublisher()
Deprecated.
|
protected ListEventAssembler<E> |
deepCopy() |
void |
discardEvent()
Discards the current atomic change to this list change queue.
|
void |
elementDeleted(int index,
E oldValue)
Add to the current ListEvent the removal of the element at the specified
index, with the specified previous value.
|
void |
elementDeleted(int index,
java.util.List<E> oldValues)
Adds a block of removal events
|
void |
elementInserted(int index,
E newValue)
Add to the current ListEvent the insert of the element at
the specified index, with the specified previous value.
|
void |
elementInserted(int index,
java.util.List<E> newValues)
Adds a block of insert events.
|
void |
elementUpdated(int index,
E oldValue)
Deprecated.
replaced with
elementUpdated(int, Object, Object). |
void |
elementUpdated(int index,
E oldValue,
E newValue)
Add to the current ListEvent the update of the element at the specified
index, with the specified previous value.
|
void |
elementUpdated(int index,
java.util.List<E> oldValues,
java.util.List<E> newValues) |
void |
elementUpdated(int index,
java.util.List<ObjectChange<E>> changes)
Adds a block of update events
|
void |
elementUpdated(int index,
ObjectChange<E> change) |
ListEvent<E> |
emptyEvent() |
void |
forwardEvent(ListEvent<?> listChanges)
Forwards the event.
|
ListEvent<E> |
getCurrentChanges()
Returns the uncommited changes of the current event level
|
java.util.List<ListEventListener<E>> |
getListEventListeners()
Get all
ListEventListeners observing the EventList. |
boolean |
isEventEmpty()
Returns true if the current atomic change to this list change
queue is empty; false otherwise.
|
boolean |
isEventInProgress()
Indicate whether or not an event is in progress.
|
ListEventAssembler<E> |
newAssembler() |
void |
removeListEventListener(ListEventListener<? super E> listChangeListener)
Removes the specified listener from receiving notification when new
changes are appended to this list change sequence.
|
void |
reorder(int[] reorderMap,
java.util.List<ObjectChange<E>> changes)
Sets the current event as a reordering.
|
protected int eventLevel
protected boolean allowNestedEvents
protected int[] reorderMap
public ListEventAssembler(EventList<E> sourceList, ListEventPublisher publisher)
@Deprecated public static ListEventPublisher createListEventPublisher()
createListEventPublisher in interface IListEventAssembler<E>public boolean isEventInProgress()
isEventInProgress in interface IListEventAssembler<E>public void beginEvent()
This simple change event does not support change events nested within. To allow other methods to nest change events within a change event, use beginEvent(true).
beginEvent in interface IListEventAssembler<E>public void beginEvent(boolean allowNestedEvents)
beginEvent in interface IListEventAssembler<E>allowNestedEvents - false to throw an exception
if another call to beginEvent() is made before
the next call to commitEvent(). Nested events allow
multiple method's events to be composed into a single
event.public void elementInserted(int index,
E newValue)
elementInserted in interface IListEventAssembler<E>public void elementInserted(int index,
java.util.List<E> newValues)
elementInserted in interface IListEventAssembler<E>public void elementDeleted(int index,
E oldValue)
elementDeleted in interface IListEventAssembler<E>public void elementDeleted(int index,
java.util.List<E> oldValues)
elementDeleted in interface IListEventAssembler<E>public void elementUpdated(int index,
java.util.List<ObjectChange<E>> changes)
elementUpdated in interface IListEventAssembler<E>public void elementUpdated(int index,
E oldValue,
E newValue)
elementUpdated in interface IListEventAssembler<E>public void elementUpdated(int index,
java.util.List<E> oldValues,
java.util.List<E> newValues)
elementUpdated in interface IListEventAssembler<E>public void elementUpdated(int index,
ObjectChange<E> change)
elementUpdated in interface IListEventAssembler<E>@Deprecated
public void elementUpdated(int index,
E oldValue)
elementUpdated(int, Object, Object).public void addChange(int type,
int index,
ObjectChange<E> event)
addChange in interface IListEventAssembler<E>public void addChange(int type,
int startIndex,
java.util.List<ObjectChange<E>> changeEvents)
addChange in interface IListEventAssembler<E>public void reorder(int[] reorderMap,
java.util.List<ObjectChange<E>> changes)
reorder in interface IListEventAssembler<E>public void forwardEvent(ListEvent<?> listChanges)
Note that this method should be preferred to manually forwarding events because it is heavily optimized.
Note that currently this implementation does a best effort to preserve reorderings. This means that a reordering is lost if it is combined with any other ListEvent.
forwardEvent in interface IListEventAssembler<E>public void commitEvent()
If the current event is nested within a greater event, this will simply change the nesting level so that further changes are applied directly to the parent change.
commitEvent in interface IListEventAssembler<E>public void discardEvent()
The caller of this method is responsible for returning the EventList to its state before the event began. If they fail to do so, the EventList pipeline may be in an inconsistent state.
If the current event is nested within a greater event, this will discard changes at the current nesting level and that further changes are still applied directly to the parent change.
discardEvent in interface IListEventAssembler<E>public boolean isEventEmpty()
isEventEmpty in interface IListEventAssembler<E>public void addListEventListener(ListEventListener<? super E> listChangeListener)
For each listener, a ListEvent is created, which provides a read-only view to the list changes in the list. The same ListChangeView object is used for all notifications to the specified listener, so if a listener does not process a set of changes, those changes will persist in the next notification.
addListEventListener in interface IListEventAssembler<E>listChangeListener - event listener != nulljava.lang.NullPointerException - if the specified listener is nullpublic void removeListEventListener(ListEventListener<? super E> listChangeListener)
This uses the == identity comparison to find the listener
instead of equals(). This is because multiple Lists may be
listening and therefore equals() may be ambiguous.
removeListEventListener in interface IListEventAssembler<E>listChangeListener - event listener != nulljava.lang.NullPointerException - if the specified listener is nulljava.lang.IllegalArgumentException - if the specified listener wasn't added beforepublic java.util.List<ListEventListener<E>> getListEventListeners()
ListEventListeners observing the EventList.getListEventListeners in interface IListEventAssembler<E>public ListEvent<E> getCurrentChanges()
getCurrentChanges in interface IListEventAssembler<E>public ListEvent<E> emptyEvent()
emptyEvent in interface IListEventAssembler<E>public ListEventAssembler<E> newAssembler()
newAssembler in interface IListEventAssembler<E>protected ListEventAssembler<E> deepCopy()
public static <T> void applyListEvent(ListEvent<T> event, java.util.List<T> target)
public static <T> void applyListEvent(ListEvent<T> event, java.util.List<T> target, ListEventAssembler<T> targetAssembler)
Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by swimmesberger at Mon Feb 25 11:02:37 CET 2019