peterreilly 2004/12/17 11:46:05 Modified: src/main/org/apache/tools/ant/util/regexp JakartaOroMatcher.java JakartaOroRegexp.java JakartaRegexpMatcher.java JakartaRegexpRegexp.java Jdk14RegexpMatcher.java Jdk14RegexpRegexp.java Regexp.java RegexpFactory.java RegexpMatcher.java RegexpMatcherFactory.java RegexpUtil.java Log: checkstyle Revision Changes Path 1.18 +32 -2 ant/src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java Index: JakartaOroMatcher.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/regexp/JakartaOroMatcher.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- JakartaOroMatcher.java 9 Mar 2004 16:48:54 -0000 1.17 +++ JakartaOroMatcher.java 17 Dec 2004 19:46:04 -0000 1.18 @@ -34,11 +34,15 @@ protected final Perl5Compiler compiler = new Perl5Compiler(); protected final Perl5Matcher matcher = new Perl5Matcher(); + /** + * Constructor for JakartaOroMatcher. + */ public JakartaOroMatcher() { } /** * Set the regexp pattern from the String description. + * @param pattern the pattern to match */ public void setPattern(String pattern) { this.pattern = pattern; @@ -46,6 +50,7 @@ /** * Get a String representation of the regexp pattern + * @return the pattern */ public String getPattern() { return this.pattern; @@ -53,6 +58,9 @@ /** * 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) throws BuildException { @@ -66,7 +74,10 @@ } /** - * 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 { return matches(argument, MATCH_DEFAULT); @@ -74,6 +85,10 @@ /** * 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) throws BuildException { @@ -82,10 +97,15 @@ } /** - * 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 * 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 { return getGroups(argument, MATCH_DEFAULT); @@ -96,6 +116,11 @@ * * <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) throws BuildException { @@ -116,6 +141,11 @@ 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) { int cOptions = Perl5Compiler.DEFAULT_MASK; 1.17 +15 -0 ant/src/main/org/apache/tools/ant/util/regexp/JakartaOroRegexp.java Index: JakartaOroRegexp.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/regexp/JakartaOroRegexp.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- JakartaOroRegexp.java 9 Mar 2004 16:48:54 -0000 1.16 +++ JakartaOroRegexp.java 17 Dec 2004 19:46:04 -0000 1.17 @@ -28,10 +28,19 @@ */ public class JakartaOroRegexp extends JakartaOroMatcher implements Regexp { + /** Constructor for JakartaOroRegexp */ public JakartaOroRegexp() { 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) throws BuildException { // translate \1 to $1 so that the Perl5Substitution will work @@ -71,6 +80,12 @@ 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) { boolean replaceAll = RegexpUtil.hasFlag(options, REPLACE_ALL); int subsOptions = 1; 1.20 +38 -1 ant/src/main/org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.java Index: JakartaRegexpMatcher.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/regexp/JakartaRegexpMatcher.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- JakartaRegexpMatcher.java 9 Mar 2004 16:48:54 -0000 1.19 +++ JakartaRegexpMatcher.java 17 Dec 2004 19:46:04 -0000 1.20 @@ -32,6 +32,7 @@ /** * Set the regexp pattern from the String description. + * @param pattern the pattern to match */ public void setPattern(String pattern) { this.pattern = pattern; @@ -39,11 +40,19 @@ /** * Get a String representation of the regexp pattern + * @return the pattern */ public String getPattern() { 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) throws BuildException { int cOptions = getCompilerOptions(options); @@ -58,6 +67,9 @@ /** * 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 { return matches(argument, MATCH_DEFAULT); @@ -65,6 +77,10 @@ /** * 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) throws BuildException { @@ -76,15 +92,31 @@ } /** - * 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 * 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 { 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) throws BuildException { RE reg = getCompiledPattern(options); @@ -104,6 +136,11 @@ 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) { int cOptions = RE.MATCH_NORMAL; 1.16 +15 -0 ant/src/main/org/apache/tools/ant/util/regexp/JakartaRegexpRegexp.java Index: JakartaRegexpRegexp.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/regexp/JakartaRegexpRegexp.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- JakartaRegexpRegexp.java 9 Mar 2004 16:48:54 -0000 1.15 +++ JakartaRegexpRegexp.java 17 Dec 2004 19:46:04 -0000 1.16 @@ -27,10 +27,17 @@ public class JakartaRegexpRegexp extends JakartaRegexpMatcher implements Regexp { + /** Constructor for JakartaRegexpRegexp */ public JakartaRegexpRegexp() { 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) { int subsOptions = RE.REPLACE_FIRSTONLY; if (RegexpUtil.hasFlag(options, REPLACE_ALL)) { @@ -39,6 +46,14 @@ 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) throws BuildException { Vector v = getGroups(input, options); 1.19 +34 -2 ant/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java Index: Jdk14RegexpMatcher.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcher.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- Jdk14RegexpMatcher.java 9 Mar 2004 16:48:54 -0000 1.18 +++ Jdk14RegexpMatcher.java 17 Dec 2004 19:46:04 -0000 1.19 @@ -32,11 +32,13 @@ private String pattern; + /** Constructor for JakartaOroRegexp */ public Jdk14RegexpMatcher() { } /** * Set the regexp pattern from the String description. + * @param pattern the pattern to match */ public void setPattern(String pattern) { this.pattern = pattern; @@ -44,11 +46,19 @@ /** * Get a String representation of the regexp pattern + * @return the pattern + * @throws BuildException on error */ public String getPattern() { 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) throws BuildException { int cOptions = getCompilerOptions(options); @@ -61,7 +71,10 @@ } /** - * 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 { return matches(argument, MATCH_DEFAULT); @@ -69,6 +82,10 @@ /** * 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) throws BuildException { @@ -81,10 +98,15 @@ } /** - * 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 * 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 { return getGroups(argument, MATCH_DEFAULT); @@ -95,6 +117,11 @@ * * <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) throws BuildException { @@ -116,6 +143,11 @@ 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) { // be strict about line separator int cOptions = Pattern.UNIX_LINES; 1.19 +15 -0 ant/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexp.java Index: Jdk14RegexpRegexp.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexp.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- Jdk14RegexpRegexp.java 9 Mar 2004 16:48:54 -0000 1.18 +++ Jdk14RegexpRegexp.java 17 Dec 2004 19:46:04 -0000 1.19 @@ -27,10 +27,17 @@ */ public class Jdk14RegexpRegexp extends Jdk14RegexpMatcher implements Regexp { + /** Constructor for Jdk14RegexpRegexp */ public Jdk14RegexpRegexp() { 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) { int subsOptions = REPLACE_FIRST; if (RegexpUtil.hasFlag(options, REPLACE_ALL)) { @@ -39,6 +46,14 @@ 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) throws BuildException { // translate \1 to $(1) so that the Matcher will work 1.12 +2 -0 ant/src/main/org/apache/tools/ant/util/regexp/Regexp.java Index: Regexp.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/regexp/Regexp.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- Regexp.java 9 Mar 2004 16:48:54 -0000 1.11 +++ Regexp.java 17 Dec 2004 19:46:04 -0000 1.12 @@ -41,6 +41,8 @@ * @param argument The string which defines the substitution * @param options The list of options for the match and replace. See the * MATCH_ and REPLACE_ constants above. + * @return the result of the operation + * @throws BuildException on error */ String substitute(String input, String argument, int options) throws BuildException; 1.16 +7 -1 ant/src/main/org/apache/tools/ant/util/regexp/RegexpFactory.java Index: RegexpFactory.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/regexp/RegexpFactory.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- RegexpFactory.java 9 Mar 2004 16:48:54 -0000 1.15 +++ RegexpFactory.java 17 Dec 2004 19:46:04 -0000 1.16 @@ -27,11 +27,15 @@ * @version $Revision$ */ public class RegexpFactory extends RegexpMatcherFactory { + + /** Constructor for RegexpFactory */ public RegexpFactory() { } /*** * Create a new regular expression matcher instance. + * @return the matcher instance + * @throws BuildException on error */ public Regexp newRegexp() throws BuildException { return (Regexp) newRegexp(null); @@ -41,6 +45,8 @@ * Create a new regular expression matcher instance. * * @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 { String systemDefault = null; 1.16 +17 -1 ant/src/main/org/apache/tools/ant/util/regexp/RegexpMatcher.java Index: RegexpMatcher.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/regexp/RegexpMatcher.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- RegexpMatcher.java 9 Mar 2004 16:48:54 -0000 1.15 +++ RegexpMatcher.java 17 Dec 2004 19:46:04 -0000 1.16 @@ -50,24 +50,36 @@ /** * Set the regexp pattern from the String description. + * @param pattern the pattern to match + * @throws BuildException on error */ void setPattern(String pattern) throws BuildException; /** * Get a String representation of the regexp pattern + * @return the pattern + * @throws BuildException on error */ String getPattern() throws BuildException; /** * 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; /** - * 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 * 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; @@ -77,6 +89,8 @@ * @param input The string to check for a match * @param options The list of options for the match. See the * MATCH_ constants above. + * @return true if the pattern matches + * @throws BuildException on error */ boolean matches(String input, int options) throws BuildException; @@ -86,6 +100,8 @@ * @param input The string to check for a match * @param options The list of options for the match. See the * MATCH_ constants above. + * @return the vector of groups + * @throws BuildException on error */ Vector getGroups(String input, int options) throws BuildException; 1.17 +18 -0 ant/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java Index: RegexpMatcherFactory.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/regexp/RegexpMatcherFactory.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- RegexpMatcherFactory.java 9 Mar 2004 16:48:54 -0000 1.16 +++ RegexpMatcherFactory.java 17 Dec 2004 19:46:04 -0000 1.17 @@ -32,11 +32,14 @@ */ public class RegexpMatcherFactory { + /** Constructor for RegexpMatcherFactory. */ public RegexpMatcherFactory() { } /*** * Create a new regular expression instance. + * @return the matcher + * @throws BuildException on error */ public RegexpMatcher newRegexpMatcher() throws BuildException { return newRegexpMatcher(null); @@ -46,6 +49,8 @@ * Create a new regular expression instance. * * @param p Project whose ant.regexp.regexpimpl property will be used. + * @return the matcher + * @throws BuildException on error */ public RegexpMatcher newRegexpMatcher(Project p) throws BuildException { @@ -86,6 +91,13 @@ 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) throws BuildException { try { @@ -96,6 +108,12 @@ } } + /** + * 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 { try { Class.forName(className); 1.12 +18 -4 ant/src/main/org/apache/tools/ant/util/regexp/RegexpUtil.java Index: RegexpUtil.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/util/regexp/RegexpUtil.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- RegexpUtil.java 22 Apr 2004 12:41:10 -0000 1.11 +++ RegexpUtil.java 17 Dec 2004 19:46:04 -0000 1.12 @@ -17,18 +17,32 @@ 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() { } - 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); } - 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)); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]