Count resources from a ResourceCollection, storing to a property or
writing to the log. Can also be used as a Condition.
| Method from org.apache.tools.ant.taskdefs.ResourceCount Detail: |
public void add(ResourceCollection r) {
if (rc != null) {
throw new BuildException(ONE_NESTED_MESSAGE);
}
rc = r;
}
Add the ResourceCollection to count. |
public boolean eval() {
if (rc == null) {
throw new BuildException(ONE_NESTED_MESSAGE);
}
if (count == null) {
throw new BuildException(COUNT_REQUIRED);
}
return when.evaluate(new Integer(rc.size()).compareTo(count));
}
Fulfill the condition contract. |
public void execute() {
if (rc == null) {
throw new BuildException(ONE_NESTED_MESSAGE);
}
if (property == null) {
log("resource count = " + rc.size());
} else {
getProject().setNewProperty(property, Integer.toString(rc.size()));
}
}
|
public void setCount(int c) {
count = new Integer(c);
}
Set the target count number for use as a Condition. |
public void setProperty(String p) {
property = p;
}
Set the name of the property to set in task mode. |
public void setRefid(Reference r) {
Object o = r.getReferencedObject();
if (!(o instanceof ResourceCollection)) {
throw new BuildException(r.getRefId()
+ " doesn\'t denote a ResourceCollection");
}
add((ResourceCollection) o);
}
Set the ResourceCollection reference. |
public void setWhen(Comparison c) {
when = c;
}
Set the comparison for use as a Condition. |