public abstract class AbstractObservableList extends AbstractList implements IObservableList
This class is thread safe. All state accessing methods must be invoked from
the current realm
. Methods for adding and removing
listeners may be invoked from any thread.
modCount
Constructor and Description |
---|
AbstractObservableList() |
AbstractObservableList(Realm realm) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(Object o) |
boolean |
addAll(Collection c) |
boolean |
addAll(int index,
Collection c) |
void |
addChangeListener(IChangeListener listener)
Adds the given change listener to the list of change listeners.
|
void |
addDisposeListener(IDisposeListener listener)
Adds the given dispose listener to the list of dispose listeners.
|
void |
addListChangeListener(IListChangeListener listener)
Adds the given list change listener to the list of list change listeners.
|
void |
addStaleListener(IStaleListener listener)
Adds the given stale listener to the list of stale listeners.
|
protected void |
checkRealm()
Asserts that the realm is the current realm.
|
boolean |
contains(Object o) |
boolean |
containsAll(Collection c) |
void |
dispose()
Disposes of this observable object, removing all listeners registered
with this object, and all listeners this object might have registered on
other objects.
|
protected abstract int |
doGetSize() |
boolean |
equals(Object o) |
protected void |
fireChange()
Fires change event.
|
protected void |
fireListChange(ListDiff diff) |
protected void |
fireStale()
Fires stale event.
|
protected void |
firstListenerAdded() |
Realm |
getRealm()
Returns the realm for this observable.
|
int |
hashCode() |
protected boolean |
hasListeners()
Returns whether this observable list has any registered listeners.
|
int |
indexOf(Object o) |
boolean |
isDisposed()
Returns whether the observable has been disposed
|
boolean |
isEmpty() |
boolean |
isStale()
Returns whether the state of this observable is stale and is expected to
change soon.
|
Iterator |
iterator() |
int |
lastIndexOf(Object o) |
protected void |
lastListenerRemoved() |
Object |
move(int oldIndex,
int newIndex)
Moves the element located at
oldIndex to
newIndex . |
boolean |
remove(Object o) |
boolean |
removeAll(Collection c) |
void |
removeChangeListener(IChangeListener listener)
Removes the given change listener from the list of change listeners.
|
void |
removeDisposeListener(IDisposeListener listener)
Removes the given dispose listener from the list of dispose listeners.
|
void |
removeListChangeListener(IListChangeListener listener)
Removes the given list change listener from the list of list change listeners.
|
void |
removeStaleListener(IStaleListener listener)
Removes the given stale listener from the list of stale listeners.
|
boolean |
retainAll(Collection c) |
int |
size() |
Object[] |
toArray() |
Object[] |
toArray(Object[] a) |
add, clear, get, listIterator, listIterator, remove, removeRange, set, subList
toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
get, getElementType, listIterator, listIterator, remove, set, subList
add, clear, replaceAll, sort, spliterator
parallelStream, removeIf, stream
public AbstractObservableList(Realm realm)
realm
- public AbstractObservableList()
protected boolean hasListeners()
public boolean isStale()
IObservable
isStale
in interface IObservable
public void addListChangeListener(IListChangeListener listener)
IObservableList
addListChangeListener
in interface IObservableList
public void removeListChangeListener(IListChangeListener listener)
IObservableList
removeListChangeListener
in interface IObservableList
protected void fireListChange(ListDiff diff)
public void addChangeListener(IChangeListener listener)
IObservable
addChangeListener
in interface IObservable
public void removeChangeListener(IChangeListener listener)
IObservable
removeChangeListener
in interface IObservable
public void addStaleListener(IStaleListener listener)
IObservable
addStaleListener
in interface IObservable
IObservable.isStale()
public void removeStaleListener(IStaleListener listener)
IObservable
removeStaleListener
in interface IObservable
public void addDisposeListener(IDisposeListener listener)
IObservable
addDisposeListener
in interface IObservable
listener
- the listener to addpublic void removeDisposeListener(IDisposeListener listener)
IObservable
removeDisposeListener
in interface IObservable
listener
- the listener to removeprotected void fireChange()
protected void fireStale()
protected void firstListenerAdded()
protected void lastListenerRemoved()
public boolean isDisposed()
IObservable
isDisposed
in interface IObservable
public void dispose()
IObservable
dispose
in interface IObservable
public final int size()
size
in interface Collection
size
in interface List
size
in interface IObservableList
size
in class AbstractCollection
protected abstract int doGetSize()
public boolean isEmpty()
isEmpty
in interface Collection
isEmpty
in interface List
isEmpty
in interface IObservableList
isEmpty
in class AbstractCollection
public boolean contains(Object o)
contains
in interface Collection
contains
in interface List
contains
in interface IObservableList
contains
in class AbstractCollection
public Iterator iterator()
iterator
in interface Iterable
iterator
in interface Collection
iterator
in interface List
iterator
in interface IObservableList
iterator
in class AbstractList
public Object[] toArray()
toArray
in interface Collection
toArray
in interface List
toArray
in interface IObservableList
toArray
in class AbstractCollection
public Object[] toArray(Object[] a)
toArray
in interface Collection
toArray
in interface List
toArray
in interface IObservableList
toArray
in class AbstractCollection
public boolean add(Object o)
add
in interface Collection
add
in interface List
add
in interface IObservableList
add
in class AbstractList
public Object move(int oldIndex, int newIndex)
oldIndex
to
newIndex
. This method is equivalent to calling
add(newIndex, remove(oldIndex))
.
Subclasses should override this method to deliver list change
notification for the remove and add operations in the same
ListChangeEvent, as this allows ListDiff.accept(ListDiffVisitor)
to recognize the operation as a move.
move
in interface IObservableList
oldIndex
- the element's position before the move. Must be within the
range 0 <= oldIndex < size()
.newIndex
- the element's position after the move. Must be within the
range 0 <= newIndex < size()
.IndexOutOfBoundsException
- if either argument is out of range (0 <= index < size()
).ListDiffVisitor.handleMove(int, int, Object)
,
ListDiff.accept(ListDiffVisitor)
public boolean remove(Object o)
remove
in interface Collection
remove
in interface List
remove
in interface IObservableList
remove
in class AbstractCollection
public boolean containsAll(Collection c)
containsAll
in interface Collection
containsAll
in interface List
containsAll
in interface IObservableList
containsAll
in class AbstractCollection
public boolean addAll(Collection c)
addAll
in interface Collection
addAll
in interface List
addAll
in interface IObservableList
addAll
in class AbstractCollection
public boolean addAll(int index, Collection c)
addAll
in interface List
addAll
in interface IObservableList
addAll
in class AbstractList
public boolean removeAll(Collection c)
removeAll
in interface Collection
removeAll
in interface List
removeAll
in interface IObservableList
removeAll
in class AbstractCollection
public boolean retainAll(Collection c)
retainAll
in interface Collection
retainAll
in interface List
retainAll
in interface IObservableList
retainAll
in class AbstractCollection
public boolean equals(Object o)
equals
in interface Collection
equals
in interface List
equals
in interface IObservableList
equals
in class AbstractList
public int hashCode()
hashCode
in interface Collection
hashCode
in interface List
hashCode
in interface IObservableList
hashCode
in class AbstractList
public int indexOf(Object o)
indexOf
in interface List
indexOf
in interface IObservableList
indexOf
in class AbstractList
public int lastIndexOf(Object o)
lastIndexOf
in interface List
lastIndexOf
in interface IObservableList
lastIndexOf
in class AbstractList
public Realm getRealm()
IObservable
Because observables can only be accessed from within one realm, and they always fire events on that realm, their state can be observed in an incremental way. It is always safe to call getters of an observable from within a change listener attached to that observable.
getRealm
in interface IObservable
protected void checkRealm()
AssertionFailedException
- if the realm is not the current realmRealm.isCurrent()
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.