Top Description Constructors Methods
javafx.beans.binding

public abstract Class ListExpression<E>

extends Object
implements ObservableListValue<E>
Class Inheritance
All Implemented Interfaces
javafx.beans.value.ObservableListValue, javafx.collections.ObservableList, javafx.beans.Observable, java.util.List, java.util.SequencedCollection, java.util.Collection, java.lang.Iterable, javafx.beans.value.ObservableObjectValue, javafx.beans.value.ObservableValue
Known Direct Subclasses
javafx.beans.property.ReadOnlyListProperty, javafx.beans.binding.ListBinding
Type Parameters
<E>
the type of the List elements.
Imports
com.sun.javafx.binding.StringFormatter, javafx.beans.property.ReadOnlyBooleanProperty, .ReadOnlyIntegerProperty, javafx.beans.value.ObservableIntegerValue, .ObservableListValue, javafx.collections.FXCollections, .ObservableList, java.util.Collection, .Iterator, .List, .ListIterator

ListExpression is an javafx.beans.value.ObservableListValue plus additional convenience methods to generate bindings in a fluent style.

A concrete sub-class of ListExpression has to implement the method javafx.beans.value.ObservableListValue#get(), which provides the actual value of this expression.

If the wrapped list of a ListExpression is null, all methods implementing the List interface will behave as if they were applied to an immutable empty list.

Since
JavaFX 2.1

Constructor Summary

AccessConstructor and Description
public
ListExpression()

Creates a default ListExpression.

Method Summary

Modifier and TypeMethod and Description
public boolean
add(E element)

Implements java.util.List.add.

Appends the specified element to the end of this list (optional operation).

public void
add(int i, E element)

Implements java.util.List.add.

Inserts the specified element at the specified position in this list (optional operation).

public boolean
addAll(Collection<? extends E> elements)

Implements java.util.List.addAll.

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).

public boolean
addAll(int i, Collection<? extends E> elements)

Implements java.util.List.addAll.

Inserts all of the elements in the specified collection into this list at the specified position (optional operation).

public boolean
addAll(E... elements)

Implements javafx.collections.ObservableList.addAll.

A convenience method for var-arg addition of elements.

public StringBinding

Returns:

the new StringBinding
asString
()

Creates a javafx.beans.binding.StringBinding that holds the value of the ListExpression turned into a String.

public void
clear()

Implements java.util.List.clear.

Removes all of the elements from this list (optional operation).

public boolean
contains(Object obj)

Implements java.util.List.contains.

Returns true if this list contains the specified element.

public boolean
containsAll(Collection<?> objects)

Implements java.util.List.containsAll.

Returns true if this list contains all of the elements of the specified collection.

public abstract ReadOnlyBooleanProperty

Returns:

the ReadOnlyBooleanProperty
emptyProperty
()

A boolean property that is true, if the list is empty.

public E
get(int i)

Implements java.util.List.get.

Returns the element at the specified position in this list.

private ObservableList<E>
public int

Returns:

the size
getSize
()

The size of the list

public ObservableList<E>
getValue()

Implements javafx.beans.value.ObservableValue.getValue.

Returns the current value of this ObservableValue

public int
indexOf(Object obj)

Implements java.util.List.indexOf.

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.

public boolean
isEmpty()

Implements java.util.List.isEmpty.

Returns true if this list contains no elements.

public BooleanBinding

Returns:

the new BooleanBinding
isEqualTo
(final ObservableList<?>
the other ObservableList
other
)

Creates a new BooleanBinding that holds true if this list is equal to another javafx.collections.ObservableList.

public BooleanBinding

Returns:

the new BooleanBinding
isNotEqualTo
(final ObservableList<?>
the other ObservableList
other
)

Creates a new BooleanBinding that holds true if this list is not equal to another javafx.collections.ObservableList.

public BooleanBinding

Returns:

the new BooleanBinding
isNotNull
()

Creates a new BooleanBinding that holds true if the wrapped list is not null.

public BooleanBinding

Returns:

the new BooleanBinding
isNull
()

Creates a new BooleanBinding that holds true if the wrapped list is null.

public Iterator<E>
iterator()

Implements java.util.List.iterator.

Returns an iterator over the elements in this list in proper sequence.

public int
lastIndexOf(Object obj)

Implements java.util.List.lastIndexOf.

Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.

public static <
the type of the wrapped List
E
>
ListExpression<E>

Returns:

A ListExpression that wraps the ObservableListValue if necessary
listExpression
(final ObservableListValue<E>
The source ObservableListValue
value
)

Returns a ListExpression that wraps a javafx.beans.value.ObservableListValue.

public ListIterator<E>
listIterator()

Implements java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence).

public ListIterator<E>
listIterator(int i)

Implements java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list.

public boolean
remove(Object obj)

Implements java.util.List.remove.

Removes the first occurrence of the specified element from this list, if it is present (optional operation).

public E
remove(int i)

Implements java.util.List.remove.

Removes the element at the specified position in this list (optional operation).

public void
remove(int from, int to)

Implements javafx.collections.ObservableList.remove.

A simplified way of calling sublist(from, to).clear().

public boolean
removeAll(Collection<?> objects)

Implements java.util.List.removeAll.

Removes from this list all of its elements that are contained in the specified collection (optional operation).

public boolean
removeAll(E... elements)

Implements javafx.collections.ObservableList.removeAll.

A convenience method for var-arg usage of the removeAll method.

public boolean
retainAll(Collection<?> objects)

Implements java.util.List.retainAll.

Retains only the elements in this list that are contained in the specified collection (optional operation).

public boolean
retainAll(E... elements)

Implements javafx.collections.ObservableList.retainAll.

A convenience method for var-arg usage of the retainAll method.

public E
set(int i, E element)

Implements java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).

public boolean
setAll(E... elements)

Implements javafx.collections.ObservableList.setAll.

Clears the ObservableList and adds all the elements passed as var-args.

public boolean
setAll(Collection<? extends E> elements)

Implements javafx.collections.ObservableList.setAll.

Clears the ObservableList and adds all elements from the collection.

public int
size()

Implements java.util.List.size.

Returns the number of elements in this list.

public abstract ReadOnlyIntegerProperty

Returns:

the property
sizeProperty
()

An integer property that represents the size of the list.

public List<E>
subList(int from, int to)

Implements java.util.List.subList.

Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.

public Object[]
toArray()

Implements java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element).

public <T> T[]
toArray(T[] array)

Implements java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array.

public ObjectBinding<E>

Returns:

the ObjectBinding
valueAt
(int
the index of the element
index
)

Creates a new ObjectBinding that contains the element at the specified position.

public ObjectBinding<E>

Returns:

the ObjectBinding
valueAt
(ObservableIntegerValue
the index of the element
index
)

Creates a new ObjectBinding that contains the element at the specified position.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ListExpressionback to summary
public ListExpression()

Creates a default ListExpression.

Method Detail

addback to summary
public boolean add(E element)

Implements java.util.List.add.

Doc from java.util.List.add.

Appends the specified element to the end of this list (optional operation).

Lists that support this operation may place limitations on what elements may be added to this list. In particular, some lists will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. List classes should clearly specify in their documentation any restrictions on what elements may be added.

Annotations
@Override
addback to summary
public void add(int i, E element)

Implements java.util.List.add.

Doc from java.util.List.add.

Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Annotations
@Override
addAllback to summary
public boolean addAll(Collection<? extends E> elements)

Implements java.util.List.addAll.

Doc from java.util.List.addAll.

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)

Annotations
@Override
addAllback to summary
public boolean addAll(int i, Collection<? extends E> elements)

Implements java.util.List.addAll.

Doc from java.util.List.addAll.

Inserts all of the elements in the specified collection into this list at the specified position (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in this list in the order that they are returned by the specified collection's iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)

Annotations
@Override
addAllback to summary
public boolean addAll(E... elements)

Implements javafx.collections.ObservableList.addAll.

Doc from javafx.collections.ObservableList.addAll.

A convenience method for var-arg addition of elements.

Annotations
@Override
asStringback to summary
public StringBinding asString()

Creates a javafx.beans.binding.StringBinding that holds the value of the ListExpression turned into a String. If the value of this ListExpression changes, the value of the StringBinding will be updated automatically.

Returns:StringBinding

the new StringBinding

clearback to summary
public void clear()

Implements java.util.List.clear.

Doc from java.util.List.clear.

Removes all of the elements from this list (optional operation). The list will be empty after this call returns.

Annotations
@Override
containsback to summary
public boolean contains(Object obj)

Implements java.util.List.contains.

Doc from java.util.List.contains.

Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that Objects.equals(o, e).

Annotations
@Override
containsAllback to summary
public boolean containsAll(Collection<?> objects)

Implements java.util.List.containsAll.

Doc from java.util.List.containsAll.

Returns true if this list contains all of the elements of the specified collection.

Annotations
@Override
emptyPropertyback to summary
public abstract ReadOnlyBooleanProperty emptyProperty()

A boolean property that is true, if the list is empty.

Returns:ReadOnlyBooleanProperty

the ReadOnlyBooleanProperty

getback to summary
public E get(int i)

Implements java.util.List.get.

Doc from java.util.List.get.

Returns the element at the specified position in this list.

Annotations
@Override
getNonNullback to summary
private ObservableList<E> getNonNull()
getSizeback to summary
public int getSize()

The size of the list

Returns:int

the size

getValueback to summary
public ObservableList<E> getValue()

Implements javafx.beans.value.ObservableValue.getValue.

Doc from javafx.beans.value.ObservableValue.getValue.

Returns the current value of this ObservableValue

Annotations
@Override
indexOfback to summary
public int indexOf(Object obj)

Implements java.util.List.indexOf.

Doc from java.util.List.indexOf.

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the lowest index i such that Objects.equals(o, get(i)), or -1 if there is no such index.

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Implements java.util.List.isEmpty.

Doc from java.util.List.isEmpty.

Returns true if this list contains no elements.

Annotations
@Override
isEqualToback to summary
public BooleanBinding isEqualTo(final ObservableList<?> other)

Creates a new BooleanBinding that holds true if this list is equal to another javafx.collections.ObservableList.

Parameters
other:ObservableList<?>

the other ObservableList

Returns:BooleanBinding

the new BooleanBinding

Exceptions
NullPointerException:
if other is null
isNotEqualToback to summary
public BooleanBinding isNotEqualTo(final ObservableList<?> other)

Creates a new BooleanBinding that holds true if this list is not equal to another javafx.collections.ObservableList.

Parameters
other:ObservableList<?>

the other ObservableList

Returns:BooleanBinding

the new BooleanBinding

Exceptions
NullPointerException:
if other is null
isNotNullback to summary
public BooleanBinding isNotNull()

Creates a new BooleanBinding that holds true if the wrapped list is not null.

Returns:BooleanBinding

the new BooleanBinding

isNullback to summary
public BooleanBinding isNull()

Creates a new BooleanBinding that holds true if the wrapped list is null.

Returns:BooleanBinding

the new BooleanBinding

iteratorback to summary
public Iterator<E> iterator()

Implements java.util.List.iterator.

Doc from java.util.List.iterator.

Returns an iterator over the elements in this list in proper sequence.

Annotations
@Override
lastIndexOfback to summary
public int lastIndexOf(Object obj)

Implements java.util.List.lastIndexOf.

Doc from java.util.List.lastIndexOf.

Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the highest index i such that Objects.equals(o, get(i)), or -1 if there is no such index.

Annotations
@Override
listExpressionback to summary
public static <E> ListExpression<E> listExpression(final ObservableListValue<E> value)

Returns a ListExpression that wraps a javafx.beans.value.ObservableListValue. If the ObservableListValue is already a ListExpression, it will be returned. Otherwise a new javafx.beans.binding.ListBinding is created that is bound to the ObservableListValue.

Parameters
<E>
the type of the wrapped List
value:ObservableListValue<E>

The source ObservableListValue

Returns:ListExpression<E>

A ListExpression that wraps the ObservableListValue if necessary

Exceptions
NullPointerException:
if value is null
listIteratorback to summary
public ListIterator<E> listIterator()

Implements java.util.List.listIterator.

Doc from java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence).

Annotations
@Override
listIteratorback to summary
public ListIterator<E> listIterator(int i)

Implements java.util.List.listIterator.

Doc from java.util.List.listIterator.

Returns a list iterator over the elements in this list (in proper sequence), starting at the specified position in the list. The specified index indicates the first element that would be returned by an initial call to next. An initial call to previous would return the element with the specified index minus one.

Annotations
@Override
removeback to summary
public boolean remove(Object obj)

Implements java.util.List.remove.

Doc from java.util.List.remove.

Removes the first occurrence of the specified element from this list, if it is present (optional operation). If this list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that Objects.equals(o, get(i)) (if such an element exists). Returns true if this list contained the specified element (or equivalently, if this list changed as a result of the call).

Annotations
@Override
removeback to summary
public E remove(int i)

Implements java.util.List.remove.

Doc from java.util.List.remove.

Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.

Annotations
@Override
removeback to summary
public void remove(int from, int to)

Implements javafx.collections.ObservableList.remove.

Doc from javafx.collections.ObservableList.remove.

A simplified way of calling sublist(from, to).clear(). As this is a common operation, ObservableList has this method for convenient usage.

Annotations
@Override
removeAllback to summary
public boolean removeAll(Collection<?> objects)

Implements java.util.List.removeAll.

Doc from java.util.List.removeAll.

Removes from this list all of its elements that are contained in the specified collection (optional operation).

Annotations
@Override
removeAllback to summary
public boolean removeAll(E... elements)

Implements javafx.collections.ObservableList.removeAll.

Doc from javafx.collections.ObservableList.removeAll.

A convenience method for var-arg usage of the removeAll method.

Annotations
@Override
retainAllback to summary
public boolean retainAll(Collection<?> objects)

Implements java.util.List.retainAll.

Doc from java.util.List.retainAll.

Retains only the elements in this list that are contained in the specified collection (optional operation). In other words, removes from this list all of its elements that are not contained in the specified collection.

Annotations
@Override
retainAllback to summary
public boolean retainAll(E... elements)

Implements javafx.collections.ObservableList.retainAll.

Doc from javafx.collections.ObservableList.retainAll.

A convenience method for var-arg usage of the retainAll method.

Annotations
@Override
setback to summary
public E set(int i, E element)

Implements java.util.List.set.

Doc from java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).

Annotations
@Override
setAllback to summary
public boolean setAll(E... elements)

Implements javafx.collections.ObservableList.setAll.

Doc from javafx.collections.ObservableList.setAll.

Clears the ObservableList and adds all the elements passed as var-args.

Annotations
@Override
setAllback to summary
public boolean setAll(Collection<? extends E> elements)

Implements javafx.collections.ObservableList.setAll.

Doc from javafx.collections.ObservableList.setAll.

Clears the ObservableList and adds all elements from the collection.

Annotations
@Override
sizeback to summary
public int size()

Implements java.util.List.size.

Doc from java.util.List.size.

Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Annotations
@Override
sizePropertyback to summary
public abstract ReadOnlyIntegerProperty sizeProperty()

An integer property that represents the size of the list.

Returns:ReadOnlyIntegerProperty

the property

subListback to summary
public List<E> subList(int from, int to)

Implements java.util.List.subList.

Doc from java.util.List.subList.

Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned list is empty.) The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. The returned list supports all of the optional list operations supported by this list.

This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list:

list.subList(from, to).clear();
Similar idioms may be constructed for indexOf and lastIndexOf, and all of the algorithms in the Collections class can be applied to a subList.

The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)

Annotations
@Override
toArrayback to summary
public Object[] toArray()

Implements java.util.List.toArray.

Doc from java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element).

The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array even if this list is backed by an array). The caller is thus free to modify the returned array.

This method acts as bridge between array-based and collection-based APIs.

Annotations
@Override
toArrayback to summary
public <T> T[] toArray(T[] array)

Implements java.util.List.toArray.

Doc from java.util.List.toArray.

Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array. If the list fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this list.

If the list fits in the specified array with room to spare (i.e., the array has more elements than the list), the element in the array immediately following the end of the list is set to null. (This is useful in determining the length of the list only if the caller knows that the list does not contain any null elements.)

Like the toArray() method, this method acts as bridge between array-based and collection-based APIs. Further, this method allows precise control over the runtime type of the output array, and may, under certain circumstances, be used to save allocation costs.

Suppose x is a list known to contain only strings. The following code can be used to dump the list into a newly allocated array of String:

String[] y = x.toArray(new String[0]);
Note that toArray(new Object[0]) is identical in function to toArray().
Annotations
@Override
valueAtback to summary
public ObjectBinding<E> valueAt(int index)

Creates a new ObjectBinding that contains the element at the specified position. If index points behind the list, the ObjectBinding contains null.

Parameters
index:int

the index of the element

Returns:ObjectBinding<E>

the ObjectBinding

Exceptions
IllegalArgumentException:
if index < 0
valueAtback to summary
public ObjectBinding<E> valueAt(ObservableIntegerValue index)

Creates a new ObjectBinding that contains the element at the specified position. If index points outside of the list, the ObjectBinding contains null.

Parameters
index:ObservableIntegerValue

the index of the element

Returns:ObjectBinding<E>

the ObjectBinding

Exceptions
NullPointerException:
if index is null