I'm trying to write a TreeModel that can show an Ant fileset. Rather than
finding all matching files at once, like DirectoryScanner does, I only want to
have to scan one directory at a time, as the user expands the tree node for
that directory.
In order get the same results that Ant does, I need to access these static
methods and constants in DirectoryScanner.java:
DEFAULTEXCLUDES
matchPatternStart
matchPath
match
They are currently protected. This means that my class has to extend
DirectoryScanner for the sole purpose of being able to call these methods. I'd
like to make them public instead; hopefully this is a legit thing to do. I've
attached a patch for this change.
Alex
Index: DirectoryScanner.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/DirectoryScanner.java,v
retrieving revision 1.8
diff -u -r1.8 DirectoryScanner.java
--- DirectoryScanner.java 2001/01/03 14:18:26 1.8
+++ DirectoryScanner.java 2001/01/30 16:58:34
@@ -140,7 +140,7 @@
*
* @see #addDefaultExcludes()
*/
- protected final static String[] DEFAULTEXCLUDES = {
+ public final static String[] DEFAULTEXCLUDES = {
"**/*~",
"**/#*#",
"**/%*%",
@@ -221,7 +221,7 @@
* @param pattern the (non-null) pattern to match against
* @param str the (non-null) string (path) to match
*/
- protected static boolean matchPatternStart(String pattern, String str) {
+ public static boolean matchPatternStart(String pattern, String str) {
// When str starts with a File.separator, pattern has to start with a
// File.separator.
// When pattern starts with a File.separator, str has to start with a
@@ -283,7 +283,7 @@
* @return <code>true</code> when the pattern matches against the string.
* <code>false</code> otherwise.
*/
- protected static boolean matchPath(String pattern, String str) {
+ public static boolean matchPath(String pattern, String str) {
// When str starts with a File.separator, pattern has to start with a
// File.separator.
// When pattern starts with a File.separator, str has to start with a
@@ -423,7 +423,7 @@
* @return <code>true</code> when the string matches against the pattern,
* <code>false</code> otherwise.
*/
- protected static boolean match(String pattern, String str) {
+ public static boolean match(String pattern, String str) {
char[] patArr = pattern.toCharArray();
char[] strArr = str.toCharArray();
int patIdxStart = 0;