summaryrefslogtreecommitdiff
path: root/src/main/org/apache/tools/ant/types/resources/Resources.java
diff options
context:
space:
mode:
authorMatthew Jason Benson <mbenson@apache.org>2005-11-23 18:16:24 +0000
committerMatthew Jason Benson <mbenson@apache.org>2005-11-23 18:16:24 +0000
commitac067a950849bfb82b9f8efd45231946d1020a37 (patch)
tree4db44f61ef6d4babab106a1af9e64376247fc684 /src/main/org/apache/tools/ant/types/resources/Resources.java
parentdb060df3c3ec41339c5fcbf8c177ec9f01299cae (diff)
downloadant-ac067a950849bfb82b9f8efd45231946d1020a37.tar.gz
allow empty <resources> after all.
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@348510 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/main/org/apache/tools/ant/types/resources/Resources.java')
-rwxr-xr-xsrc/main/org/apache/tools/ant/types/resources/Resources.java31
1 files changed, 12 insertions, 19 deletions
diff --git a/src/main/org/apache/tools/ant/types/resources/Resources.java b/src/main/org/apache/tools/ant/types/resources/Resources.java
index 1d6a3b0cf..c0f4bbcb8 100755
--- a/src/main/org/apache/tools/ant/types/resources/Resources.java
+++ b/src/main/org/apache/tools/ant/types/resources/Resources.java
@@ -77,11 +77,14 @@ public class Resources extends DataType implements ResourceCollection {
private class MyIterator implements Iterator {
Iterator rci = rc.iterator();
Iterator ri = null;
+
public boolean hasNext() {
- if ((ri == null || !ri.hasNext()) && rci.hasNext()) {
+ boolean result = ri != null && ri.hasNext();
+ while (!result && rci.hasNext()) {
ri = ((ResourceCollection) rci.next()).iterator();
+ result = ri.hasNext();
}
- return ri != null && ri.hasNext();
+ return result;
}
public Object next() {
if (!hasNext()) {
@@ -95,7 +98,7 @@ public class Resources extends DataType implements ResourceCollection {
}
}
- private Vector rc = null;
+ private Vector rc = new Vector();
private Collection coll = null;
/**
@@ -106,7 +109,9 @@ public class Resources extends DataType implements ResourceCollection {
if (isReference()) {
throw noChildrenAllowed();
}
- rc = (rc == null) ? new Vector() : rc;
+ if (c == null) {
+ return;
+ }
rc.add(c);
FailFast.invalidate(this);
coll = null;
@@ -146,18 +151,9 @@ public class Resources extends DataType implements ResourceCollection {
return getRef().isFilesystemOnly();
}
validate();
- //first the easy way, if all children are filesystem-only, return true:
- boolean goEarly = true;
- for (Iterator i = rc.iterator(); goEarly && i.hasNext();) {
- goEarly &= ((ResourceCollection) i.next()).isFilesystemOnly();
- }
- if (goEarly) {
- return true;
- }
- /* now check each Resource in case the child only
- lets through files from any children IT may have: */
- for (Iterator i = coll.iterator(); i.hasNext();) {
- if (!(i.next() instanceof FileResource)) {
+
+ for (Iterator i = rc.iterator(); i.hasNext();) {
+ if ((!((ResourceCollection) i.next()).isFilesystemOnly())) {
return false;
}
}
@@ -200,9 +196,6 @@ public class Resources extends DataType implements ResourceCollection {
private synchronized void validate() {
dieOnCircularReference();
- if (rc == null || rc.size() == 0) {
- throw new BuildException("Resources: no resources specified.");
- }
coll = (coll == null) ? new MyCollection() : coll;
}