T
- actual array instance typepublic interface ObservableArray<T extends ObservableArray<T>> extends Observable
ObservableArray
is an array that allows listeners to track changes
when they occur. In order to track changes, the internal array
is encapsulated and there is no direct access available from the outside.
Bulk operations are supported but they always do a copy of the data range.
You can find them in subclasses as they deal with primitive arrays directly.
Implementations have both capacity
, which is internal array length,
and size
. If size needs to be increased beyond capacity, the capacity
increases to match that new size. Use trimToSize()
method
to shrink it.
ArrayChangeListener
Modifier and Type | Method and Description |
---|---|
void |
addListener(ArrayChangeListener<T> listener)
Add a listener to this observable array.
|
void |
clear()
Empties the array by resizing it to 0.
|
void |
ensureCapacity(int capacity)
Grows the capacity of this array if the current capacity is less than
given
capacity , does nothing if it already exceeds
the capacity . |
void |
removeListener(ArrayChangeListener<T> listener)
Tries to remove a listener from this observable array.
|
void |
resize(int size)
Sets new length of data in this array.
|
int |
size()
Retrieves length of data in this array.
|
void |
trimToSize()
Shrinks the capacity to the current size of data in the array.
|
addListener, removeListener
void addListener(ArrayChangeListener<T> listener)
listener
- the listener for listening to the array changesNullPointerException
- if listener
is null
void removeListener(ArrayChangeListener<T> listener)
listener
- a listener to removeNullPointerException
- if listener
is null
void resize(int size)
size
- new length of data in this arrayNegativeArraySizeException
- if size is negativevoid ensureCapacity(int capacity)
capacity
, does nothing if it already exceeds
the capacity
.capacity
- void trimToSize()
void clear()
trimToSize()
int size()
Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.