01: /*
02: * Copyright 2001-2007 Hippo (www.hippo.nl)
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package hippo.ant;
17:
18: import org.apache.tools.ant.BuildException;
19: import org.apache.tools.ant.Task;
20:
21: public class PropertyTransformer extends Task {
22:
23: private String m_source;
24:
25: private String m_findExpression;
26:
27: private String m_replacement;
28:
29: private String m_target;
30:
31: public PropertyTransformer() {
32: super ();
33: }
34:
35: public void setSource(String source) {
36: m_source = source;
37: }
38:
39: public void setFindExpression(String findExpression) {
40: m_findExpression = findExpression;
41: }
42:
43: public void setReplacement(String replacement) {
44: m_replacement = replacement;
45: }
46:
47: public void setTarget(String target) {
48: m_target = target;
49: }
50:
51: public void execute() throws BuildException {
52: getProject().setProperty(
53: m_target,
54: getProject().getProperty(m_source).replaceAll(
55: m_findExpression, m_replacement));
56: }
57: }
|