E - the type of the elements contained in the Listpublic abstract class ModifiableObservableListBase<E> extends ObservableListBase<E>
ObservableList implementations that are modifiable.
To implement a modifiable ObservableList class, you just need to implement the following set of methods:
and the notifications and built and fired automatically for you.
Example of a simple ObservableList delegating to another List would look like this:
public class ArrayObservableList<E> extends ModifiableObservableList<E> {
private final List<E> delegate = new ArrayList<>();
public E get(int index) {
return delegate.get(index);
}
public int size() {
return delegate.size();
}
protected void doAdd(int index, E element) {
delegate.add(index, element);
}
protected E doSet(int index, E element) {
return delegate.set(index, element);
}
protected E doRemove(int index) {
return delegate.remove(index);
}
ObservableListBase| Constructor and Description |
|---|
ModifiableObservableListBase() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
E element) |
boolean |
addAll(java.util.Collection<? extends E> c) |
boolean |
addAll(int index,
java.util.Collection<? extends E> c) |
protected abstract void |
doAdd(int index,
E element)
Adds the
element to the List at the position of index. |
protected abstract E |
doRemove(int index)
Removes the element at position of
index. |
protected abstract E |
doSet(int index,
E element)
Sets the
element in the List at the position of index. |
abstract E |
get(int index) |
E |
remove(int index) |
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection<?> c) |
protected void |
removeRange(int fromIndex,
int toIndex) |
boolean |
retainAll(java.util.Collection<?> c) |
E |
set(int index,
E element) |
boolean |
setAll(java.util.Collection<? extends E> col)
Clears the ObservableList and add all elements from the collection.
|
abstract int |
size() |
java.util.List<E> |
subList(int fromIndex,
int toIndex) |
addAll, addListener, addListener, beginChange, endChange, fireChange, hasListeners, nextAdd, nextPermutation, nextRemove, nextRemove, nextReplace, nextSet, nextUpdate, remove, removeAll, removeListener, removeListener, retainAll, setAlladd, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIteratorcontains, containsAll, isEmpty, toArray, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitfiltered, sorted, sortedpublic boolean setAll(java.util.Collection<? extends E> col)
ObservableListsetAll in interface ObservableList<E>setAll in class ObservableListBase<E>col - the collection with elements that will be added to this observableArrayListpublic boolean addAll(java.util.Collection<? extends E> c)
public boolean addAll(int index,
java.util.Collection<? extends E> c)
protected void removeRange(int fromIndex,
int toIndex)
removeRange in class java.util.AbstractList<E>public boolean removeAll(java.util.Collection<?> c)
public boolean retainAll(java.util.Collection<?> c)
public void add(int index,
E element)
public boolean remove(java.lang.Object o)
public E remove(int index)
public java.util.List<E> subList(int fromIndex, int toIndex)
public abstract E get(int index)
public abstract int size()
protected abstract void doAdd(int index,
E element)
element to the List at the position of index.
For the description of possible exceptions, please refer to the documentation
of AbstractList.add(java.lang.Object) method.
index - the position where to add the elementelement - the element that will be addedjava.lang.ClassCastExceptionjava.lang.NullPointerExceptionjava.lang.IllegalArgumentExceptionjava.lang.IndexOutOfBoundsException - if the index is out of range
(index < 0 || index > size())protected abstract E doSet(int index, E element)
element in the List at the position of index.
For the description of possible exceptions, please refer to the documentation
of set(int, java.lang.Object) method.
index - the position where to set the elementelement - the element that will be set at the specified positionjava.lang.ClassCastExceptionjava.lang.NullPointerExceptionjava.lang.IllegalArgumentExceptionjava.lang.IndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= size())protected abstract E doRemove(int index)
index.index - the index of the removed elementjava.lang.IndexOutOfBoundsException - if the index is out of range
(index < 0 || index >= size())Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2023, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.