You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2008/09/15 11:54:07 UTC

svn commit: r695402 - in /ant/core/trunk/src/main/org/apache/tools/ant: DirectoryScanner.java types/selectors/PathPattern.java types/selectors/SelectorUtils.java

Author: bodewig
Date: Mon Sep 15 02:54:06 2008
New Revision: 695402

URL: http://svn.apache.org/viewvc?rev=695402&view=rev
Log:
Avoid repeated tokenization, make DefaultExcludesTest happy.

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/PathPattern.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java?rev=695402&r1=695401&r2=695402&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java Mon Sep 15 02:54:06 2008
@@ -145,30 +145,30 @@
      */
     protected static final String[] DEFAULTEXCLUDES = {
         // Miscellaneous typical temporary files
-        SelectorUtils.DEEP_ROOT_MATCH + "*~",
-        SelectorUtils.DEEP_ROOT_MATCH + "#*#",
-        SelectorUtils.DEEP_ROOT_MATCH + ".#*",
-        SelectorUtils.DEEP_ROOT_MATCH + "%*%",
-        SelectorUtils.DEEP_ROOT_MATCH + "._*",
+        SelectorUtils.DEEP_TREE_MATCH + "/*~",
+        SelectorUtils.DEEP_TREE_MATCH + "/#*#",
+        SelectorUtils.DEEP_TREE_MATCH + "/.#*",
+        SelectorUtils.DEEP_TREE_MATCH + "/%*%",
+        SelectorUtils.DEEP_TREE_MATCH + "/._*",
 
         // CVS
-        SelectorUtils.DEEP_ROOT_MATCH + "CVS",
-        SelectorUtils.DEEP_ROOT_MATCH + "CVS" + SelectorUtils.DEEP_LEAVES_MATCH,
-        SelectorUtils.DEEP_ROOT_MATCH + ".cvsignore",
+        SelectorUtils.DEEP_TREE_MATCH + "/CVS",
+        SelectorUtils.DEEP_TREE_MATCH + "/CVS/" + SelectorUtils.DEEP_TREE_MATCH,
+        SelectorUtils.DEEP_TREE_MATCH + "/.cvsignore",
 
         // SCCS
-        SelectorUtils.DEEP_ROOT_MATCH + "SCCS",
-        SelectorUtils.DEEP_ROOT_MATCH + "SCCS" + SelectorUtils.DEEP_LEAVES_MATCH,
+        SelectorUtils.DEEP_TREE_MATCH + "/SCCS",
+        SelectorUtils.DEEP_TREE_MATCH + "/SCCS/" + SelectorUtils.DEEP_TREE_MATCH,
 
         // Visual SourceSafe
-        SelectorUtils.DEEP_ROOT_MATCH + "vssver.scc",
+        SelectorUtils.DEEP_TREE_MATCH + "/vssver.scc",
 
         // Subversion
-        SelectorUtils.DEEP_ROOT_MATCH + ".svn",
-        SelectorUtils.DEEP_ROOT_MATCH + ".svn" + SelectorUtils.DEEP_LEAVES_MATCH,
+        SelectorUtils.DEEP_TREE_MATCH + "/.svn",
+        SelectorUtils.DEEP_TREE_MATCH + "/.svn/" + SelectorUtils.DEEP_TREE_MATCH,
 
         // Mac
-        SelectorUtils.DEEP_ROOT_MATCH + ".DS_Store"
+        SelectorUtils.DEEP_TREE_MATCH + "/.DS_Store"
     };
 
     /**
@@ -1295,10 +1295,13 @@
      *         least one include pattern, or <code>false</code> otherwise.
      */
     protected boolean couldHoldIncluded(String name) {
+        final PathPattern tokenizedName = new PathPattern(name);
         for (int i = 0; i < includes.length; i++) {
-            if (matchPatternStart(includes[i], name, isCaseSensitive())
+            PathPattern tokenizedInclude = new PathPattern(includes[i]);
+            if (tokenizedName.matchPatternStartOf(tokenizedInclude,
+                                                  isCaseSensitive())
                 && isMorePowerfulThanExcludes(name, includes[i])
-                && isDeeper(includes[i], name)) {
+                && isDeeper(tokenizedInclude, tokenizedName)) {
                 return true;
             }
         }
@@ -1313,13 +1316,9 @@
      * @return whether the pattern is deeper than the name.
      * @since Ant 1.6.3
      */
-    private boolean isDeeper(String pattern, String name) {
-        Vector p = SelectorUtils.tokenizePath(pattern);
-        if (!p.contains(SelectorUtils.DEEP_TREE_MATCH)) {
-            Vector n = SelectorUtils.tokenizePath(name);
-            return p.size() > n.size();
-        }
-        return true;
+    private boolean isDeeper(PathPattern pattern, PathPattern name) {
+        return pattern.containsPattern(SelectorUtils.DEEP_TREE_MATCH)
+            || pattern.depth() > name.depth();
     }
 
     /**
@@ -1341,7 +1340,8 @@
      */
     private boolean isMorePowerfulThanExcludes(String name,
                                                String includepattern) {
-        String soughtexclude = name + SelectorUtils.DEEP_LEAVES_MATCH;
+        final String soughtexclude =
+            name + File.separatorChar + SelectorUtils.DEEP_TREE_MATCH;
         for (int counter = 0; counter < excludes.length; counter++) {
             if (excludes[counter].equals(soughtexclude))  {
                 return false;

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/PathPattern.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/PathPattern.java?rev=695402&r1=695401&r2=695402&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/PathPattern.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/PathPattern.java Mon Sep 15 02:54:06 2008
@@ -70,6 +70,16 @@
     }
     
     /**
+     * Tests whether or not this PathPattern matches the start of
+     * another pattern.
+     */
+    public boolean matchPatternStartOf(PathPattern other,
+                                       boolean caseSensitive) {
+        return SelectorUtils.matchPatternStart(other.tokenizedPattern,
+                                               tokenizedPattern, caseSensitive);
+    }
+
+    /**
      * @return The pattern String
      */
     public String toString() {
@@ -79,4 +89,23 @@
     public String getPattern() {
         return pattern;
     }
+
+    /**
+     * The depth (or length) of a pattern.
+     */
+    public int depth() {
+        return tokenizedPattern.length;
+    }
+
+    /**
+     * Does the tokenized pattern contain the given string?
+     */
+    public boolean containsPattern(String pat) {
+        for (int i = 0; i < tokenizedPattern.length; i++) {
+            if (tokenizedPattern[i].equals(pat)) {
+                return true;
+            }
+        }
+        return false;
+    }
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java?rev=695402&r1=695401&r2=695402&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java Mon Sep 15 02:54:06 2008
@@ -44,20 +44,6 @@
      */
     public static final String DEEP_TREE_MATCH = "**";
 
-    /**
-     * The pattern that matches an arbitrary number of directories at
-     * the leaves.
-     * @since Ant 1.8.0
-     */
-    public static final String DEEP_LEAVES_MATCH = File.separatorChar + "**";
-
-    /**
-     * The pattern that matches an arbitrary number of directories at
-     * the root.
-     * @since Ant 1.8.0
-     */
-    public static final String DEEP_ROOT_MATCH = "**" + File.separatorChar;
-
     private static final SelectorUtils instance = new SelectorUtils();
     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
 
@@ -126,7 +112,30 @@
 
         String[] patDirs = tokenizePathAsArray(pattern);
         String[] strDirs = tokenizePathAsArray(str);
+        return matchPatternStart(patDirs, strDirs, isCaseSensitive);
+    }
+
 
+    /**
+     * Tests whether or not a given path matches the start of a given
+     * pattern up to the first "**".
+     * <p>
+     * This is not a general purpose test and should only be used if you
+     * can live with false positives. For example, <code>pattern=**\a</code>
+     * and <code>str=b</code> will yield <code>true</code>.
+     *
+     * @param patDirs The tokenized pattern to match against. Must not be
+     *                <code>null</code>.
+     * @param strDirs The tokenized path to match. Must not be
+     *                <code>null</code>.
+     * @param isCaseSensitive Whether or not matching should be performed
+     *                        case sensitively.
+     *
+     * @return whether or not a given path matches the start of a given
+     * pattern up to the first "**".
+     */
+    static boolean matchPatternStart(String[] patDirs, String[] strDirs,
+                                     boolean isCaseSensitive) {
         int patIdxStart = 0;
         int patIdxEnd = patDirs.length - 1;
         int strIdxStart = 0;



Re: svn commit: r695402 - in /ant/core/trunk/src/main/org/apache/tools/ant: DirectoryScanner.java types/selectors/PathPattern.java types/selectors/SelectorUtils.java

Posted by Gilles Scokart <gs...@gmail.com>.
2008/9/16 Stefan Bodewig <bo...@apache.org>:
> On Tue, 16 Sep 2008, Gilles Scokart <gs...@gmail.com> wrote:
>
>> I'm still thinking that a 'PathPattern' and a 'PathValue' (or
>> whatever name you preffer) are two different things that have
>> enought reality to exists as independent classes.
>
> I tried to come up with a different name for the class and failed to
> find anything meaningful, so yes, there probably is room for two
> separate classes (TokenizedPattern and TokenizedPath?).
>
> I'm willing to explore this - and to explore even more places in
> DirectoryScanner where we tokenize the same strings more than once.
>
> Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>

There is one very big case : when we recurse, we tokenize again and
again the beguin of the path.  But I don't think you can change that
by keeping the current protected API.

-- 
Gilles Scokart

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: svn commit: r695402 - in /ant/core/trunk/src/main/org/apache/tools/ant: DirectoryScanner.java types/selectors/PathPattern.java types/selectors/SelectorUtils.java

Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 16 Sep 2008, Gilles Scokart <gs...@gmail.com> wrote:

> I'm still thinking that a 'PathPattern' and a 'PathValue' (or
> whatever name you preffer) are two different things that have
> enought reality to exists as independent classes.

I tried to come up with a different name for the class and failed to
find anything meaningful, so yes, there probably is room for two
separate classes (TokenizedPattern and TokenizedPath?).

I'm willing to explore this - and to explore even more places in
DirectoryScanner where we tokenize the same strings more than once.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: svn commit: r695402 - in /ant/core/trunk/src/main/org/apache/tools/ant: DirectoryScanner.java types/selectors/PathPattern.java types/selectors/SelectorUtils.java

Posted by Gilles Scokart <gs...@gmail.com>.
2008/9/15 Stefan Bodewig <bo...@apache.org>:
> On Mon, 15 Sep 2008, Gilles Scokart <gs...@gmail.com> wrote:
>
>> Cool, I was thinking to do something like that but I was not sure
>> about the class to use, and wheter it was really usefull to store
>> tokenized path into an object in case we have a single include
>> patterns.  I missed the fact that isDeeper was also requiring a
>> tokenization.  So clearly my doubt about the usefullness was invalid
>> (I was thinking that we could eliminate a tokenization only when we
>> had 2 or more includes pattern on which we loop).
>
> True, even with a single include pattern (which we always have
> since "no include pattern" gets translated to "**") the file's name
> would get tokenized twice, as would the include pattern itself.
>>
>> However, with this change you are storing pattern and values in the
>> same class.
>
> Is your main problem the name of the class?
>
>> I think we should have two classes.  Both need to tokenize a
>> string using the same tokenizer, but what you can do with both is
>> different.
>
> I'm not convinced their behaviour is really any different, every
> name is a pattern as well.
>
> IIUC you'd prefer to move the match methods into a pattern specific
> class - and probably change the left and right side in the new
> matchPatternStartOf method so that the new method is on class
> representing the pattern (all delegating to SelecotrUtils).  This
> would class share the tokenization (delegated as well), depth and
> contains logic with a different class used for paths without any
> wildcards.
>
> We could do that, but I don't really see that much benefit.
>
> Stefan
>

I'm still thinking that a 'PathPattern' and a 'PathValue' (or whatever
name you preffer) are two different things that have enought reality
to exists as independent classes.

For the moment, we are just using those classes as a tokenized string
container, but I could very well imagine other behaviors.  For
instance, we could build a new PathValue based on an other PathValue
to avoid even more tokenization (I don't think it is possible by
keeping the DirectoryScanner protected method, but that could be used
somewhere else).

But maybe you are right, that's maybe a YAGNI.  Maybe this class
should just be a tokenized string container which is pattern oriented.
 In that case, I think it should be renamed. Maybe TokenizedPattern ,
TokeninzedPathPattern , TokenizedPatternOrValue  ?

As I said, I'm not sure.

-- 
Gilles Scokart

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: svn commit: r695402 - in /ant/core/trunk/src/main/org/apache/tools/ant: DirectoryScanner.java types/selectors/PathPattern.java types/selectors/SelectorUtils.java

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 15 Sep 2008, Gilles Scokart <gs...@gmail.com> wrote:

> Cool, I was thinking to do something like that but I was not sure
> about the class to use, and wheter it was really usefull to store
> tokenized path into an object in case we have a single include
> patterns.  I missed the fact that isDeeper was also requiring a
> tokenization.  So clearly my doubt about the usefullness was invalid
> (I was thinking that we could eliminate a tokenization only when we
> had 2 or more includes pattern on which we loop).

True, even with a single include pattern (which we always have
since "no include pattern" gets translated to "**") the file's name
would get tokenized twice, as would the include pattern itself.
> 
> However, with this change you are storing pattern and values in the
> same class.

Is your main problem the name of the class?

> I think we should have two classes.  Both need to tokenize a
> string using the same tokenizer, but what you can do with both is
> different.

I'm not convinced their behaviour is really any different, every
name is a pattern as well.

IIUC you'd prefer to move the match methods into a pattern specific
class - and probably change the left and right side in the new
matchPatternStartOf method so that the new method is on class
representing the pattern (all delegating to SelecotrUtils).  This
would class share the tokenization (delegated as well), depth and
contains logic with a different class used for paths without any
wildcards.

We could do that, but I don't really see that much benefit.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: svn commit: r695402 - in /ant/core/trunk/src/main/org/apache/tools/ant: DirectoryScanner.java types/selectors/PathPattern.java types/selectors/SelectorUtils.java

Posted by Gilles Scokart <gs...@gmail.com>.
Cool,
I was thinking to do something like that but I was not sure about the
class to use, and wheter it was really usefull to store tokenized path
into an object in case we have a single include patterns.
I missed the fact that isDeeper was also requiring a tokenization.  So
clearly my doubt about the usefullness was invalid (I was thinking
that we could eliminate a tokenization only when we had 2 or more
includes pattern on which we loop).

However, with this change you are storing pattern and values in the
same class.  I think we should have two classes.  Both need to
tokenize a string using the same tokenizer, but what you can do with
both is different.

WDYT?

Gilles


2008/9/15  <bo...@apache.org>:
> Author: bodewig
> Date: Mon Sep 15 02:54:06 2008
> New Revision: 695402
>
> URL: http://svn.apache.org/viewvc?rev=695402&view=rev
> Log:
> Avoid repeated tokenization, make DefaultExcludesTest happy.
>
> Modified:
>    ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java
>    ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/PathPattern.java
>    ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java
>
> Modified: ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java
> URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java?rev=695402&r1=695401&r2=695402&view=diff
> ==============================================================================
> --- ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java (original)
> +++ ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java Mon Sep 15 02:54:06 2008
> @@ -145,30 +145,30 @@
>      */
>     protected static final String[] DEFAULTEXCLUDES = {
>         // Miscellaneous typical temporary files
> -        SelectorUtils.DEEP_ROOT_MATCH + "*~",
> -        SelectorUtils.DEEP_ROOT_MATCH + "#*#",
> -        SelectorUtils.DEEP_ROOT_MATCH + ".#*",
> -        SelectorUtils.DEEP_ROOT_MATCH + "%*%",
> -        SelectorUtils.DEEP_ROOT_MATCH + "._*",
> +        SelectorUtils.DEEP_TREE_MATCH + "/*~",
> +        SelectorUtils.DEEP_TREE_MATCH + "/#*#",
> +        SelectorUtils.DEEP_TREE_MATCH + "/.#*",
> +        SelectorUtils.DEEP_TREE_MATCH + "/%*%",
> +        SelectorUtils.DEEP_TREE_MATCH + "/._*",
>
>         // CVS
> -        SelectorUtils.DEEP_ROOT_MATCH + "CVS",
> -        SelectorUtils.DEEP_ROOT_MATCH + "CVS" + SelectorUtils.DEEP_LEAVES_MATCH,
> -        SelectorUtils.DEEP_ROOT_MATCH + ".cvsignore",
> +        SelectorUtils.DEEP_TREE_MATCH + "/CVS",
> +        SelectorUtils.DEEP_TREE_MATCH + "/CVS/" + SelectorUtils.DEEP_TREE_MATCH,
> +        SelectorUtils.DEEP_TREE_MATCH + "/.cvsignore",
>
>         // SCCS
> -        SelectorUtils.DEEP_ROOT_MATCH + "SCCS",
> -        SelectorUtils.DEEP_ROOT_MATCH + "SCCS" + SelectorUtils.DEEP_LEAVES_MATCH,
> +        SelectorUtils.DEEP_TREE_MATCH + "/SCCS",
> +        SelectorUtils.DEEP_TREE_MATCH + "/SCCS/" + SelectorUtils.DEEP_TREE_MATCH,
>
>         // Visual SourceSafe
> -        SelectorUtils.DEEP_ROOT_MATCH + "vssver.scc",
> +        SelectorUtils.DEEP_TREE_MATCH + "/vssver.scc",
>
>         // Subversion
> -        SelectorUtils.DEEP_ROOT_MATCH + ".svn",
> -        SelectorUtils.DEEP_ROOT_MATCH + ".svn" + SelectorUtils.DEEP_LEAVES_MATCH,
> +        SelectorUtils.DEEP_TREE_MATCH + "/.svn",
> +        SelectorUtils.DEEP_TREE_MATCH + "/.svn/" + SelectorUtils.DEEP_TREE_MATCH,
>
>         // Mac
> -        SelectorUtils.DEEP_ROOT_MATCH + ".DS_Store"
> +        SelectorUtils.DEEP_TREE_MATCH + "/.DS_Store"
>     };
>
>     /**
> @@ -1295,10 +1295,13 @@
>      *         least one include pattern, or <code>false</code> otherwise.
>      */
>     protected boolean couldHoldIncluded(String name) {
> +        final PathPattern tokenizedName = new PathPattern(name);
>         for (int i = 0; i < includes.length; i++) {
> -            if (matchPatternStart(includes[i], name, isCaseSensitive())
> +            PathPattern tokenizedInclude = new PathPattern(includes[i]);
> +            if (tokenizedName.matchPatternStartOf(tokenizedInclude,
> +                                                  isCaseSensitive())
>                 && isMorePowerfulThanExcludes(name, includes[i])
> -                && isDeeper(includes[i], name)) {
> +                && isDeeper(tokenizedInclude, tokenizedName)) {
>                 return true;
>             }
>         }
> @@ -1313,13 +1316,9 @@
>      * @return whether the pattern is deeper than the name.
>      * @since Ant 1.6.3
>      */
> -    private boolean isDeeper(String pattern, String name) {
> -        Vector p = SelectorUtils.tokenizePath(pattern);
> -        if (!p.contains(SelectorUtils.DEEP_TREE_MATCH)) {
> -            Vector n = SelectorUtils.tokenizePath(name);
> -            return p.size() > n.size();
> -        }
> -        return true;
> +    private boolean isDeeper(PathPattern pattern, PathPattern name) {
> +        return pattern.containsPattern(SelectorUtils.DEEP_TREE_MATCH)
> +            || pattern.depth() > name.depth();
>     }
>
>     /**
> @@ -1341,7 +1340,8 @@
>      */
>     private boolean isMorePowerfulThanExcludes(String name,
>                                                String includepattern) {
> -        String soughtexclude = name + SelectorUtils.DEEP_LEAVES_MATCH;
> +        final String soughtexclude =
> +            name + File.separatorChar + SelectorUtils.DEEP_TREE_MATCH;
>         for (int counter = 0; counter < excludes.length; counter++) {
>             if (excludes[counter].equals(soughtexclude))  {
>                 return false;
>
> Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/PathPattern.java
> URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/PathPattern.java?rev=695402&r1=695401&r2=695402&view=diff
> ==============================================================================
> --- ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/PathPattern.java (original)
> +++ ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/PathPattern.java Mon Sep 15 02:54:06 2008
> @@ -70,6 +70,16 @@
>     }
>
>     /**
> +     * Tests whether or not this PathPattern matches the start of
> +     * another pattern.
> +     */
> +    public boolean matchPatternStartOf(PathPattern other,
> +                                       boolean caseSensitive) {
> +        return SelectorUtils.matchPatternStart(other.tokenizedPattern,
> +                                               tokenizedPattern, caseSensitive);
> +    }
> +
> +    /**
>      * @return The pattern String
>      */
>     public String toString() {
> @@ -79,4 +89,23 @@
>     public String getPattern() {
>         return pattern;
>     }
> +
> +    /**
> +     * The depth (or length) of a pattern.
> +     */
> +    public int depth() {
> +        return tokenizedPattern.length;
> +    }
> +
> +    /**
> +     * Does the tokenized pattern contain the given string?
> +     */
> +    public boolean containsPattern(String pat) {
> +        for (int i = 0; i < tokenizedPattern.length; i++) {
> +            if (tokenizedPattern[i].equals(pat)) {
> +                return true;
> +            }
> +        }
> +        return false;
> +    }
>  }
>
> Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java
> URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java?rev=695402&r1=695401&r2=695402&view=diff
> ==============================================================================
> --- ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java (original)
> +++ ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/SelectorUtils.java Mon Sep 15 02:54:06 2008
> @@ -44,20 +44,6 @@
>      */
>     public static final String DEEP_TREE_MATCH = "**";
>
> -    /**
> -     * The pattern that matches an arbitrary number of directories at
> -     * the leaves.
> -     * @since Ant 1.8.0
> -     */
> -    public static final String DEEP_LEAVES_MATCH = File.separatorChar + "**";
> -
> -    /**
> -     * The pattern that matches an arbitrary number of directories at
> -     * the root.
> -     * @since Ant 1.8.0
> -     */
> -    public static final String DEEP_ROOT_MATCH = "**" + File.separatorChar;
> -
>     private static final SelectorUtils instance = new SelectorUtils();
>     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
>
> @@ -126,7 +112,30 @@
>
>         String[] patDirs = tokenizePathAsArray(pattern);
>         String[] strDirs = tokenizePathAsArray(str);
> +        return matchPatternStart(patDirs, strDirs, isCaseSensitive);
> +    }
> +
>
> +    /**
> +     * Tests whether or not a given path matches the start of a given
> +     * pattern up to the first "**".
> +     * <p>
> +     * This is not a general purpose test and should only be used if you
> +     * can live with false positives. For example, <code>pattern=**\a</code>
> +     * and <code>str=b</code> will yield <code>true</code>.
> +     *
> +     * @param patDirs The tokenized pattern to match against. Must not be
> +     *                <code>null</code>.
> +     * @param strDirs The tokenized path to match. Must not be
> +     *                <code>null</code>.
> +     * @param isCaseSensitive Whether or not matching should be performed
> +     *                        case sensitively.
> +     *
> +     * @return whether or not a given path matches the start of a given
> +     * pattern up to the first "**".
> +     */
> +    static boolean matchPatternStart(String[] patDirs, String[] strDirs,
> +                                     boolean isCaseSensitive) {
>         int patIdxStart = 0;
>         int patIdxEnd = patDirs.length - 1;
>         int strIdxStart = 0;
>
>
>



-- 
Gilles Scokart

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org