Module javafx.base

Class ObservableListBase<E>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
javafx.collections.ObservableListBase<E>
Type Parameters:
E - the type of the elements contained in the List
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, SequencedCollection<E>, Observable, ObservableList<E>
Direct Known Subclasses:
ModifiableObservableListBase, TransformationList

public abstract class ObservableListBase<E> extends AbstractList<E> implements ObservableList<E>
Abstract class that serves as a base class for ObservableList implementations. The base class provides two functionalities for the implementing classes. The following example shows how the Change build-up works:
  public void removeOddIndexes() {
      beginChange();
      try {
          for (int i = 1; i < size(); ++i) {
              remove(i);
          }
      } finally {
          endChange();
      }
  }

  public void remove(int i) {
      beginChange();
      try {
          E removed = ... //do some stuff that will actually remove the element at index i
          nextRemove(i, removed);
      } finally {
          endChange();
      }
  }

 
The try/finally blocks in the example are needed only if there's a possibility for an exception to occur inside a beginChange() / endChange() block

Note: If you want to create modifiable ObservableList implementation, consider using ModifiableObservableListBase as a superclass.

Note: In order to create list with sequential access, you should override AbstractList.listIterator(), AbstractList.iterator() methods and use them in AbstractList.get(int), AbstractCollection.size() and other methods accordingly.

Since:
JavaFX 8.0
See Also: