source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/main/org/apache/tools/ant/types/selectors/OrSelector.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, any of which have to
25 * select a file in order for this selector to select it.
26 *
27 * @since 1.5
28 */
29public class OrSelector extends BaseSelectorContainer {
30
31 /**
32 * Default constructor.
33 */
34 public OrSelector() {
35 }
36
37 /**
38 * @return a string representation of the selector
39 */
40 public String toString() {
41 StringBuffer buf = new StringBuffer();
42 if (hasSelectors()) {
43 buf.append("{orselect: ");
44 buf.append(super.toString());
45 buf.append("}");
46 }
47 return buf.toString();
48 }
49
50 /**
51 * Returns true (the file is selected) if any of the other selectors
52 * agree that the file should be selected.
53 *
54 * @param basedir the base directory the scan is being done from
55 * @param filename the name of the file to check
56 * @param file a java.io.File object for the filename that the selector
57 * can use
58 * @return whether the file should be selected or not
59 */
60 public boolean isSelected(File basedir, String filename, File file) {
61 validate();
62 Enumeration e = selectorElements();
63 boolean result;
64
65 // First, check that all elements are correctly configured
66 while (e.hasMoreElements()) {
67 result = ((FileSelector) e.nextElement()).isSelected(basedir,
68 filename, file);
69 if (result) {
70 return true;
71 }
72 }
73 return false;
74 }
75
76}
77
Note: See TracBrowser for help on using the repository browser.