1 | package ise.antelope.tasks;
|
---|
2 |
|
---|
3 | import ise.antelope.tasks.typedefs.string.*;
|
---|
4 |
|
---|
5 | import java.util.*;
|
---|
6 | import org.apache.tools.ant.BuildException;
|
---|
7 |
|
---|
8 | import org.apache.tools.ant.Task;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * Copyright 2003
|
---|
12 | *
|
---|
13 | * @version $Revision: 1.2 $
|
---|
14 | */
|
---|
15 | public class StringUtilTask extends Task {
|
---|
16 |
|
---|
17 | private String string = null;
|
---|
18 |
|
---|
19 | private String property = null;
|
---|
20 |
|
---|
21 | private Vector ops = new Vector();
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * Sets the string attribute of the StringUtilTask object
|
---|
25 | *
|
---|
26 | * @param string The new string value
|
---|
27 | */
|
---|
28 | public void setString(String string) {
|
---|
29 | this.string = string;
|
---|
30 | }
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Sets the property attribute of the StringUtilTask object
|
---|
34 | *
|
---|
35 | * @param name The new property value
|
---|
36 | */
|
---|
37 | public void setProperty(String name) {
|
---|
38 | property = name;
|
---|
39 | }
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Adds a feature to the StringOp attribute of the StringUtilTask object
|
---|
43 | *
|
---|
44 | * @param op The feature to be added to the StringOp attribute
|
---|
45 | */
|
---|
46 | public void addStringOp(StringOp op) {
|
---|
47 | ops.add(op);
|
---|
48 | }
|
---|
49 |
|
---|
50 | public void addLowercase(LowerCase op) {
|
---|
51 | ops.add(op);
|
---|
52 | }
|
---|
53 |
|
---|
54 | public void addUppercase(UpperCase op) {
|
---|
55 | ops.add(op);
|
---|
56 | }
|
---|
57 |
|
---|
58 | public void addTrim(Trim op) {
|
---|
59 | ops.add(op);
|
---|
60 | }
|
---|
61 |
|
---|
62 | public void addSubstring(Substring op) {
|
---|
63 | ops.add(op);
|
---|
64 | }
|
---|
65 |
|
---|
66 | public void addReplace(Replace op) {
|
---|
67 | ops.add(op);
|
---|
68 | }
|
---|
69 |
|
---|
70 | public void addIndexOf(IndexOf op) {
|
---|
71 | ops.add(op);
|
---|
72 | }
|
---|
73 |
|
---|
74 | public void addLastIndexOf(LastIndexOf op) {
|
---|
75 | ops.add(op);
|
---|
76 | }
|
---|
77 |
|
---|
78 | public void addLength(Length op) {
|
---|
79 | ops.add(op);
|
---|
80 | }
|
---|
81 |
|
---|
82 | public void addSort(Sort op) {
|
---|
83 | ops.add(op);
|
---|
84 | }
|
---|
85 |
|
---|
86 | public void addMessagebox(MessageBox op) {
|
---|
87 | ops.add(op);
|
---|
88 | }
|
---|
89 |
|
---|
90 |
|
---|
91 | /** Description of the Method */
|
---|
92 | public void execute() {
|
---|
93 | Enumeration en = ops.elements();
|
---|
94 | while (en.hasMoreElements()) {
|
---|
95 | string = ((StringOp) en.nextElement()).execute(string);
|
---|
96 | }
|
---|
97 | if (property != null) {
|
---|
98 | Unset unset = new Unset();
|
---|
99 | unset.setProject(getProject());
|
---|
100 | unset.setName(property);
|
---|
101 | unset.execute();
|
---|
102 | getProject().setProperty(property, string);
|
---|
103 | }
|
---|
104 | }
|
---|
105 |
|
---|
106 | }
|
---|
107 |
|
---|