1 | private String from;↵ | | 1 | private String from;↵
|
2 | private String to;↵ | | 2 | private String to;↵
|
3 | private RegularExpression regularExpression;↵ | | 3 | private RegularExpression regularExpression;↵
|
4 | private Substitution substitution;↵ | | 4 | private Substitution substitution;↵
|
5 | private boolean initialized = false;↵ | | 5 | private boolean initialized = false;↵
|
6 | private String flags = "";↵ | | 6 | private String flags = "";↵
|
7 | private int options;↵ | | 7 | private int options;↵
|
8 | private Regexp regexp;↵ | | 8 | private Regexp regexp;↵
|
|
|
9 | /**↵ | | 9 | /**↵
|
10 | * the from attribute↵ | | |
|
11 | * @param from the regex string↵ | | 10 | * @param from the regex pattern↵
|
12 | */↵ | | 11 | */↵
|
13 | public void setPattern(String from) {↵ | | 12 | public void setPattern(String from) {↵
|
14 | this.from = from;↵ | | 13 | this.from = from;↵
|
15 | }↵ | | 14 | }↵
|
|
16 | /**↵ | | 15 | /**↵
|
17 | * the to attribute↵ | | |
|
18 | * @param to the replacement string↵ | | 16 | * @param to the replacement string↵
|
19 | */↵ | | 17 | */↵
|
20 | public void setReplace(String to) {↵ | | 18 | public void setReplace(String to) {↵
|
21 | this.to = to;↵ | | 19 | this.to = to;↵
|
22 | }↵ | | 20 | }↵
|
|
23 | /**↵ | | 21 | /**↵
|
24 | * @param flags the regex flags↵ | | 22 | * @param flags the regex flags↵
|
25 | */↵ | | 23 | */↵
|
26 | public void setFlags(String flags) {↵ | | 24 | public void setFlags(String flags) {↵
|
27 | this.flags = flags;↵ | | 25 | this.flags = flags;↵
|
28 | }↵ | | 26 | }↵
|
|
29 | private void initialize() {↵ | | 27 | private void initialize() {↵
|
30 | if (initialized) {↵ | | 28 | if (initialized) {↵
|
31 | return;↵ | | 29 | return;↵
|
32 | }↵ | | 30 | }↵
|
33 | options = convertRegexOptions(flags);↵ | | 31 | options = convertRegexOptions(flags);↵
|
34 | if (from == null) {↵ | | 32 | if (from == null) {↵
|
35 | throw new BuildException("Missing pattern in replaceregex");↵ | | 33 | throw new BuildException("Missing from in containsregex");↵
|
36 | }↵ | | 34 | }↵
|
37 | regularExpression = new RegularExpression();↵ | | 35 | regularExpression = new RegularExpression();↵
|
38 | regularExpression.setPattern(from);↵ | | 36 | regularExpression.setPattern(from);↵
|
39 | regexp = regularExpression.getRegexp(getProject());↵ | | 37 | regexp = regularExpression.getRegexp(getProject());↵
|
40 | if (to == null) {↵ | | 38 | if (to == null) {↵
|
41 | to = "";↵ | | 39 | return;↵
|
42 | }↵ | | 40 | }↵
|
43 | substitution = new Substitution();↵ | | 41 | substitution = new Substitution();↵
|
44 | substitution.setExpression(to) | | 42 | substitution.setExpression(to)
|