01: // Copyright 2004, 2005 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // 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;
18: import java.util.List;
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: private List _filters;
31:
32: /**
33: * Creates a new composite filter; the list passed in is <em>retained not copied</em>
34: * and should not be changed futher by the caller.
35: *
36: * @param filters {@link List} of {@link MethodFilter}.
37: */
38: public CompositeFilter(List filters) {
39: _filters = filters;
40: }
41:
42: public boolean matchMethod(MethodSignature sig) {
43: Iterator i = _filters.iterator();
44: while (i.hasNext()) {
45: MethodFilter mf = (MethodFilter) i.next();
46:
47: if (!mf.matchMethod(sig))
48: return false;
49: }
50:
51: // All matches!
52:
53: return true;
54: }
55:
56: }
|