FileDocCategorySizeDatePackage
ResourcesMatch.javaAPI DocApache Ant 1.703195Wed Dec 13 06:16:20 GMT 2006None

ResourcesMatch

public class ResourcesMatch extends Object implements Condition
Compares resources for equality based on size and content. All resources specified must match; no resource collections specified is an error condition; if resource collections are specified, but yield fewer than two elements, the condition evaluates to true.
since
Ant 1.7

Fields Summary
private org.apache.tools.ant.types.resources.Union
resources
private boolean
asText
Constructors Summary
Methods Summary
public voidadd(org.apache.tools.ant.types.ResourceCollection rc)
Add a resource collection.

param
rc the resource collection to add.

        if (rc == null) {
            return;
        }
        resources = resources == null ? new Union() : resources;
        resources.add(rc);
    
public booleaneval()
Verify that all resources match.

return
true if all resources are equal.
exception
BuildException if there is an error.

        if (resources == null) {
            throw new BuildException(
                "You must specify one or more nested resource collections");
        }
        if (resources.size() > 1) {
            Iterator i = resources.iterator();
            Resource r1 = (Resource) i.next();
            Resource r2 = null;

            while (i.hasNext()) {
                r2 = (Resource) i.next();
                try {
                    if (!ResourceUtils.contentEquals(r1, r2, asText)) {
                        return false;
                    }
                } catch (IOException ioe) {
                    throw new BuildException("when comparing resources "
                        + r1.toString() + " and " + r2.toString(), ioe);
                }
                r1 = r2;
            }
        }
        return true;
    
public voidsetAsText(boolean asText)
Set whether to treat resources as if they were text files, ignoring line endings.

param
asText whether to ignore line endings.


                              
        
        this.asText = asText;