Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 66519 invoked from network); 19 Dec 2003 16:53:01 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 19 Dec 2003 16:53:01 -0000 Received: (qmail 73566 invoked by uid 500); 19 Dec 2003 16:52:51 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 73530 invoked by uid 500); 19 Dec 2003 16:52:51 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 73510 invoked by uid 500); 19 Dec 2003 16:52:51 -0000 Received: (qmail 73501 invoked from network); 19 Dec 2003 16:52:51 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 19 Dec 2003 16:52:51 -0000 Received: (qmail 66481 invoked by uid 1539); 19 Dec 2003 16:52:57 -0000 Date: 19 Dec 2003 16:52:57 -0000 Message-ID: <20031219165257.66480.qmail@minotaur.apache.org> From: peterreilly@apache.org To: ant-cvs@apache.org Subject: cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional ReplaceRegExp.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N peterreilly 2003/12/19 08:52:57 Modified: src/main/org/apache/tools/ant/taskdefs/optional ReplaceRegExp.java Log: stylecheck changes Revision Changes Path 1.32 +30 -4 ant/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java Index: ReplaceRegExp.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- ReplaceRegExp.java 19 Dec 2003 15:13:02 -0000 1.31 +++ ReplaceRegExp.java 19 Dec 2003 16:52:57 -0000 1.32 @@ -181,6 +181,7 @@ /** * file for which the regular expression should be replaced; * required unless a nested fileset is supplied. + * @param file The file for which the reg exp should be replaced. */ public void setFile(File file) { this.file = file; @@ -190,6 +191,7 @@ /** * the regular expression pattern to match in the file(s); * required if no nested <regexp> is used + * @param match the match attribute. */ public void setMatch(String match) { if (regex != null) { @@ -205,6 +207,7 @@ * The substitution pattern to place in the file(s) in place * of the regular expression. * Required if no nested <substitution> is used + * @param replace the replace attribute */ public void setReplace(String replace) { @@ -230,6 +233,7 @@ * "." to match any character, including a newline, which normally, * it would not match. * + * @param flags the flags attribute */ public void setFlags(String flags) { this.flags = flags; @@ -242,6 +246,7 @@ * want to only replace the first occurrence of a regular expression on * each line, which is not easy to do when processing the file as a whole. * Defaults to false. + * @param byline the byline attribute as a string * @deprecated - use setByLine(boolean) */ public void setByLine(String byline) { @@ -259,6 +264,7 @@ * want to only replace the first occurrence of a regular expression on * each line, which is not easy to do when processing the file as a whole. * Defaults to false. + * @param byline the byline attribute */ public void setByLine(boolean byline) { this.byline = byline; @@ -268,6 +274,7 @@ /** * Specifies the encoding Ant expects the files to be in - * defaults to the platforms default encoding. + * @param encoding the encoding attribute * * @since Ant 1.6 */ @@ -277,6 +284,7 @@ /** * list files to apply the replacement to + * @param set the fileset element */ public void addFileset(FileSet set) { filesets.addElement(set); @@ -287,6 +295,7 @@ * A regular expression. * You can use this element to refer to a previously * defined regular expression datatype instance + * @return the regular expression object to be configured as an element */ public RegularExpression createRegexp() { if (regex != null) { @@ -301,6 +310,7 @@ /** * A substitution pattern. You can use this element to refer to a previously * defined substitution pattern datatype instance. + * @return the substitution pattern object to be configured as an element */ public Substitution createSubstitution() { if (subs != null) { @@ -313,6 +323,16 @@ } + /** + * Invoke a regular expression (r) on a string (input) using + * substitutions (s) for a matching regex. + * + * @param r a regular expression + * @param s a Substitution + * @param input the string to do the replacement on + * @param options The options for the regular expression + * @return the replacement result + */ protected String doReplace(RegularExpression r, Substitution s, String input, @@ -321,7 +341,7 @@ Regexp regexp = r.getRegexp(getProject()); if (regexp.matches(input, options)) { - log("Found match; substituting",Project.MSG_DEBUG); + log("Found match; substituting", Project.MSG_DEBUG); res = regexp.substitute(input, s.getExpression(getProject()), options); } @@ -330,7 +350,13 @@ } - /** Perform the replace on the entire file */ + /** + * Perform the replacement on a file + * + * @param f the file to perform the relacement on + * @param options the regular expressions options + * @exception IOException if an error occurs + */ protected void doReplace(File f, int options) throws IOException { File temp = fileUtils.createTempFile("replace", ".txt", null); @@ -455,7 +481,7 @@ w = null; if (changes) { - log("File has changed; saving the updated file",Project.MSG_VERBOSE); + log("File has changed; saving the updated file", Project.MSG_VERBOSE); try { fileUtils.rename(temp, f); temp = null; @@ -464,7 +490,7 @@ + temp, getLocation()); } } else { - log("No change made",Project.MSG_DEBUG); + log("No change made", Project.MSG_DEBUG); } } finally { try { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org