Spec-Zone .ru
спецификации, руководства, описания, API
|
E
- the list element typepublic abstract static class ListChangeListener.Change<E>
extends java.lang.Object
getRemoved()
method returns a list of elements that have been
replaced or removed from the list.[getFrom(), getTo())
is the range of elements
in the list that contain new elements. Note that this is a half-open
interval, so if the range is empty, addedFrom will be equal to
addedTo. This will occur, for example, if the operation was a
deletion and will mark the index where the deletion happenedObservableList<Item> theList = ...;
{
theList.addListener(new ListChangeListener<Item>() {
public void onChanged(Change<Item> c) {
while (c.next()) {
if (c.wasPermutated()) {
for (int i = c.getFrom(); i < c.getTo(); ++i) {
//permutate
}
} else if (c.wasUpdated()) {
//update item
} else {
for (Item remitem : c.getRemoved()) {
remitem.remove(Outer.this);
}
for (Item additem : c.getAddedSubList()) {
additem.add(Outer.this);
}
}
}
}
});
}
Warning: This class directly accesses the source list to acquire information about the changes.
Constructor and Description |
---|
ListChangeListener.Change(ObservableList<E> list)
Constructs a new change done to a list.
|
Modifier and Type | Method and Description |
---|---|
int |
getAddedSize()
Size of the interval that was added.
|
java.util.List<E> |
getAddedSubList()
To get a subList view of the list that contains only the elements
added, use getAddedSubList() method.
|
abstract int |
getFrom()
If wasAdded is true, the interval contains all the values that were added.
|
ObservableList<E> |
getList()
The source list of the change.
|
protected abstract int[] |
getPermutation()
If this change is an permutation, it returns an integer array
that describes the permutation.
|
int |
getPermutation(int i)
By calling these method, you can observe the permutation that happened.
|
abstract java.util.List<E> |
getRemoved()
An immutable list of removed/replaced elements.
|
int |
getRemovedSize()
Size of getRemoved() list.
|
abstract int |
getTo()
The end of the change interval.
|
abstract boolean |
next()
Go to the next change.
|
abstract void |
reset()
Reset to the initial stage.
|
boolean |
wasAdded()
Indicates if elements were added during this change
|
boolean |
wasPermutated()
Indicates if the change was only a permutation.
|
boolean |
wasRemoved()
Indicates if elements were removed during this change
|
boolean |
wasReplaced()
Indicates if elements were replaced during this change
|
boolean |
wasUpdated()
Indicates that the elements between getFrom() (inclusive)
to getTo() exclusive has changed.
|
public ListChangeListener.Change(ObservableList<E> list)
list
- that was changedpublic abstract boolean next()
public abstract void reset()
public ObservableList<E> getList()
public abstract int getFrom()
java.lang.IllegalStateException
- if this Change is in initial statepublic abstract int getTo()
java.lang.IllegalStateException
- if this Change is in initial stategetFrom()
public abstract java.util.List<E> getRemoved()
java.lang.IllegalStateException
- if this Change is in initial statepublic boolean wasPermutated()
java.lang.IllegalStateException
- if this Change is in initial statepublic boolean wasAdded()
java.lang.IllegalStateException
- if this Change is in initial statepublic boolean wasRemoved()
java.lang.IllegalStateException
- if this Change is in initial statepublic boolean wasReplaced()
as wasAdded() && wasRemoved()
java.lang.IllegalStateException
- if this Change is in initial statepublic boolean wasUpdated()
public java.util.List<E> getAddedSubList()
c.getList().subList(c.getFrom(), c.getTo());
for (Node n : change.getAddedSubList()) {
// do something
}
java.lang.IllegalStateException
- if this Change is in initial statepublic int getRemovedSize()
java.lang.IllegalStateException
- if this Change is in initial statepublic int getAddedSize()
java.lang.IllegalStateException
- if this Change is in initial stateprotected abstract int[] getPermutation()
wasPermutated()
and getPermutation(int)
methods.java.lang.IllegalStateException
- if this Change is in initial statepublic int getPermutation(int i)
change.getPermutation()(oldIndex);Note: default implementation of this method takes the information from
getPermutation()
method. You don't have to override this method.i
- the old index that contained the element prior to this changeCopyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. Use is subject to