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:
19: package org.apache.tools.ant.types.selectors;
20:
21: import java.io.File;
22: import java.util.Enumeration;
23:
24: /**
25: * This selector has a collection of other selectors. All of those selectors
26: * must refuse to select a file before the file is considered selected by
27: * this selector.
28: *
29: * @since 1.5
30: */
31: public class NoneSelector extends BaseSelectorContainer {
32:
33: /**
34: * Default constructor.
35: */
36: public NoneSelector() {
37: }
38:
39: /**
40: * @return a string representation of the selector
41: */
42: public String toString() {
43: StringBuffer buf = new StringBuffer();
44: if (hasSelectors()) {
45: buf.append("{noneselect: ");
46: buf.append(super .toString());
47: buf.append("}");
48: }
49: return buf.toString();
50: }
51:
52: /**
53: * Returns true (the file is selected) only if all other selectors
54: * agree that the file should not be selected.
55: *
56: * @param basedir the base directory the scan is being done from
57: * @param filename is the name of the file to check
58: * @param file is a java.io.File object for the filename that the selector
59: * can use
60: * @return whether the file should be selected or not
61: */
62: public boolean isSelected(File basedir, String filename, File file) {
63: validate();
64: Enumeration e = selectorElements();
65: boolean result;
66:
67: while (e.hasMoreElements()) {
68: result = ((FileSelector) e.nextElement()).isSelected(
69: basedir, filename, file);
70: if (result) {
71: return false;
72: }
73: }
74: return true;
75: }
76:
77: }
|