KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > methodmatch > CompositeFilter


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.hivemind.methodmatch;
16
17 import java.util.Iterator JavaDoc;
18 import java.util.List JavaDoc;
19
20 import org.apache.hivemind.service.MethodSignature;
21
22 /**
23  * Runs a suite of {@link org.apache.hivemind.methodmatch.MethodFilter}s, returning
24  * true only if each filter does. The tests short-circuit with the first filter
25  * to return false.
26  *
27  * @author Howard Lewis Ship
28  */

29 public class CompositeFilter extends MethodFilter
30 {
31     private List JavaDoc _filters;
32
33     /**
34      * Creates a new composite filter; the list passed in is <em>retained not copied</em>
35      * and should not be changed futher by the caller.
36      *
37      * @param filters {@link List} of {@link MethodFilter}.
38      */

39     public CompositeFilter(List JavaDoc filters)
40     {
41         _filters = filters;
42     }
43
44     public boolean matchMethod(MethodSignature sig)
45     {
46         Iterator JavaDoc i = _filters.iterator();
47         while (i.hasNext())
48         {
49             MethodFilter mf = (MethodFilter) i.next();
50
51             if (!mf.matchMethod(sig))
52                 return false;
53         }
54
55         // All matches!
56

57         return true;
58     }
59
60 }
61
Popular Tags