- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- javafx.collections.ObservableListBase<E>
-
- javafx.collections.transformation.TransformationList<E,E>
-
- javafx.collections.transformation.FilteredList<E>
-
- All Implemented Interfaces:
-
Iterable<E>
,Collection<E>
,List<E>
,Observable
,ObservableList<E>
public final class FilteredList<E> extends TransformationList<E,E>
包装一个ObservableList并使用提供的谓词过滤其内容。 ObservableList中的所有更改都会立即传播到FilteredList。- 从以下版本开始:
- JavaFX 8.0
- 另请参见:
-
TransformationList
-
-
Property Summary
Properties Type Property 描述 ObjectProperty<Predicate<? super E>>
predicate
该谓词将匹配此FilteredList中的元素。
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
构造方法摘要
构造方法 Constructor 描述 FilteredList(ObservableList<E> source)
在源列表周围构造一个新的FilteredList包装器。FilteredList(ObservableList<E> source, Predicate<? super E> predicate)
在源列表周围构造一个新的FilteredList包装器。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 E
get(int index)
返回此列表中指定位置的元素。Predicate<? super E>
getPredicate()
获取属性谓词的值。int
getSourceIndex(int index)
将此列表元素的索引映射到直接源列表中的索引。int
getViewIndex(int index)
将直接源列表的元素的索引映射到此列表中的索引。ObjectProperty<Predicate<? super E>>
predicateProperty()
该谓词将匹配此FilteredList中的元素。void
setPredicate(Predicate<? super E> predicate)
设置属性谓词的值。int
size()
返回此列表中的元素数。protected void
sourceChanged(ListChangeListener.Change<? extends E> c)
当来自源的更改被触发时调用。-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream
-
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, of, of, of, of, of, of, of, of, of, of, of, of, remove, remove, removeAll, replaceAll, retainAll, set, sort, spliterator, subList, toArray, toArray
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface javafx.beans.Observable
addListener, removeListener
-
Methods inherited from interface javafx.collections.ObservableList
addAll, addListener, filtered, remove, removeAll, removeListener, retainAll, setAll, setAll, sorted, sorted
-
Methods inherited from class javafx.collections.ObservableListBase
addAll, addListener, addListener, beginChange, endChange, fireChange, hasListeners, nextAdd, nextPermutation, nextRemove, nextRemove, nextReplace, nextSet, nextUpdate, remove, removeAll, removeListener, removeListener, retainAll, setAll, setAll
-
Methods inherited from class javafx.collections.transformation.TransformationList
getSource, getSourceIndexFor, isInTransformationChain
-
-
-
-
Property Detail
-
predicate
public final ObjectProperty<Predicate<? super E>> predicateProperty
该谓词将匹配此FilteredList中的元素。 不符合谓词的元素将被过滤掉。 Null谓词表示“always true”谓词,所有元素都将匹配。
-
-
构造方法详细信息
-
FilteredList
public FilteredList(ObservableList<E> source, Predicate<? super E> predicate)
在源列表周围构造一个新的FilteredList包装器。 提供的谓词将匹配源列表中可见的元素。 如果谓词为空,则所有元素都将匹配,列表等于源列表。- 参数
-
source
- 源列表 -
predicate
- 匹配元素的谓词或null以匹配所有元素。
-
FilteredList
public FilteredList(ObservableList<E> source)
- 参数
-
source
- 源列表
-
-
方法详细信息
-
predicateProperty
public final ObjectProperty<Predicate<? super E>> predicateProperty()
该谓词将匹配此FilteredList中的元素。 不符合谓词的元素将被过滤掉。 Null谓词表示“always true”谓词,所有元素都将匹配。
-
getPredicate
public final Predicate<? super E> getPredicate()
获取属性谓词的值。- Property description:
- 该谓词将匹配此FilteredList中的元素。 不符合谓词的元素将被过滤掉。 Null谓词表示“always true”谓词,所有元素都将匹配。
-
setPredicate
public final void setPredicate(Predicate<? super E> predicate)
设置属性谓词的值。- Property description:
- 该谓词将匹配此FilteredList中的元素。 不符合谓词的元素将被过滤掉。 Null谓词表示“always true”谓词,所有元素都将匹配。
-
sourceChanged
protected void sourceChanged(ListChangeListener.Change<? extends E> c)
描述从类复制:TransformationList
当来自源的更改被触发时调用。- Specified by:
-
sourceChanged
在TransformationList<E,E>
- 参数
-
c
- 变化
-
size
public int size()
返回此列表中的元素数。- Specified by:
-
size
在接口Collection<E>
- Specified by:
-
size
在接口List<E>
- Specified by:
-
size
在AbstractCollection<E>
- 结果
- 此列表中的元素数
-
get
public E get(int index)
返回此列表中指定位置的元素。- Specified by:
-
get
在接口List<E>
- Specified by:
-
get
在AbstractList<E>
- 参数
-
index
- 要返回的元素的索引 - 结果
- 该列表中指定位置的元素
- 异常
-
IndexOutOfBoundsException
- 如果指数超出范围(index < 0 || index >= size()
)
-
getSourceIndex
public int getSourceIndex(int index)
描述从类别复制:TransformationList
将此列表元素的索引映射到直接源列表中的索引。- Specified by:
-
getSourceIndex
在TransformationList<E,E>
- 参数
-
index
- 此列表中的索引 - 结果
- 源列表中元素的起始索引
- 另请参见:
-
TransformationList.getSource()
-
getViewIndex
public int getViewIndex(int index)
描述从类复制:TransformationList
将直接源列表的元素的索引映射到此列表中的索引。- Specified by:
-
getViewIndex
在TransformationList<E,E>
- 参数
-
index
- 源列表中的索引 - 结果
- 如果列表中包含该元素的索引,否则为负值
- 另请参见:
-
TransformationList.getSource()
,TransformationList.getSourceIndex(int)
-
-