source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/main/org/apache/tools/ant/types/selectors/NoneSelector.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 2.3 KB
Line 
1/*
2 * Copyright 2002-2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package org.apache.tools.ant.types.selectors;
19
20import java.io.File;
21import java.util.Enumeration;
22
23/**
24 * This selector has a collection of other selectors. All of those selectors
25 * must refuse to select a file before the file is considered selected by
26 * this selector.
27 *
28 * @since 1.5
29 */
30public class NoneSelector extends BaseSelectorContainer {
31
32 /**
33 * Default constructor.
34 */
35 public NoneSelector() {
36 }
37
38 /**
39 * @return a string representation of the selector
40 */
41 public String toString() {
42 StringBuffer buf = new StringBuffer();
43 if (hasSelectors()) {
44 buf.append("{noneselect: ");
45 buf.append(super.toString());
46 buf.append("}");
47 }
48 return buf.toString();
49 }
50
51 /**
52 * Returns true (the file is selected) only if all other selectors
53 * agree that the file should not be selected.
54 *
55 * @param basedir the base directory the scan is being done from
56 * @param filename is the name of the file to check
57 * @param file is a java.io.File object for the filename that the selector
58 * can use
59 * @return whether the file should be selected or not
60 */
61 public boolean isSelected(File basedir, String filename, File file) {
62 validate();
63 Enumeration e = selectorElements();
64 boolean result;
65
66 while (e.hasMoreElements()) {
67 result = ((FileSelector) e.nextElement()).isSelected(basedir,
68 filename, file);
69 if (result) {
70 return false;
71 }
72 }
73 return true;
74 }
75
76}
77
Note: See TracBrowser for help on using the repository browser.