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

Sort

public class Sort extends BaseResourceCollectionWrapper
ResourceCollection that sorts another ResourceCollection.
since
Ant 1.7

Fields Summary
private org.apache.tools.ant.types.resources.comparators.DelegatedResourceComparator
comp
Constructors Summary
Methods Summary
public synchronized voidadd(org.apache.tools.ant.types.resources.comparators.ResourceComparator c)
Add a ResourceComparator to this Sort ResourceCollection. If multiple ResourceComparators are added, they will be processed in LIFO order.

param
c the ResourceComparator to add.

        if (isReference()) {
            throw noChildrenAllowed();
        }
        comp.add(c);
        FailFast.invalidate(this);
    
protected synchronized voiddieOnCircularReference(java.util.Stack stk, org.apache.tools.ant.Project p)
Overrides the BaseResourceCollectionContainer version to recurse on nested ResourceComparators.

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 {
            DataType.invokeCircularReferenceCheck(comp, stk, p);
            setChecked(true);
        }
    
protected synchronized java.util.CollectiongetCollection()
Sort the contained elements.

return
a Collection of Resources.


                  
        
        ResourceCollection rc = getResourceCollection();
        Iterator iter = rc.iterator();
        if (!(iter.hasNext())) {
            return Collections.EMPTY_SET;
        }
        SortedBag b = new SortedBag(comp);
        while (iter.hasNext()) {
            b.add(iter.next());
        }
        return b;