01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.tools.ant.types.resources.selectors;
19:
20: import java.util.Iterator;
21:
22: import org.apache.tools.ant.types.Resource;
23:
24: /**
25: * And ResourceSelector.
26: * @since Ant 1.7
27: */
28: public class And extends ResourceSelectorContainer implements
29: ResourceSelector {
30:
31: /**
32: * Default constructor.
33: */
34: public And() {
35: }
36:
37: /**
38: * Convenience constructor.
39: * @param r the ResourceSelector[] to add.
40: */
41: public And(ResourceSelector[] r) {
42: super (r);
43: }
44:
45: /**
46: * Return true if this Resource is selected.
47: * @param r the Resource to check.
48: * @return whether the Resource was selected.
49: */
50: public boolean isSelected(Resource r) {
51: for (Iterator i = getSelectors(); i.hasNext();) {
52: if (!((ResourceSelector) i.next()).isSelected(r)) {
53: return false;
54: }
55: }
56: return true;
57: }
58:
59: }
|