git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@277248 13f79535-47bb-0310-9956-ffa450edef68master
@@ -34,11 +34,15 @@ public class JakartaOroMatcher implements RegexpMatcher { | |||||
protected final Perl5Compiler compiler = new Perl5Compiler(); | protected final Perl5Compiler compiler = new Perl5Compiler(); | ||||
protected final Perl5Matcher matcher = new Perl5Matcher(); | protected final Perl5Matcher matcher = new Perl5Matcher(); | ||||
/** | |||||
* Constructor for JakartaOroMatcher. | |||||
*/ | |||||
public JakartaOroMatcher() { | public JakartaOroMatcher() { | ||||
} | } | ||||
/** | /** | ||||
* Set the regexp pattern from the String description. | * Set the regexp pattern from the String description. | ||||
* @param pattern the pattern to match | |||||
*/ | */ | ||||
public void setPattern(String pattern) { | public void setPattern(String pattern) { | ||||
this.pattern = pattern; | this.pattern = pattern; | ||||
@@ -46,6 +50,7 @@ public class JakartaOroMatcher implements RegexpMatcher { | |||||
/** | /** | ||||
* Get a String representation of the regexp pattern | * Get a String representation of the regexp pattern | ||||
* @return the pattern | |||||
*/ | */ | ||||
public String getPattern() { | public String getPattern() { | ||||
return this.pattern; | return this.pattern; | ||||
@@ -53,6 +58,9 @@ public class JakartaOroMatcher implements RegexpMatcher { | |||||
/** | /** | ||||
* Get a compiled representation of the regexp pattern | * Get a compiled representation of the regexp pattern | ||||
* @param options the options | |||||
* @return the compiled pattern | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
protected Pattern getCompiledPattern(int options) | protected Pattern getCompiledPattern(int options) | ||||
throws BuildException { | throws BuildException { | ||||
@@ -66,7 +74,10 @@ public class JakartaOroMatcher implements RegexpMatcher { | |||||
} | } | ||||
/** | /** | ||||
* Does the given argument match the pattern? | |||||
* Does the given argument match the pattern using default options? | |||||
* @param argument the string to match against | |||||
* @return true if the pattern matches | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
public boolean matches(String argument) throws BuildException { | public boolean matches(String argument) throws BuildException { | ||||
return matches(argument, MATCH_DEFAULT); | return matches(argument, MATCH_DEFAULT); | ||||
@@ -74,6 +85,10 @@ public class JakartaOroMatcher implements RegexpMatcher { | |||||
/** | /** | ||||
* Does the given argument match the pattern? | * Does the given argument match the pattern? | ||||
* @param input the string to match against | |||||
* @param options the regex options to use | |||||
* @return true if the pattern matches | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
public boolean matches(String input, int options) | public boolean matches(String input, int options) | ||||
throws BuildException { | throws BuildException { | ||||
@@ -82,10 +97,15 @@ public class JakartaOroMatcher implements RegexpMatcher { | |||||
} | } | ||||
/** | /** | ||||
* Returns a Vector of matched groups found in the argument. | |||||
* Returns a Vector of matched groups found in the argument | |||||
* using default options. | |||||
* | * | ||||
* <p>Group 0 will be the full match, the rest are the | * <p>Group 0 will be the full match, the rest are the | ||||
* parenthesized subexpressions</p>. | * parenthesized subexpressions</p>. | ||||
* | |||||
* @param argument the string to match against | |||||
* @return the vector of groups | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
public Vector getGroups(String argument) throws BuildException { | public Vector getGroups(String argument) throws BuildException { | ||||
return getGroups(argument, MATCH_DEFAULT); | return getGroups(argument, MATCH_DEFAULT); | ||||
@@ -96,6 +116,11 @@ public class JakartaOroMatcher implements RegexpMatcher { | |||||
* | * | ||||
* <p>Group 0 will be the full match, the rest are the | * <p>Group 0 will be the full match, the rest are the | ||||
* parenthesized subexpressions</p>. | * parenthesized subexpressions</p>. | ||||
* | |||||
* @param input the string to match against | |||||
* @param options the regex options to use | |||||
* @return the vector of groups | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
public Vector getGroups(String input, int options) | public Vector getGroups(String input, int options) | ||||
throws BuildException { | throws BuildException { | ||||
@@ -116,6 +141,11 @@ public class JakartaOroMatcher implements RegexpMatcher { | |||||
return v; | return v; | ||||
} | } | ||||
/** | |||||
* Convert the generic options to the regex compiler specific options. | |||||
* @param options the generic options | |||||
* @return the specific options | |||||
*/ | |||||
protected int getCompilerOptions(int options) { | protected int getCompilerOptions(int options) { | ||||
int cOptions = Perl5Compiler.DEFAULT_MASK; | int cOptions = Perl5Compiler.DEFAULT_MASK; | ||||
@@ -28,10 +28,19 @@ import org.apache.tools.ant.BuildException; | |||||
*/ | */ | ||||
public class JakartaOroRegexp extends JakartaOroMatcher implements Regexp { | public class JakartaOroRegexp extends JakartaOroMatcher implements Regexp { | ||||
/** Constructor for JakartaOroRegexp */ | |||||
public JakartaOroRegexp() { | public JakartaOroRegexp() { | ||||
super(); | super(); | ||||
} | } | ||||
/** | |||||
* Perform a substitution on the regular expression. | |||||
* @param input The string to substitute on | |||||
* @param argument The string which defines the substitution | |||||
* @param options The list of options for the match and replace. | |||||
* @return the result of the operation | |||||
* @throws BuildException on error | |||||
*/ | |||||
public String substitute(String input, String argument, int options) | public String substitute(String input, String argument, int options) | ||||
throws BuildException { | throws BuildException { | ||||
// translate \1 to $1 so that the Perl5Substitution will work | // translate \1 to $1 so that the Perl5Substitution will work | ||||
@@ -71,6 +80,12 @@ public class JakartaOroRegexp extends JakartaOroMatcher implements Regexp { | |||||
getSubsOptions(options)); | getSubsOptions(options)); | ||||
} | } | ||||
/** | |||||
* Convert ant regexp substitution option to oro options. | |||||
* | |||||
* @param options the ant regexp options | |||||
* @return the oro substition options | |||||
*/ | |||||
protected int getSubsOptions(int options) { | protected int getSubsOptions(int options) { | ||||
boolean replaceAll = RegexpUtil.hasFlag(options, REPLACE_ALL); | boolean replaceAll = RegexpUtil.hasFlag(options, REPLACE_ALL); | ||||
int subsOptions = 1; | int subsOptions = 1; | ||||
@@ -32,6 +32,7 @@ public class JakartaRegexpMatcher implements RegexpMatcher { | |||||
/** | /** | ||||
* Set the regexp pattern from the String description. | * Set the regexp pattern from the String description. | ||||
* @param pattern the pattern to match | |||||
*/ | */ | ||||
public void setPattern(String pattern) { | public void setPattern(String pattern) { | ||||
this.pattern = pattern; | this.pattern = pattern; | ||||
@@ -39,11 +40,19 @@ public class JakartaRegexpMatcher implements RegexpMatcher { | |||||
/** | /** | ||||
* Get a String representation of the regexp pattern | * Get a String representation of the regexp pattern | ||||
* @return the pattern | |||||
*/ | */ | ||||
public String getPattern() { | public String getPattern() { | ||||
return pattern; | return pattern; | ||||
} | } | ||||
/** | |||||
* Compile the pattern. | |||||
* | |||||
* @param options the ant regexp options | |||||
* @return a compiled pattern | |||||
* @exception BuildException if an error occurs | |||||
*/ | |||||
protected RE getCompiledPattern(int options) | protected RE getCompiledPattern(int options) | ||||
throws BuildException { | throws BuildException { | ||||
int cOptions = getCompilerOptions(options); | int cOptions = getCompilerOptions(options); | ||||
@@ -58,6 +67,9 @@ public class JakartaRegexpMatcher implements RegexpMatcher { | |||||
/** | /** | ||||
* Does the given argument match the pattern? | * Does the given argument match the pattern? | ||||
* @param argument the string to match against | |||||
* @return true if the pattern matches | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
public boolean matches(String argument) throws BuildException { | public boolean matches(String argument) throws BuildException { | ||||
return matches(argument, MATCH_DEFAULT); | return matches(argument, MATCH_DEFAULT); | ||||
@@ -65,6 +77,10 @@ public class JakartaRegexpMatcher implements RegexpMatcher { | |||||
/** | /** | ||||
* Does the given argument match the pattern? | * Does the given argument match the pattern? | ||||
* @param input the string to match against | |||||
* @param options the regex options to use | |||||
* @return true if the pattern matches | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
public boolean matches(String input, int options) | public boolean matches(String input, int options) | ||||
throws BuildException { | throws BuildException { | ||||
@@ -76,15 +92,31 @@ public class JakartaRegexpMatcher implements RegexpMatcher { | |||||
} | } | ||||
/** | /** | ||||
* Returns a Vector of matched groups found in the argument. | |||||
* Returns a Vector of matched groups found in the argument | |||||
* using default options. | |||||
* | * | ||||
* <p>Group 0 will be the full match, the rest are the | * <p>Group 0 will be the full match, the rest are the | ||||
* parenthesized subexpressions</p>. | * parenthesized subexpressions</p>. | ||||
* | |||||
* @param argument the string to match against | |||||
* @return the vector of groups | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
public Vector getGroups(String argument) throws BuildException { | public Vector getGroups(String argument) throws BuildException { | ||||
return getGroups(argument, MATCH_DEFAULT); | return getGroups(argument, MATCH_DEFAULT); | ||||
} | } | ||||
/** | |||||
* Returns a Vector of matched groups found in the argument. | |||||
* | |||||
* <p>Group 0 will be the full match, the rest are the | |||||
* parenthesized subexpressions</p>. | |||||
* | |||||
* @param input the string to match against | |||||
* @param options the regex options to use | |||||
* @return the vector of groups | |||||
* @throws BuildException on error | |||||
*/ | |||||
public Vector getGroups(String input, int options) | public Vector getGroups(String input, int options) | ||||
throws BuildException { | throws BuildException { | ||||
RE reg = getCompiledPattern(options); | RE reg = getCompiledPattern(options); | ||||
@@ -104,6 +136,11 @@ public class JakartaRegexpMatcher implements RegexpMatcher { | |||||
return v; | return v; | ||||
} | } | ||||
/** | |||||
* Convert the generic options to the regex compiler specific options. | |||||
* @param options the generic options | |||||
* @return the specific options | |||||
*/ | |||||
protected int getCompilerOptions(int options) { | protected int getCompilerOptions(int options) { | ||||
int cOptions = RE.MATCH_NORMAL; | int cOptions = RE.MATCH_NORMAL; | ||||
@@ -27,10 +27,17 @@ import org.apache.tools.ant.BuildException; | |||||
public class JakartaRegexpRegexp extends JakartaRegexpMatcher | public class JakartaRegexpRegexp extends JakartaRegexpMatcher | ||||
implements Regexp { | implements Regexp { | ||||
/** Constructor for JakartaRegexpRegexp */ | |||||
public JakartaRegexpRegexp() { | public JakartaRegexpRegexp() { | ||||
super(); | super(); | ||||
} | } | ||||
/** | |||||
* Convert ant regexp substitution option to apache regex options. | |||||
* | |||||
* @param options the ant regexp options | |||||
* @return the apache regex substition options | |||||
*/ | |||||
protected int getSubsOptions(int options) { | protected int getSubsOptions(int options) { | ||||
int subsOptions = RE.REPLACE_FIRSTONLY; | int subsOptions = RE.REPLACE_FIRSTONLY; | ||||
if (RegexpUtil.hasFlag(options, REPLACE_ALL)) { | if (RegexpUtil.hasFlag(options, REPLACE_ALL)) { | ||||
@@ -39,6 +46,14 @@ public class JakartaRegexpRegexp extends JakartaRegexpMatcher | |||||
return subsOptions; | return subsOptions; | ||||
} | } | ||||
/** | |||||
* Perform a substitution on the regular expression. | |||||
* @param input The string to substitute on | |||||
* @param argument The string which defines the substitution | |||||
* @param options The list of options for the match and replace. | |||||
* @return the result of the operation | |||||
* @throws BuildException on error | |||||
*/ | |||||
public String substitute(String input, String argument, int options) | public String substitute(String input, String argument, int options) | ||||
throws BuildException { | throws BuildException { | ||||
Vector v = getGroups(input, options); | Vector v = getGroups(input, options); | ||||
@@ -32,11 +32,13 @@ public class Jdk14RegexpMatcher implements RegexpMatcher { | |||||
private String pattern; | private String pattern; | ||||
/** Constructor for JakartaOroRegexp */ | |||||
public Jdk14RegexpMatcher() { | public Jdk14RegexpMatcher() { | ||||
} | } | ||||
/** | /** | ||||
* Set the regexp pattern from the String description. | * Set the regexp pattern from the String description. | ||||
* @param pattern the pattern to match | |||||
*/ | */ | ||||
public void setPattern(String pattern) { | public void setPattern(String pattern) { | ||||
this.pattern = pattern; | this.pattern = pattern; | ||||
@@ -44,11 +46,19 @@ public class Jdk14RegexpMatcher implements RegexpMatcher { | |||||
/** | /** | ||||
* Get a String representation of the regexp pattern | * Get a String representation of the regexp pattern | ||||
* @return the pattern | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
public String getPattern() { | public String getPattern() { | ||||
return pattern; | return pattern; | ||||
} | } | ||||
/** | |||||
* Get a compiled representation of the regexp pattern | |||||
* @param options the options | |||||
* @return the compiled pattern | |||||
* @throws BuildException on error | |||||
*/ | |||||
protected Pattern getCompiledPattern(int options) | protected Pattern getCompiledPattern(int options) | ||||
throws BuildException { | throws BuildException { | ||||
int cOptions = getCompilerOptions(options); | int cOptions = getCompilerOptions(options); | ||||
@@ -61,7 +71,10 @@ public class Jdk14RegexpMatcher implements RegexpMatcher { | |||||
} | } | ||||
/** | /** | ||||
* Does the given argument match the pattern? | |||||
* Does the given argument match the pattern using default options? | |||||
* @param argument the string to match against | |||||
* @return true if the pattern matches | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
public boolean matches(String argument) throws BuildException { | public boolean matches(String argument) throws BuildException { | ||||
return matches(argument, MATCH_DEFAULT); | return matches(argument, MATCH_DEFAULT); | ||||
@@ -69,6 +82,10 @@ public class Jdk14RegexpMatcher implements RegexpMatcher { | |||||
/** | /** | ||||
* Does the given argument match the pattern? | * Does the given argument match the pattern? | ||||
* @param input the string to match against | |||||
* @param options the regex options to use | |||||
* @return true if the pattern matches | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
public boolean matches(String input, int options) | public boolean matches(String input, int options) | ||||
throws BuildException { | throws BuildException { | ||||
@@ -81,10 +98,15 @@ public class Jdk14RegexpMatcher implements RegexpMatcher { | |||||
} | } | ||||
/** | /** | ||||
* Returns a Vector of matched groups found in the argument. | |||||
* Returns a Vector of matched groups found in the argument | |||||
* using default options. | |||||
* | * | ||||
* <p>Group 0 will be the full match, the rest are the | * <p>Group 0 will be the full match, the rest are the | ||||
* parenthesized subexpressions</p>. | * parenthesized subexpressions</p>. | ||||
* | |||||
* @param argument the string to match against | |||||
* @return the vector of groups | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
public Vector getGroups(String argument) throws BuildException { | public Vector getGroups(String argument) throws BuildException { | ||||
return getGroups(argument, MATCH_DEFAULT); | return getGroups(argument, MATCH_DEFAULT); | ||||
@@ -95,6 +117,11 @@ public class Jdk14RegexpMatcher implements RegexpMatcher { | |||||
* | * | ||||
* <p>Group 0 will be the full match, the rest are the | * <p>Group 0 will be the full match, the rest are the | ||||
* parenthesized subexpressions</p>. | * parenthesized subexpressions</p>. | ||||
* | |||||
* @param input the string to match against | |||||
* @param options the regex options to use | |||||
* @return the vector of groups | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
public Vector getGroups(String input, int options) | public Vector getGroups(String input, int options) | ||||
throws BuildException { | throws BuildException { | ||||
@@ -116,6 +143,11 @@ public class Jdk14RegexpMatcher implements RegexpMatcher { | |||||
return v; | return v; | ||||
} | } | ||||
/** | |||||
* Convert the generic options to the regex compiler specific options. | |||||
* @param options the generic options | |||||
* @return the specific options | |||||
*/ | |||||
protected int getCompilerOptions(int options) { | protected int getCompilerOptions(int options) { | ||||
// be strict about line separator | // be strict about line separator | ||||
int cOptions = Pattern.UNIX_LINES; | int cOptions = Pattern.UNIX_LINES; | ||||
@@ -27,10 +27,17 @@ import org.apache.tools.ant.BuildException; | |||||
*/ | */ | ||||
public class Jdk14RegexpRegexp extends Jdk14RegexpMatcher implements Regexp { | public class Jdk14RegexpRegexp extends Jdk14RegexpMatcher implements Regexp { | ||||
/** Constructor for Jdk14RegexpRegexp */ | |||||
public Jdk14RegexpRegexp() { | public Jdk14RegexpRegexp() { | ||||
super(); | super(); | ||||
} | } | ||||
/** | |||||
* Convert ant regexp substitution option to jdk1.4 options. | |||||
* | |||||
* @param options the ant regexp options | |||||
* @return the jdk14 substition options | |||||
*/ | |||||
protected int getSubsOptions(int options) { | protected int getSubsOptions(int options) { | ||||
int subsOptions = REPLACE_FIRST; | int subsOptions = REPLACE_FIRST; | ||||
if (RegexpUtil.hasFlag(options, REPLACE_ALL)) { | if (RegexpUtil.hasFlag(options, REPLACE_ALL)) { | ||||
@@ -39,6 +46,14 @@ public class Jdk14RegexpRegexp extends Jdk14RegexpMatcher implements Regexp { | |||||
return subsOptions; | return subsOptions; | ||||
} | } | ||||
/** | |||||
* Perform a substitution on the regular expression. | |||||
* @param input The string to substitute on | |||||
* @param argument The string which defines the substitution | |||||
* @param options The list of options for the match and replace. | |||||
* @return the result of the operation | |||||
* @throws BuildException on error | |||||
*/ | |||||
public String substitute(String input, String argument, int options) | public String substitute(String input, String argument, int options) | ||||
throws BuildException { | throws BuildException { | ||||
// translate \1 to $(1) so that the Matcher will work | // translate \1 to $(1) so that the Matcher will work | ||||
@@ -41,6 +41,8 @@ public interface Regexp extends RegexpMatcher { | |||||
* @param argument The string which defines the substitution | * @param argument The string which defines the substitution | ||||
* @param options The list of options for the match and replace. See the | * @param options The list of options for the match and replace. See the | ||||
* MATCH_ and REPLACE_ constants above. | * MATCH_ and REPLACE_ constants above. | ||||
* @return the result of the operation | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
String substitute(String input, String argument, int options) | String substitute(String input, String argument, int options) | ||||
throws BuildException; | throws BuildException; | ||||
@@ -27,11 +27,15 @@ import org.apache.tools.ant.Project; | |||||
* @version $Revision$ | * @version $Revision$ | ||||
*/ | */ | ||||
public class RegexpFactory extends RegexpMatcherFactory { | public class RegexpFactory extends RegexpMatcherFactory { | ||||
/** Constructor for RegexpFactory */ | |||||
public RegexpFactory() { | public RegexpFactory() { | ||||
} | } | ||||
/*** | /*** | ||||
* Create a new regular expression matcher instance. | * Create a new regular expression matcher instance. | ||||
* @return the matcher instance | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
public Regexp newRegexp() throws BuildException { | public Regexp newRegexp() throws BuildException { | ||||
return (Regexp) newRegexp(null); | return (Regexp) newRegexp(null); | ||||
@@ -41,6 +45,8 @@ public class RegexpFactory extends RegexpMatcherFactory { | |||||
* Create a new regular expression matcher instance. | * Create a new regular expression matcher instance. | ||||
* | * | ||||
* @param p Project whose ant.regexp.regexpimpl property will be used. | * @param p Project whose ant.regexp.regexpimpl property will be used. | ||||
* @return the matcher instance | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
public Regexp newRegexp(Project p) throws BuildException { | public Regexp newRegexp(Project p) throws BuildException { | ||||
String systemDefault = null; | String systemDefault = null; | ||||
@@ -50,24 +50,36 @@ public interface RegexpMatcher { | |||||
/** | /** | ||||
* Set the regexp pattern from the String description. | * Set the regexp pattern from the String description. | ||||
* @param pattern the pattern to match | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
void setPattern(String pattern) throws BuildException; | void setPattern(String pattern) throws BuildException; | ||||
/** | /** | ||||
* Get a String representation of the regexp pattern | * Get a String representation of the regexp pattern | ||||
* @return the pattern | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
String getPattern() throws BuildException; | String getPattern() throws BuildException; | ||||
/** | /** | ||||
* Does the given argument match the pattern? | * Does the given argument match the pattern? | ||||
* @param argument the string to match against | |||||
* @return true if the pattern matches | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
boolean matches(String argument) throws BuildException; | boolean matches(String argument) throws BuildException; | ||||
/** | /** | ||||
* Returns a Vector of matched groups found in the argument. | |||||
* Returns a Vector of matched groups found in the argument | |||||
* using default options. | |||||
* | * | ||||
* <p>Group 0 will be the full match, the rest are the | * <p>Group 0 will be the full match, the rest are the | ||||
* parenthesized subexpressions</p>. | * parenthesized subexpressions</p>. | ||||
* | |||||
* @param argument the string to match against | |||||
* @return the vector of groups | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
Vector getGroups(String argument) throws BuildException; | Vector getGroups(String argument) throws BuildException; | ||||
@@ -77,6 +89,8 @@ public interface RegexpMatcher { | |||||
* @param input The string to check for a match | * @param input The string to check for a match | ||||
* @param options The list of options for the match. See the | * @param options The list of options for the match. See the | ||||
* MATCH_ constants above. | * MATCH_ constants above. | ||||
* @return true if the pattern matches | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
boolean matches(String input, int options) throws BuildException; | boolean matches(String input, int options) throws BuildException; | ||||
@@ -86,6 +100,8 @@ public interface RegexpMatcher { | |||||
* @param input The string to check for a match | * @param input The string to check for a match | ||||
* @param options The list of options for the match. See the | * @param options The list of options for the match. See the | ||||
* MATCH_ constants above. | * MATCH_ constants above. | ||||
* @return the vector of groups | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
Vector getGroups(String input, int options) throws BuildException; | Vector getGroups(String input, int options) throws BuildException; | ||||
@@ -32,11 +32,14 @@ import org.apache.tools.ant.Project; | |||||
*/ | */ | ||||
public class RegexpMatcherFactory { | public class RegexpMatcherFactory { | ||||
/** Constructor for RegexpMatcherFactory. */ | |||||
public RegexpMatcherFactory() { | public RegexpMatcherFactory() { | ||||
} | } | ||||
/*** | /*** | ||||
* Create a new regular expression instance. | * Create a new regular expression instance. | ||||
* @return the matcher | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
public RegexpMatcher newRegexpMatcher() throws BuildException { | public RegexpMatcher newRegexpMatcher() throws BuildException { | ||||
return newRegexpMatcher(null); | return newRegexpMatcher(null); | ||||
@@ -46,6 +49,8 @@ public class RegexpMatcherFactory { | |||||
* Create a new regular expression instance. | * Create a new regular expression instance. | ||||
* | * | ||||
* @param p Project whose ant.regexp.regexpimpl property will be used. | * @param p Project whose ant.regexp.regexpimpl property will be used. | ||||
* @return the matcher | |||||
* @throws BuildException on error | |||||
*/ | */ | ||||
public RegexpMatcher newRegexpMatcher(Project p) | public RegexpMatcher newRegexpMatcher(Project p) | ||||
throws BuildException { | throws BuildException { | ||||
@@ -86,6 +91,13 @@ public class RegexpMatcherFactory { | |||||
throw new BuildException("No supported regular expression matcher found"); | throw new BuildException("No supported regular expression matcher found"); | ||||
} | } | ||||
/** | |||||
* Create an instance of a matcher from a classname. | |||||
* | |||||
* @param className a <code>String</code> value | |||||
* @return a <code>RegexpMatcher</code> value | |||||
* @exception BuildException if an error occurs | |||||
*/ | |||||
protected RegexpMatcher createInstance(String className) | protected RegexpMatcher createInstance(String className) | ||||
throws BuildException { | throws BuildException { | ||||
try { | try { | ||||
@@ -96,6 +108,12 @@ public class RegexpMatcherFactory { | |||||
} | } | ||||
} | } | ||||
/** | |||||
* Test if a particular class is available to be used. | |||||
* | |||||
* @param className a <code>String</code> value | |||||
* @exception BuildException if an error occurs | |||||
*/ | |||||
protected void testAvailability(String className) throws BuildException { | protected void testAvailability(String className) throws BuildException { | ||||
try { | try { | ||||
Class.forName(className); | Class.forName(className); | ||||
@@ -17,18 +17,32 @@ | |||||
package org.apache.tools.ant.util.regexp; | package org.apache.tools.ant.util.regexp; | ||||
/*** | /*** | ||||
* Regular expression utilities class which handles flag operations | |||||
* Regular expression utilities class which handles flag operations. | |||||
* | * | ||||
*/ | */ | ||||
public class RegexpUtil { | |||||
public final class RegexpUtil { | |||||
private RegexpUtil() { | private RegexpUtil() { | ||||
} | } | ||||
public static final boolean hasFlag(int options, int flag) { | |||||
/** | |||||
* Check the options has a particular flag set. | |||||
* | |||||
* @param options an <code>int</code> value | |||||
* @param flag an <code>int</code> value | |||||
* @return true if the flag is set | |||||
*/ | |||||
public static boolean hasFlag(int options, int flag) { | |||||
return ((options & flag) > 0); | return ((options & flag) > 0); | ||||
} | } | ||||
public static final int removeFlag(int options, int flag) { | |||||
/** | |||||
* Remove a particular flag from an int value contains the option flags. | |||||
* | |||||
* @param options an <code>int</code> value | |||||
* @param flag an <code>int</code> value | |||||
* @return the options with the flag unset | |||||
*/ | |||||
public static int removeFlag(int options, int flag) { | |||||
return (options & (0xFFFFFFFF - flag)); | return (options & (0xFFFFFFFF - flag)); | ||||
} | } | ||||
} | } |