1 18 19 package org.apache.tools.ant.taskdefs.condition; 20 21 import java.util.Enumeration ; 22 import java.util.Vector ; 23 import org.apache.tools.ant.Project; 24 import org.apache.tools.ant.DynamicElement; 25 import org.apache.tools.ant.ComponentHelper; 26 import org.apache.tools.ant.ProjectComponent; 27 import org.apache.tools.ant.taskdefs.Available; 28 import org.apache.tools.ant.taskdefs.Checksum; 29 import org.apache.tools.ant.taskdefs.UpToDate; 30 31 38 public abstract class ConditionBase extends ProjectComponent 39 implements DynamicElement { 40 41 private static final String CONDITION_ANTLIB 42 = "antlib:org.apache.tools.ant.types.conditions:"; 43 44 47 private String taskName = "condition"; 48 49 52 private Vector conditions = new Vector (); 53 54 57 protected ConditionBase() { 58 taskName = "component"; 59 } 60 61 66 protected ConditionBase(String taskName) { 67 this.taskName = taskName; 68 } 69 70 76 protected int countConditions() { 77 return conditions.size(); 78 } 79 80 86 protected final Enumeration getConditions() { 87 return conditions.elements(); 88 } 89 90 97 public void setTaskName(String name) { 98 this.taskName = name; 99 } 100 101 107 public String getTaskName() { 108 return taskName; 109 } 110 111 116 public void addAvailable(Available a) { 117 conditions.addElement(a); 118 } 119 120 126 public void addChecksum(Checksum c) { 127 conditions.addElement(c); 128 } 129 130 136 public void addUptodate(UpToDate u) { 137 conditions.addElement(u); 138 } 139 140 146 public void addNot(Not n) { 147 conditions.addElement(n); 148 } 149 150 156 public void addAnd(And a) { 157 conditions.addElement(a); 158 } 159 160 166 public void addOr(Or o) { 167 conditions.addElement(o); 168 } 169 170 176 public void addEquals(Equals e) { 177 conditions.addElement(e); 178 } 179 180 186 public void addOs(Os o) { 187 conditions.addElement(o); 188 } 189 190 196 public void addIsSet(IsSet i) { 197 conditions.addElement(i); 198 } 199 200 206 public void addHttp(Http h) { 207 conditions.addElement(h); 208 } 209 210 216 public void addSocket(Socket s) { 217 conditions.addElement(s); 218 } 219 220 226 public void addFilesMatch(FilesMatch test) { 227 conditions.addElement(test); 228 } 229 230 236 public void addContains(Contains test) { 237 conditions.addElement(test); 238 } 239 240 246 public void addIsTrue(IsTrue test) { 247 conditions.addElement(test); 248 } 249 250 256 public void addIsFalse(IsFalse test) { 257 conditions.addElement(test); 258 } 259 260 266 public void addIsReference(IsReference i) { 267 conditions.addElement(i); 268 } 269 270 274 public void addIsFileSelected(IsFileSelected test) { 275 conditions.addElement(test); 276 } 277 278 283 public void add(Condition c) { 284 conditions.addElement(c); 285 } 286 287 294 public Object createDynamicElement(String name) { 295 Object cond = ComponentHelper.getComponentHelper(getProject()) 296 .createComponent(CONDITION_ANTLIB + name); 297 if (!(cond instanceof Condition)) { 298 return null; 299 } 300 log("Dynamically discovered '" + name + "' " + cond, 301 Project.MSG_DEBUG); 302 add((Condition) cond); 303 return cond; 304 } 305 306 } 307 | Popular Tags |