1. /*
  2. * Copyright 2000-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;
  18. import java.io.File;
  19. /**
  20. * An interface used to describe the actions required of any type of
  21. * directory scanner.
  22. *
  23. */
  24. public interface FileScanner {
  25. /**
  26. * Adds default exclusions to the current exclusions set.
  27. */
  28. void addDefaultExcludes();
  29. /**
  30. * Returns the base directory to be scanned.
  31. * This is the directory which is scanned recursively.
  32. *
  33. * @return the base directory to be scanned
  34. */
  35. File getBasedir();
  36. /**
  37. * Returns the names of the directories which matched at least one of the
  38. * include patterns and at least one of the exclude patterns.
  39. * The names are relative to the base directory.
  40. *
  41. * @return the names of the directories which matched at least one of the
  42. * include patterns and at least one of the exclude patterns.
  43. */
  44. String[] getExcludedDirectories();
  45. /**
  46. * Returns the names of the files which matched at least one of the
  47. * include patterns and at least one of the exclude patterns.
  48. * The names are relative to the base directory.
  49. *
  50. * @return the names of the files which matched at least one of the
  51. * include patterns and at least one of the exclude patterns.
  52. *
  53. */
  54. String[] getExcludedFiles();
  55. /**
  56. * Returns the names of the directories which matched at least one of the
  57. * include patterns and none of the exclude patterns.
  58. * The names are relative to the base directory.
  59. *
  60. * @return the names of the directories which matched at least one of the
  61. * include patterns and none of the exclude patterns.
  62. */
  63. String[] getIncludedDirectories();
  64. /**
  65. * Returns the names of the files which matched at least one of the
  66. * include patterns and none of the exclude patterns.
  67. * The names are relative to the base directory.
  68. *
  69. * @return the names of the files which matched at least one of the
  70. * include patterns and none of the exclude patterns.
  71. */
  72. String[] getIncludedFiles();
  73. /**
  74. * Returns the names of the directories which matched none of the include
  75. * patterns. The names are relative to the base directory.
  76. *
  77. * @return the names of the directories which matched none of the include
  78. * patterns.
  79. */
  80. String[] getNotIncludedDirectories();
  81. /**
  82. * Returns the names of the files which matched none of the include
  83. * patterns. The names are relative to the base directory.
  84. *
  85. * @return the names of the files which matched none of the include
  86. * patterns.
  87. */
  88. String[] getNotIncludedFiles();
  89. /**
  90. * Scans the base directory for files which match at least one include
  91. * pattern and don't match any exclude patterns.
  92. *
  93. * @exception IllegalStateException if the base directory was set
  94. * incorrectly (i.e. if it is <code>null</code>, doesn't exist,
  95. * or isn't a directory).
  96. */
  97. void scan() throws IllegalStateException;
  98. /**
  99. * Sets the base directory to be scanned. This is the directory which is
  100. * scanned recursively. All '/' and '\' characters should be replaced by
  101. * <code>File.separatorChar</code>, so the separator used need not match
  102. * <code>File.separatorChar</code>.
  103. *
  104. * @param basedir The base directory to scan.
  105. * Must not be <code>null</code>.
  106. */
  107. void setBasedir(String basedir);
  108. /**
  109. * Sets the base directory to be scanned. This is the directory which is
  110. * scanned recursively.
  111. *
  112. * @param basedir The base directory for scanning.
  113. * Should not be <code>null</code>.
  114. */
  115. void setBasedir(File basedir);
  116. /**
  117. * Sets the list of exclude patterns to use.
  118. *
  119. * @param excludes A list of exclude patterns.
  120. * May be <code>null</code>, indicating that no files
  121. * should be excluded. If a non-<code>null</code> list is
  122. * given, all elements must be non-<code>null</code>.
  123. */
  124. void setExcludes(String[] excludes);
  125. /**
  126. * Sets the list of include patterns to use.
  127. *
  128. * @param includes A list of include patterns.
  129. * May be <code>null</code>, indicating that all files
  130. * should be included. If a non-<code>null</code>
  131. * list is given, all elements must be
  132. * non-<code>null</code>.
  133. */
  134. void setIncludes(String[] includes);
  135. /**
  136. * Sets whether or not the file system should be regarded as case sensitive.
  137. *
  138. * @param isCaseSensitive whether or not the file system should be
  139. * regarded as a case sensitive one
  140. */
  141. void setCaseSensitive(boolean isCaseSensitive);
  142. }