KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > types > selectors > NoneSelector


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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 JavaDoc;
22 import java.util.Enumeration JavaDoc;
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 JavaDoc toString() {
43         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
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 JavaDoc basedir, String JavaDoc filename, File JavaDoc file) {
63         validate();
64         Enumeration JavaDoc e = selectorElements();
65         boolean result;
66
67         while (e.hasMoreElements()) {
68             result = ((FileSelector) e.nextElement()).isSelected(basedir,
69                     filename, file);
70             if (result) {
71                 return false;
72             }
73         }
74         return true;
75     }
76
77 }
78
79
Popular Tags