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

DelegatedResourceComparator

public class DelegatedResourceComparator extends ResourceComparator
Delegates to other ResourceComparators or, if none specified, uses Resources' natural ordering.
since
Ant 1.7

Fields Summary
private Vector
v
Constructors Summary
Methods Summary
public synchronized voidadd(ResourceComparator c)
Add a delegate ResourceComparator.

param
c the next delegate ResourceComparator.


                   
         
        if (isReference()) {
            throw noChildrenAllowed();
        }
        if (c == null) {
            return;
        }
        v = (v == null) ? new Vector() : v;
        v.add(c);
    
protected voiddieOnCircularReference(java.util.Stack stk, org.apache.tools.ant.Project p)
Overrides the version from DataType to recurse on nested ResourceSelector s.

param
stk the Stack of references.
param
p the Project to resolve against.
throws
BuildException on error.

        if (isChecked()) {
            return;
        }
        if (isReference()) {
            super.dieOnCircularReference(stk, p);
        } else {
            if (!(v == null || v.isEmpty())) {
                for (Iterator i = v.iterator(); i.hasNext();) {
                    Object o = i.next();
                    if (o instanceof DataType) {
                        stk.push(o);
                        invokeCircularReferenceCheck((DataType) o, stk, p);
                    }
                }
            }
            setChecked(true);
        }
    
public synchronized booleanequals(java.lang.Object o)
Equality method based on the vector of resources, or if a reference, the referredto object.

param
o the object to check against.
return
true if there is equality.

        if (o == this) {
            return true;
        }
        if (isReference()) {
            return getCheckedRef().equals(o);
        }
        if (!(o instanceof DelegatedResourceComparator)) {
            return false;
        }
        Vector ov = ((DelegatedResourceComparator) o).v;
        return v == null ? ov == null : v.equals(ov);
    
public synchronized inthashCode()
Hashcode based on the rules for equality.

return
a hashcode.

        if (isReference()) {
            return getCheckedRef().hashCode();
        }
        return v == null ? 0 : v.hashCode();
    
protected synchronized intresourceCompare(org.apache.tools.ant.types.Resource foo, org.apache.tools.ant.types.Resource bar)
{@inheritDoc}

        //if no nested, natural order:
        if (v == null || v.isEmpty()) {
            return foo.compareTo(bar);
        }
        int result = 0;
        for (Iterator i = v.iterator(); result == 0 && i.hasNext();) {
            result = ((ResourceComparator) i.next()).resourceCompare(foo, bar);
        }
        return result;