1 | package ise.antelope.tasks.condition;
|
---|
2 |
|
---|
3 | import java.util.Enumeration;
|
---|
4 | import java.util.Hashtable;
|
---|
5 | import java.util.Vector;
|
---|
6 |
|
---|
7 | import org.apache.tools.ant.ProjectComponent;
|
---|
8 | import org.apache.tools.ant.Project;
|
---|
9 | import org.apache.tools.ant.BuildException;
|
---|
10 | import org.apache.tools.ant.UnknownElement;
|
---|
11 | import org.apache.tools.ant.taskdefs.Available;
|
---|
12 | import org.apache.tools.ant.taskdefs.Checksum;
|
---|
13 | import org.apache.tools.ant.taskdefs.UpToDate;
|
---|
14 | import org.apache.tools.ant.taskdefs.condition.*;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * Extends ConditionBase so I can get access to the condition count and the
|
---|
18 | * first condition. This is the class that the BooleanConditionTask is proxy
|
---|
19 | * for.
|
---|
20 | *
|
---|
21 | * @author danson
|
---|
22 | */
|
---|
23 | public class BooleanConditionBase extends ProjectComponent {
|
---|
24 |
|
---|
25 | private Vector conditions = new Vector();
|
---|
26 |
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Gets the conditionCount attribute of the BooleanConditionBase object
|
---|
30 | *
|
---|
31 | * @return The conditionCount value
|
---|
32 | */
|
---|
33 | public int getConditionCount() {
|
---|
34 | return countConditions();
|
---|
35 | }
|
---|
36 |
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * Gets the firstCondition attribute of the BooleanConditionBase object
|
---|
40 | *
|
---|
41 | * @return The firstCondition value
|
---|
42 | */
|
---|
43 | public Condition getFirstCondition() {
|
---|
44 | return ( Condition ) getConditions().nextElement();
|
---|
45 | }
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Count the conditions.
|
---|
49 | *
|
---|
50 | * @return the number of conditions in the container
|
---|
51 | * @since 1.1
|
---|
52 | */
|
---|
53 | public int countConditions() {
|
---|
54 | return conditions.size();
|
---|
55 | }
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Iterate through all conditions.
|
---|
59 | *
|
---|
60 | * @return an enumeration to use for iteration
|
---|
61 | * @since 1.1
|
---|
62 | */
|
---|
63 | public final Enumeration getConditions() {
|
---|
64 | return conditions.elements();
|
---|
65 | }
|
---|
66 |
|
---|
67 | public void addAvailable( Available a ) {
|
---|
68 | add( a );
|
---|
69 | }
|
---|
70 |
|
---|
71 | public void addChecksum( Checksum c ) {
|
---|
72 | add( c );
|
---|
73 | }
|
---|
74 |
|
---|
75 | public void addUptodate( UpToDate u ) {
|
---|
76 | add( u );
|
---|
77 | }
|
---|
78 |
|
---|
79 | public void addNot( Not n ) {
|
---|
80 | add( n );
|
---|
81 | }
|
---|
82 |
|
---|
83 | public void addAnd( And a ) {
|
---|
84 | add( a );
|
---|
85 | }
|
---|
86 |
|
---|
87 | public void addOr( Or o ) {
|
---|
88 | add( o );
|
---|
89 | }
|
---|
90 |
|
---|
91 | public void addEquals( Equals e ) {
|
---|
92 | add( e );
|
---|
93 | }
|
---|
94 |
|
---|
95 | public void addOs( Os o ) {
|
---|
96 | add( o );
|
---|
97 | }
|
---|
98 |
|
---|
99 | public void addIsSet( IsSet i ) {
|
---|
100 | add( i );
|
---|
101 | }
|
---|
102 |
|
---|
103 | public void addHttp( Http h ) {
|
---|
104 | add( h );
|
---|
105 | }
|
---|
106 |
|
---|
107 | public void addSocket( Socket s ) {
|
---|
108 | add( s );
|
---|
109 | }
|
---|
110 |
|
---|
111 | public void addFilesMatch( FilesMatch test ) {
|
---|
112 | add( test );
|
---|
113 | }
|
---|
114 |
|
---|
115 | public void addContains( Contains test ) {
|
---|
116 | add( test );
|
---|
117 | }
|
---|
118 |
|
---|
119 | public void addIsTrue( IsTrue test ) {
|
---|
120 | add( test );
|
---|
121 | }
|
---|
122 |
|
---|
123 | public void addIsFalse( IsFalse test ) {
|
---|
124 | add( test );
|
---|
125 | }
|
---|
126 |
|
---|
127 | public void addIsReference( IsReference i ) {
|
---|
128 | add( i );
|
---|
129 | }
|
---|
130 |
|
---|
131 | public void addIsPropertyTrue( IsPropertyTrue i ) {
|
---|
132 | add( i );
|
---|
133 | }
|
---|
134 |
|
---|
135 | public void addIsPropertyFalse( IsPropertyFalse i ) {
|
---|
136 | add( i );
|
---|
137 | }
|
---|
138 |
|
---|
139 | public void addIsGreaterThan( IsGreaterThan i ) {
|
---|
140 | add( i );
|
---|
141 | }
|
---|
142 |
|
---|
143 | public void addIsLessThan( IsLessThan i ) {
|
---|
144 | add( i );
|
---|
145 | }
|
---|
146 |
|
---|
147 | public void addMathEquals( MathEquals i ) {
|
---|
148 | add( i );
|
---|
149 | }
|
---|
150 |
|
---|
151 | public void addStartsWith( StartsWith i ) {
|
---|
152 | add( i );
|
---|
153 | }
|
---|
154 |
|
---|
155 | public void addEndsWith( EndsWith i ) {
|
---|
156 | add( i );
|
---|
157 | }
|
---|
158 |
|
---|
159 | public void addDateDifference(DateTimeDifference i) {
|
---|
160 | add(i);
|
---|
161 | }
|
---|
162 |
|
---|
163 | public void addTimeDifference(DateTimeDifference i) {
|
---|
164 | add(i);
|
---|
165 | }
|
---|
166 |
|
---|
167 | public void addDateBefore(DateTimeBefore i) {
|
---|
168 | add(i);
|
---|
169 | }
|
---|
170 |
|
---|
171 | public void addTimeBefore(DateTimeBefore i) {
|
---|
172 | add(i);
|
---|
173 | }
|
---|
174 |
|
---|
175 | /**
|
---|
176 | * Add an arbitrary condition -- this doesn't work, it is copied from
|
---|
177 | * ConditionBase in Ant, and it doesn't work there either.
|
---|
178 | * @param c a condition
|
---|
179 | * @since Ant 1.6
|
---|
180 | */
|
---|
181 | public void add( Condition c ) {
|
---|
182 | conditions.addElement( c );
|
---|
183 | }
|
---|
184 |
|
---|
185 | }
|
---|
186 |
|
---|