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.selectors;
19:
20: import java.io.File;
21:
22: import org.apache.tools.ant.BuildException;
23: import org.apache.tools.ant.types.Parameter;
24:
25: /**
26: * Convenience base class for all selectors accessed through ExtendSelector.
27: * It provides support for gathering the parameters together as well as for
28: * assigning an error message and throwing a build exception if an error is
29: * detected.
30: *
31: * @since 1.5
32: */
33: public abstract class BaseExtendSelector extends BaseSelector implements
34: ExtendFileSelector {
35:
36: // CheckStyle:VisibilityModifier OFF - bc
37:
38: /** The passed in parameter array. */
39: protected Parameter[] parameters = null;
40:
41: // CheckStyle:VisibilityModifier ON
42:
43: /**
44: * Default constructor.
45: */
46: public BaseExtendSelector() {
47: }
48:
49: /**
50: * Set all the Parameters for this custom selector, collected by
51: * the ExtendSelector class.
52: *
53: * @param parameters the complete set of parameters for this selector
54: */
55: public void setParameters(Parameter[] parameters) {
56: this .parameters = parameters;
57: }
58:
59: /**
60: * Allows access to the parameters gathered and set within the
61: * <custom> tag.
62: *
63: * @return the set of parameters defined for this selector
64: */
65: protected Parameter[] getParameters() {
66: return parameters;
67: }
68:
69: /**
70: * Method that each selector will implement to create their
71: * selection behaviour. If there is a problem with the setup
72: * of a selector, it can throw a BuildException to indicate
73: * the problem.
74: *
75: * @param basedir A java.io.File object for the base directory
76: * @param filename The name of the file to check
77: * @param file A File object for this filename
78: * @return whether the file should be selected or not
79: * @exception BuildException if an error occurs
80: */
81: public abstract boolean isSelected(File basedir, String filename,
82: File file) throws BuildException;
83:
84: }
|