KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > antmod > tasks > GsubTask


1 package org.antmod.tasks;
2
3 import org.apache.commons.lang.StringUtils;
4 import org.apache.tools.ant.BuildException;
5 import org.apache.tools.ant.Task;
6
7 /**
8  * Easy string replacements.
9  *
10  * @author Klaas Waslander
11  */

12 public class GsubTask extends Task {
13     
14     private String JavaDoc oldString;
15     private String JavaDoc newString;
16     private String JavaDoc text;
17     private String JavaDoc property;
18
19
20     public GsubTask() {
21     }
22
23     public void execute() throws BuildException {
24         //String result = StringUtil.gsub(this.oldString, this.newString, this.text);
25
String JavaDoc result = StringUtils.replace(this.text, this.oldString, this.newString);
26         getProject().setProperty(this.property, result);
27     }
28
29     /**
30      * @param string
31      */

32     public void setNewString(String JavaDoc string) {
33         newString = string;
34     }
35
36     /**
37      * @param string
38      */

39     public void setOldString(String JavaDoc string) {
40         oldString = string;
41     }
42
43     /**
44      * @param string
45      */

46     public void setProperty(String JavaDoc string) {
47         property = string;
48     }
49
50     /**
51      * @param string
52      */

53     public void setText(String JavaDoc string) {
54         text = string;
55     }
56
57 }
58
Popular Tags