M
-模型的类型;例如
PersonModel
I
-标识符的类型;当使用
TableRowSorter
这将
Integer
public abstract class RowFilter<M,I> extends Object
RowFilter
用来从模型使他们不在视图中显示过滤条目。例如,一个
JTable
相关
RowFilter
可能只允许包含一个特定字符串列的行。入口的含义取决于组件类型。例如,当一个过滤器是一个
JTable
相关,进入对应一行;当一个
JTree
相关条目对应一个节点。
子类必须重写include
方法显示条目是否应显示在视图。的Entry
参数可以用来在每个条目列中获得价值。下面的示例显示了一个include
方法只允许条目包含一个或多个值从字符串“A”:
rowfilter <对象,对象> startswithafilter =新rowfilter <对象,对象> (){公共布尔包括(条目<?扩展对象,?扩展对象>输入)为(int i =条目。getvaluecount() - 1;我> = 0;我--){如果(条目。getstringvalue(我)。从(“”)){/值从“A”开始,包括它返回true;}}没有一个列以“A”开始,返回错误,使这个未显示输入/输入/显示返回false;}}; 对象,对象> 对象,对象>
RowFilter
有两形式类型参数,允许你创建一个特定的模型
RowFilter
。例如,以下假设一个具体的模式,是包装
Person
对象类型。一个20岁以上的只有
Person
s将显示:
personmodel rowfilter <整数> ,agefilter =新rowfilter < personmodel,整数>(){公共布尔包括(条目<?延伸personmodel,?扩展整数>输入)personmodel personmodel =条目。getmodel();人= personmodel。GetPerson(条目。getidentifier());如果(人。getage() > 20){返回真值表示该行应显示。返回true;}/年龄= 20,不显示。返回false;}};personmodel模型= createpersonmodel();tablerowsorter < personmodel >选=新tablerowsorter < personmodel >(模型);setrowfilter(agefilter)分类器; 整数>
TableRowSorter
Modifier and Type | Class and Description |
---|---|
static class |
RowFilter.ComparisonType
这可能比较值的默认
RowFilter s支持枚举。
|
static class |
RowFilter.Entry<M,I>
一个
Entry 对象传递给
RowFilter 实例,使滤波器得到的输入数据的值,从而确定输入是否应显示。
|
Constructor and Description |
---|
RowFilter() |
Modifier and Type | Method and Description |
---|---|
static <M,I> RowFilter<M,I> |
andFilter(Iterable<? extends RowFilter<? super M,? super I>> filters)
返回一个
RowFilter 包括条目如果所有提供的过滤器包括入境。
|
static <M,I> RowFilter<M,I> |
dateFilter(RowFilter.ComparisonType type, Date date, int... indices)
返回一个
RowFilter 包括至少有一个
Date 值满足指定标准的条目。
|
abstract boolean |
include(RowFilter.Entry<? extends M,? extends I> entry)
如果要显示指定的条目,则返回真实;返回错误,如果条目应该被隐藏。
|
static <M,I> RowFilter<M,I> |
notFilter(RowFilter<M,I> filter)
返回一个
RowFilter 包括条目,如果提供的过滤器不包括入境。
|
static <M,I> RowFilter<M,I> |
numberFilter(RowFilter.ComparisonType type, Number number, int... indices)
返回一个
RowFilter 包括至少有一个
Number 值满足指定标准的条目。
|
static <M,I> RowFilter<M,I> |
orFilter(Iterable<? extends RowFilter<? super M,? super I>> filters)
返回一个
RowFilter 包括条目,如果提供的过滤器包括入口。
|
static <M,I> RowFilter<M,I> |
regexFilter(String regex, int... indices)
返回一个
RowFilter 使用正则表达式来确定哪些条目包括。
|
public static <M,I> RowFilter<M,I> regexFilter(String regex, int... indices)
RowFilter
使用正则表达式来确定哪些条目包括。包括至少一个匹配值的唯一条目。例如,下面创建一个
RowFilter
包括条目至少有一个值从“一”:
rowfilter。regexfilter(“^“);
返回的过滤器使用Matcher.find()
测试包。要测试的确切匹配使用的字符','和' $ ',以匹配字符串的开始和结束分别。例如,“^ foo$”只包括行的字符串就是“foo”而不是,例如,“食物”。看到了支持正则表达式的完整描述Pattern
构建。
regex
-滤波器对正则表达式
indices
-检查指标值。如果没有提供所有的值进行评估
RowFilter
null
regex
NullPointerException
IllegalArgumentException
-如果有任何的
indices
是<0
PatternSyntaxException
-如果
regex
不是有效的正则表达式。
Pattern
public static <M,I> RowFilter<M,I> dateFilter(RowFilter.ComparisonType type, Date date, int... indices)
RowFilter
包括至少有一个
Date
值满足指定标准的条目。例如,下面的
RowFilter
只包括条目当前日期之后至少有一个日期值:
rowfilter。日期过滤器(comparisontype.after,新());
type
-要执行的比较的类型
date
-日期的比较
indices
-检查指标值。如果没有提供所有的值进行评估
RowFilter
null
date
NullPointerException
IllegalArgumentException
-如果有任何的
indices
是<0或
type
是
null
Calendar
,
Date
public static <M,I> RowFilter<M,I> numberFilter(RowFilter.ComparisonType type, Number number, int... indices)
RowFilter
包括至少有一个
Number
值满足指定标准的条目。例如,下面的过滤器将只包括条目至少有一个数的值等于10:
rowfilter numberfilter(comparisontype.equal,10);
type
-要执行的比较的类型
indices
-检查指标值。如果没有提供所有的值进行评估
RowFilter
IllegalArgumentException
-如果有任何的
indices
是<0,
type
是
null
或
number
是
null
public static <M,I> RowFilter<M,I> orFilter(Iterable<? extends RowFilter<? super M,? super I>> filters)
RowFilter
包括条目,如果提供的过滤器包括入口。
下面的示例创建一个RowFilter
将包括任何条目包含字符串“foo”或字符串“酒吧”:
列表< rowfilter <对象,对象> > < < rowfilter过滤器=新的ArrayList对象,对象> >(2);过滤器。添加(rowfilter。regexfilter(“foo”));过滤器。添加(rowfilter。regexfilter(“条”));rowfilter <对象,对象> foobarfilter = rowfilter或滤波(过滤器); 对象,对象> 对象,对象>
filters
-
RowFilter
s测试
RowFilter
IllegalArgumentException
-如果过滤器是
null
NullPointerException
-如果
filters
是空的
Arrays.asList(T...)
public static <M,I> RowFilter<M,I> andFilter(Iterable<? extends RowFilter<? super M,? super I>> filters)
RowFilter
包括条目如果所有提供的过滤器包括入境。
下面的示例创建一个RowFilter
将包括任何条目包含字符串“foo”字符串“酒吧”:
列表< rowfilter <对象,对象> > < < rowfilter过滤器=新的ArrayList对象,对象> >(2);过滤器。添加(rowfilter。regexfilter(“foo”));过滤器。添加(rowfilter。regexfilter(“条”));rowfilter <对象,对象> foobarfilter = rowfilter过滤(过滤器); 对象,对象> 对象,对象>
filters
-测试
RowFilter
s
RowFilter
IllegalArgumentException
-如果过滤器是
null
NullPointerException
-如果
filters
是空的
Arrays.asList(T...)
public static <M,I> RowFilter<M,I> notFilter(RowFilter<M,I> filter)
RowFilter
包括条目,如果提供的过滤器不包括入境。
filter
-
RowFilter
否定
RowFilter
null
filter
IllegalArgumentException
public abstract boolean include(RowFilter.Entry<? extends M,? extends I> entry)
的entry
参数只适用于调用的持续时间。在调用返回未定义的行为,结果entry
。
entry
-非
null
对象包装底层对象模型
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.