Author: bodewig
Date: Tue Sep 16 21:27:09 2008
New Revision: 696146
URL: http://svn.apache.org/viewvc?rev=696146&view=rev
Log:
split PathPattern into two classes, more behavior will be added later
Added:
ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/TokenizedPath.java
(contents, props changed)
- copied, changed from r695864,
ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/PathPattern.java
ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/TokenizedPattern.java
(contents, props changed)
- copied, changed from r695864,
ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/PathPattern.java
Removed:
ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/PathPattern.java
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.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=696146&r1=696145&r2=696146&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 Tue Sep
16 21:27:09 2008
@@ -36,9 +36,10 @@
import org.apache.tools.ant.types.ResourceFactory;
import org.apache.tools.ant.types.resources.FileResource;
import org.apache.tools.ant.types.selectors.FileSelector;
-import org.apache.tools.ant.types.selectors.PathPattern;
import org.apache.tools.ant.types.selectors.SelectorScanner;
import org.apache.tools.ant.types.selectors.SelectorUtils;
+import org.apache.tools.ant.types.selectors.TokenizedPath;
+import org.apache.tools.ant.types.selectors.TokenizedPattern;
import org.apache.tools.ant.util.CollectionUtils;
import org.apache.tools.ant.util.FileUtils;
@@ -335,7 +336,7 @@
* isIncluded or isExcluded and cleared at the end of the scan
* method (cleared in clearCaches, actually).</p>
*/
- private PathPattern[] includePatterns;
+ private TokenizedPattern[] includePatterns;
/**
* Array of all exclude patterns that contain wildcards.
@@ -344,7 +345,7 @@
* isIncluded or isExcluded and cleared at the end of the scan
* method (cleared in clearCaches, actually).</p>
*/
- private PathPattern[] excludePatterns;
+ private TokenizedPattern[] excludePatterns;
/**
* Have the non-pattern sets and pattern arrays for in- and
@@ -1291,11 +1292,11 @@
* least one include pattern, or <code>false</code> otherwise.
*/
protected boolean couldHoldIncluded(String name) {
- final PathPattern tokenizedName = new PathPattern(name);
+ final TokenizedPath tokenizedName = new TokenizedPath(name);
for (int i = 0; i < includes.length; i++) {
- PathPattern tokenizedInclude = new PathPattern(includes[i]);
- if (tokenizedName.matchPatternStartOf(tokenizedInclude,
- isCaseSensitive())
+ TokenizedPattern tokenizedInclude =
+ new TokenizedPattern(includes[i]);
+ if (tokenizedInclude.matchStartOf(tokenizedName, isCaseSensitive())
&& isMorePowerfulThanExcludes(name, includes[i])
&& isDeeper(tokenizedInclude, tokenizedName)) {
return true;
@@ -1312,7 +1313,7 @@
* @return whether the pattern is deeper than the name.
* @since Ant 1.6.3
*/
- private boolean isDeeper(PathPattern pattern, PathPattern name) {
+ private boolean isDeeper(TokenizedPattern pattern, TokenizedPath name) {
return pattern.containsPattern(SelectorUtils.DEEP_TREE_MATCH)
|| pattern.depth() > name.depth();
}
@@ -1802,17 +1803,17 @@
* @param patterns String[] of patterns.
* @since Ant 1.6.3
*/
- private PathPattern[] fillNonPatternSet(Set set, String[] patterns) {
+ private TokenizedPattern[] fillNonPatternSet(Set set, String[] patterns) {
ArrayList al = new ArrayList(patterns.length);
for (int i = 0; i < patterns.length; i++) {
if (!SelectorUtils.hasWildcards(patterns[i])) {
set.add(isCaseSensitive() ? patterns[i]
: patterns[i].toUpperCase());
} else {
- al.add(new PathPattern(patterns[i]));
+ al.add(new TokenizedPattern(patterns[i]));
}
}
- return (PathPattern[]) al.toArray(new PathPattern[al.size()]);
+ return (TokenizedPattern[]) al.toArray(new
TokenizedPattern[al.size()]);
}
/**
Copied:
ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/TokenizedPath.java
(from r695864,
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/TokenizedPath.java?p2=ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/TokenizedPath.java&p1=ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/PathPattern.java&r1=695864&r2=696146&rev=696146&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/TokenizedPath.java
Tue Sep 16 21:27:09 2008
@@ -19,93 +19,39 @@
package org.apache.tools.ant.types.selectors;
/**
- * Provides reusable path pattern matching. PathPattern is preferable to
equivalent
- * SelectorUtils methods if you need to execute multiple matching with the
same pattern
- * because here the pattern itself will be parsed only once.
- * @see SelectorUtils#matchPath(String, String)
- * @see SelectorUtils#matchPath(String, String, boolean)
- * @since 1.8
+ * Container for a path that has been split into its components.
+ * @since 1.8.0
*/
-public class PathPattern {
+public class TokenizedPath {
- private final String pattern;
- private final String tokenizedPattern[];
+ private final String path;
+ private final String tokenizedPath[];
/**
- * Initialize the PathPattern by parsing it.
- * @param pattern The pattern to match against. Must not be
+ * Initialize the TokenizedPath by parsing it.
+ * @param path The path to tokenize. Must not be
* <code>null</code>.
*/
- public PathPattern(String pattern) {
- this.pattern = pattern;
- this.tokenizedPattern = SelectorUtils.tokenizePathAsArray(pattern);
+ public TokenizedPath(String path) {
+ this.path = path;
+ this.tokenizedPath = SelectorUtils.tokenizePathAsArray(path);
}
/**
- * Tests whether or not a given path matches a given pattern.
- *
- * @param str The path to match, as a String. Must not be
- * <code>null</code>.
- *
- * @return <code>true</code> if the pattern matches against the string,
- * or <code>false</code> otherwise.
- */
- public boolean matchPath(String str) {
- return SelectorUtils.matchPath(tokenizedPattern, str, true);
- }
-
- /**
- * Tests whether or not a given path matches a given pattern.
- *
- * @param str The path to match, as a String. Must not be
- * <code>null</code>.
- * @param isCaseSensitive Whether or not matching should be performed
- * case sensitively.
- *
- * @return <code>true</code> if the pattern matches against the string,
- * or <code>false</code> otherwise.
- */
- public boolean matchPath(String str, boolean isCaseSensitive) {
- return SelectorUtils.matchPath(tokenizedPattern, str, isCaseSensitive);
- }
-
- /**
- * 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
+ * @return The original path String
*/
public String toString() {
- return pattern;
+ return path;
}
- public String getPattern() {
- return pattern;
- }
-
/**
- * The depth (or length) of a pattern.
+ * The depth (or length) of a path.
*/
public int depth() {
- return tokenizedPattern.length;
+ return tokenizedPath.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;
+ /* package */ String[] getTokens() {
+ return tokenizedPath;
}
}
Propchange:
ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/TokenizedPath.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/TokenizedPath.java
------------------------------------------------------------------------------
svn:mergeinfo =
Copied:
ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/TokenizedPattern.java
(from r695864,
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/TokenizedPattern.java?p2=ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/TokenizedPattern.java&p1=ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/PathPattern.java&r1=695864&r2=696146&rev=696146&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/TokenizedPattern.java
Tue Sep 16 21:27:09 2008
@@ -26,7 +26,7 @@
* @see SelectorUtils#matchPath(String, String, boolean)
* @since 1.8
*/
-public class PathPattern {
+public class TokenizedPattern {
private final String pattern;
private final String tokenizedPattern[];
@@ -36,7 +36,7 @@
* @param pattern The pattern to match against. Must not be
* <code>null</code>.
*/
- public PathPattern(String pattern) {
+ public TokenizedPattern(String pattern) {
this.pattern = pattern;
this.tokenizedPattern = SelectorUtils.tokenizePathAsArray(pattern);
}
@@ -70,13 +70,13 @@
}
/**
- * Tests whether or not this PathPattern matches the start of
- * another pattern.
+ * Tests whether or not this pattern matches the start of
+ * a path.
*/
- public boolean matchPatternStartOf(PathPattern other,
- boolean caseSensitive) {
- return SelectorUtils.matchPatternStart(other.tokenizedPattern,
- tokenizedPattern,
caseSensitive);
+ public boolean matchStartOf(TokenizedPath path,
+ boolean caseSensitive) {
+ return SelectorUtils.matchPatternStart(tokenizedPattern,
+ path.getTokens(),
caseSensitive);
}
/**
Propchange:
ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/TokenizedPattern.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
ant/core/trunk/src/main/org/apache/tools/ant/types/selectors/TokenizedPattern.java
------------------------------------------------------------------------------
svn:mergeinfo =