JavaTM Platform
Standard Ed. 6

javax.swing
클래스 RowFilter<M, I>

java.lang.Object 
  상위를 확장 javax.swing.RowFilter<M, I>
형태 파라미터:
M - 모델의 형태. PersonModel
I - 식별자의 형태. TableRowSorter 의 사용시는 Integer


public abstract class RowFilter<M, I>
extends Object

RowFilter 는, 엔트리를 모델로부터 제거해, 뷰에 표시되지 않게 하기 위해서 사용합니다. 예를 들어,JTable 에 관련지을 수 있었던 RowFilter 에서는, 특정의 캐릭터 라인을 가지는 열이 포함되어 있는 행 밖에 허가되지 않는 것이 있습니다. 엔트리의 의미는, 컴퍼넌트의 형태에 따라서 다릅니다. 예를 들어, 필터를 JTable 에 관련지을 수 있고 있는 경우, 엔트리는 행을 의미합니다. 필터를 JTree 에 관련지을 수 있고 있는 경우, 엔트리는 노드를 의미합니다.

서브 클래스는,include 메소드를 오버라이드(override) 해, 엔트리를 뷰에 표시할지 어떨지를 지정할 필요가 있습니다. 엔트리의 각 열의 값을 가져오려면 ,Entry 인수를 사용할 수 있습니다. 다음에, 예로서 캐릭터 라인 「a」로 시작되는 값 (복수가능)을 포함한 엔트리만을 허가하는 include 메소드를 나타냅니다.

 RowFilter<Object, Object> startsWithAFilter = new RowFilter<Object, Object>() {
   public boolean include(Entry<?  extends Object, ?  extends Object> entry) {
     for (int i = entry.getValueCount() - 1; i >= 0; i--) {
       if (entry.getStringValue(i). startsWith("a")) {
         // The value starts with "a", include it
         return true;
       }
     }
     // None of the columns start with "a"; return false so that this
     // entry is not shown
     return false;
   }
 };
 
RowFilter 에는, 특정의 모델의 RowFilter 의 작성을 허가하는 2 개의 가파라미터형이 준비되어 있습니다. 예를 들어, 다음의 코드는,Person 형의 객체를 랩 하는 특정의 모델을 나타내고 있습니다. 20 세 이상의 Person 만이 표시됩니다.
 RowFilter<PersonModel, Integer> ageFilter = new RowFilter<PersonModel, Integer>() {
   public boolean include(Entry<?  extends PersonModel, ?  extends Integer> entry) {
     PersonModel personModel = entry.getModel();
     Person person = personModel.getPerson(entry.getIdentifier());
     if (person.getAge() > 20) {
       // Returning true indicates this row should be shown.
       return true;
     }
     // Age is <= 20, don't show it.
     return false;
   }
 };
 PersonModel model = createPersonModel();
 TableRowSorter<PersonModel> sorter = new TableRowSorter<PersonModel>(model);
 sorter.setRowFilter(ageFilter);
 

도입된 버젼:
1.6
관련 항목:
TableRowSorter

상자의 클래스의 개요
static class RowFilter.ComparisonType
          일부의 디폴트의 RowFilter 로 지원되는, 값비교에 사용될 가능성이 있는 값의 열거입니다.
static class RowFilter.Entry <M ,I >
          Entry 객체가 RowFilter 의 인스턴스에게 건네지면(자), 필터는 엔트리의 데이터값를 취득해, 엔트리를 표시할지 어떨지를 판단할 수가 있습니다.
 
생성자 의 개요
RowFilter ()
           
 
메소드의 개요
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)
          지정된 기준을 채우는 Date 치를 적어도 1 개(살) 이상 가지는 엔트리를 포함하는 RowFilter 를 돌려줍니다.
abstract  boolean include (RowFilter.Entry <? extends M ,? extends I > entry)
          지정된 엔트리를 표시하는 경우는 true, 표시하지 않는 경우는 false 를 돌려줍니다.
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)
          지정된 기준을 채우는 Number 치를 적어도 1 개(살) 이상 가지는 엔트리를 포함하는 RowFilter 를 돌려줍니다.
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 를 돌려줍니다.
 
클래스 java.lang. Object 로부터 상속된 메소드
clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait
 

생성자 의 상세

RowFilter

public RowFilter()
메소드의 상세

regexFilter

public static <M, I> RowFilter <M, I> regexFilter(String  regex,
                                               int... indices)
정규 표현을 사용해 포함하는 엔트리를 특정하는 RowFilter 를 돌려줍니다. 일치하는 값을 적어도 1 개(살) 이상 가지는 엔트리를 포함할 수 있습니다. 예를 들어 다음의 코드는, 「a」로 시작되는 값을 적어도 1 개(살) 이상 가지는 엔트리를 포함하는 RowFilter 를 작성합니다.
   RowFilter.regexFilter("^a");
 

반환되는 필터는,Matcher.find() 를 사용해 혼잡 내용을 확인합니다. 완전 일치의 유무를 확인하려면 , 캐릭터 라인 「^」과「$」을 사용해, 캐릭터 라인의 선두와 말미의 문자를 비교합니다. 예를 들어 「^foo$」(이)라고 지정했을 경우, 「foo」라고 완전하게 일치하는 캐릭터 라인이 있는 행만이 포함할 수 있습니다. 「food」는 일치라고는 보여지지 않습니다. 지원되고 있는 정규 표현의 구문의 자세한 것은,Pattern 를 참조해 주세요.

파라미터:
regex - 필터를 적용하는 정규 표현
indices - 조사하는 값의 인덱스. 그렇지 않은 경우는, 지정된 모든 값이 평가된다
반환값:
지정된 기준을 채우는 RowFilter
예외:
NullPointerException - regexnull 의 경우
IllegalArgumentException - indices 에 0 보다 작은 값이 포함되는 경우
PatternSyntaxException - regex 가 유효한 정규 표현이 아닌 경우
관련 항목:
Pattern

dateFilter

public static <M, I> RowFilter <M, I> dateFilter(RowFilter.ComparisonType  type,
                                              Date  date,
                                              int... indices)
지정된 기준을 채우는 Date 치를 적어도 1 개(살) 이상 가지는 엔트리를 포함하는 RowFilter 를 돌려줍니다. 예를 들어 다음의 RowFilter 는, 현재의 일자보다 나머지의 1 개 이상의 일자의 값을 가지는 엔트리를 포함합니다.
   RowFilter.dateFilter(ComparisonType.AFTER, new Date());
 

파라미터:
type - 실행하는 비교의 형태
date - 비교 대상의 일자
indices - 조사하는 값의 인덱스. 그렇지 않은 경우는, 지정된 모든 값이 평가된다
반환값:
지정된 기준을 채우는 RowFilter
예외:
NullPointerException - datenull 의 경우
IllegalArgumentException - indices 에 0 보다 작은 값이 포함되는 경우, 또는 typenull 의 경우
관련 항목:
Calendar , Date

numberFilter

public static <M, I> RowFilter <M, I> numberFilter(RowFilter.ComparisonType  type,
                                                Number  number,
                                                int... indices)
지정된 기준을 채우는 Number 치를 적어도 1 개(살) 이상 가지는 엔트리를 포함하는 RowFilter 를 돌려줍니다. 예를 들어 다음의 필터는, 10 으로 동일한 값을 적어도 1 개(살) 이상 가지는 엔트리를 포함합니다.
   RowFilter.numberFilter(ComparisonType.EQUAL, 10);
 

파라미터:
type - 실행하는 비교의 형태
indices - 조사하는 값의 인덱스. 그렇지 않은 경우는, 지정된 모든 값이 평가된다
반환값:
지정된 기준을 채우는 RowFilter
예외:
IllegalArgumentException - indices 에 0 보다 작은 값이 포함되는 경우,typenull 의 경우, 또는 numbernull 의 경우

orFilter

public static <M, I> RowFilter <M, I> orFilter(Iterable <?  extends RowFilter <?  super M,?  super I>> filters)
지정된 필터안에 엔트리를 포함하는 것이 있었을 경우에, 엔트리를 포함하는 RowFilter 를 돌려줍니다.

다음의 샘플 코드는, 캐릭터 라인 「foo」또는 「bar」가 있는 엔트리를 포함하는 RowFilter 를 작성합니다.

   List<RowFilter<Object, Object>> filters = new ArrayList<RowFilter<Object, Object>>(2);
   filters.add(RowFilter.regexFilter("foo"));
   filters.add(RowFilter.regexFilter("bar"));
   RowFilter<Object, Object> fooBarFilter = RowFilter.orFilter(filters);
 

파라미터:
filters - 판정하는 대상이 되는 RowFilter
반환값:
지정된 기준을 채우는 RowFilter
예외:
IllegalArgumentException - null 의 필터가 존재하는 경우
NullPointerException - filters 가 null 의 경우
관련 항목:
Arrays.asList(T...)

andFilter

public static <M, I> RowFilter <M, I> andFilter(Iterable <?  extends RowFilter <?  super M,?  super I>> filters)
지정된 모든 필터가 엔트리를 포함하는 경우, 엔트리를 포함하는 RowFilter 를 돌려줍니다.

다음의 샘플 코드는, 캐릭터 라인 「foo」와「bar」가 있는 엔트리를 포함하는 RowFilter 를 작성합니다.

   List<RowFilter<Object, Object>> filters = new ArrayList<RowFilter<Object, Object>>(2);
   filters.add(RowFilter.regexFilter("foo"));
   filters.add(RowFilter.regexFilter("bar"));
   RowFilter<Object, Object> fooBarFilter = RowFilter.andFilter(filters);
 

파라미터:
filters - 판정하는 대상이 되는 RowFilter
반환값:
지정된 기준을 채우는 RowFilter
예외:
IllegalArgumentException - null 의 필터가 존재하는 경우
NullPointerException - filters 가 null 의 경우
관련 항목:
Arrays.asList(T...)

notFilter

public static <M, I> RowFilter <M, I> notFilter(RowFilter <M, I> filter)
지정된 필터가 엔트리를 포함하지 않는 경우, 엔트리를 포함하는 RowFilter 를 돌려줍니다.

파라미터:
filter - 부정하는 RowFilter
반환값:
지정된 기준을 채우는 RowFilter
예외:
IllegalArgumentException - filternull 의 경우

include

public abstract boolean include(RowFilter.Entry <?  extends M ,?  extends I > entry)
지정된 엔트리를 표시하는 경우는 true, 표시하지 않는 경우는 false 를 돌려줍니다.

entry 인수는, 호출동안에 한해 유효합니다. 호출의 완료 후에 entry 를 사용했을 경우의 동작은 미정도리입니다.

파라미터:
entry - 부하의 모델로부터의 객체를 랩 하는 null 이외의 객체
반환값:
엔트리를 표시하는 경우는 true

JavaTM Platform
Standard Ed. 6

버그의 보고와 기능의 요청
한층 더 자세한 API 레퍼런스 및 개발자 문서에 대해서는,Java SE 개발자용 문서를 참조해 주세요. 개발자전용의 상세한 해설, 개념의 개요, 용어의 정의, 버그의 회피책, 및 코드 실례가 포함되어 있습니다.

Copyright 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms . Documentation Redistribution Policy 도 참조해 주세요.