FileDocCategorySizeDatePackage
Union.javaAPI DocApache Ant 1.703788Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.types.resources

Union

public class Union extends BaseResourceCollectionContainer
ResourceCollection representing the union of multiple nested ResourceCollections.
since
Ant 1.7

Fields Summary
Constructors Summary
public Union()
Default constructor.

    
public Union(org.apache.tools.ant.types.ResourceCollection rc)
Convenience constructor.

param
rc the ResourceCollection to add.

        add(rc);
    
Methods Summary
protected java.util.CollectiongetCollection()
Unify the contained Resources.

return
a Collection of Resources.

        return getCollection(false);
    
protected java.util.CollectiongetCollection(boolean asString)
Unify the contained Resources.

param
asString indicates whether the resulting Collection should contain Strings instead of Resources.
return
a Collection of Resources.

        List rc = getResourceCollections();
        if (rc.isEmpty()) {
            return Collections.EMPTY_LIST;
        }
        //preserve order-encountered using a list; enforce set logic manually:
        ArrayList union = new ArrayList(rc.size() * 2);
        for (Iterator rcIter = rc.iterator(); rcIter.hasNext();) {
            for (Iterator r = nextRC(rcIter).iterator(); r.hasNext();) {
                Object o = r.next();
                if (asString) {
                    o = o.toString();
                }
                if (!(union.contains(o))) {
                    union.add(o);
                }
            }
        }
        return union;
    
public static org.apache.tools.ant.types.resources.UniongetInstance(org.apache.tools.ant.types.ResourceCollection rc)
Static convenience method to union an arbitrary set of Resources.

param
rc a ResourceCollection.
return
a Union.

        return rc instanceof Union ? (Union) rc : new Union(rc);
    
public java.lang.String[]list()
Returns all Resources in String format. Provided for convenience in implementing Path.

return
String array of Resources.

        if (isReference()) {
            return ((Union) getCheckedRef()).list();
        }
        Collection result = getCollection(true);
        return (String[]) (result.toArray(new String[result.size()]));
    
public org.apache.tools.ant.types.Resource[]listResources()
Convenience method.

return
Resource[]

        if (isReference()) {
            return ((Union) getCheckedRef()).listResources();
        }
        Collection result = getCollection();
        return (Resource[]) (result.toArray(new Resource[result.size()]));
    
private static org.apache.tools.ant.types.ResourceCollectionnextRC(java.util.Iterator i)

        return (ResourceCollection) i.next();