FileDocCategorySizeDatePackage
Resources.javaAPI DocApache Ant 1.707120Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.types.resources

Resources

public class Resources extends org.apache.tools.ant.types.DataType implements org.apache.tools.ant.types.ResourceCollection
Generic ResourceCollection: Either stores nested ResourceCollections, making no attempt to remove duplicates, or references another ResourceCollection.
since
Ant 1.7

Fields Summary
public static final org.apache.tools.ant.types.ResourceCollection
NONE
static empty ResourceCollection
public static final Iterator
EMPTY_ITERATOR
static empty Iterator
private Vector
rc
private Collection
coll
Constructors Summary
Methods Summary
public synchronized voidadd(org.apache.tools.ant.types.ResourceCollection c)
Add a ResourceCollection.

param
c the ResourceCollection to add.

        if (isReference()) {
            throw noChildrenAllowed();
        }
        if (c == null) {
            return;
        }
        if (rc == null) {
            rc = new Vector();
        }
        rc.add(c);
        FailFast.invalidate(this);
        coll = null;
        setChecked(false);
    
protected voiddieOnCircularReference(java.util.Stack stk, org.apache.tools.ant.Project p)
Overrides the version of DataType to recurse on all DataType child elements that may have been added.

param
stk the stack of data types to use (recursively).
param
p the project to use to dereference the references.
throws
BuildException on error.

        if (isChecked()) {
            return;
        }
        if (isReference()) {
            super.dieOnCircularReference(stk, p);
        } else {
            for (Iterator i = getNested().iterator(); i.hasNext();) {
                Object o = i.next();
                if (o instanceof DataType) {
                    invokeCircularReferenceCheck((DataType) o, stk, p);
                }
            }
            setChecked(true);
        }
    
private synchronized java.util.ListgetNested()

        return rc == null ? Collections.EMPTY_LIST : rc;
    
private org.apache.tools.ant.types.ResourceCollectiongetRef()
Resolves references, allowing any ResourceCollection.

return
the referenced ResourceCollection.

        return (ResourceCollection) getCheckedRef(
            ResourceCollection.class, "ResourceCollection");
    
public booleanisFilesystemOnly()
Fulfill the ResourceCollection contract.

return
true if all Resources represent files.

        if (isReference()) {
            return getRef().isFilesystemOnly();
        }
        validate();

        for (Iterator i = getNested().iterator(); i.hasNext();) {
            if ((!((ResourceCollection) i.next()).isFilesystemOnly())) {
                return false;
            }
        }
        return true;
    
public synchronized java.util.Iteratoriterator()
Fulfill the ResourceCollection contract.

return
an Iterator of Resources.

        if (isReference()) {
            return getRef().iterator();
        }
        validate();
        return new FailFast(this, coll.iterator());
    
public synchronized intsize()
Fulfill the ResourceCollection contract.

return
number of elements as int.

        if (isReference()) {
            return getRef().size();
        }
        validate();
        return coll.size();
    
public synchronized java.lang.StringtoString()
Format this BaseResourceCollectionContainer as a String.

return
a descriptive String.

        if (isReference()) {
            return getCheckedRef().toString();
        }
        if (coll == null || coll.isEmpty()) {
            return "";
        }
        StringBuffer sb = new StringBuffer();
        for (Iterator i = coll.iterator(); i.hasNext();) {
            if (sb.length() > 0) {
                sb.append(File.pathSeparatorChar);
            }
            sb.append(i.next());
        }
        return sb.toString();
    
private synchronized voidvalidate()

        dieOnCircularReference();
        coll = (coll == null) ? new MyCollection() : coll;