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