ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kev Jackson <foamd...@gmail.com>
Subject Non-reflective version of DirectoryScanner refectoring
Date Fri, 25 Aug 2006 01:26:41 GMT
Hi,

After thinking this through this morning on the ride into work, here is
a version of the refactoring (extract method) that doesn't use any
reflection (so should satisfy both Antoine and Matt ;))

Attached patch for testing purposes too.

/**
     * Process included file.
     * @param name  path of the file relative to the directory of the
FileSet.
     * @param file  included File.
     */
    private void accountForIncludedFile(String name, File file) {
    	processIncluded(name, file, filesIncluded, filesExcluded,
filesDeselected);
    }

    /**
     * Process included directory.
     * @param name path of the directory relative to the directory of
     *             the FileSet.
     * @param file directory as File.
     * @param fast whether to perform fast scans.
     */
    private void accountForIncludedDir(String name, File file, boolean
fast) {
    	processIncluded(name, file, dirsIncluded, dirsExcluded,
dirsDeselected);
        if (fast && couldHoldIncluded(name) && !contentsExcluded(name))
{
            scandir(file, name + File.separator, fast);
        }
    }
    
    private void processIncluded(String name, File file, Vector inc,
Vector exc, Vector des) {
        
        if (inc.contains(name) || exc.contains(name) ||
des.contains(name)) { return; }
        
        boolean included = false;
        if (isExcluded(name)) {
            exc.add(name);
        } else if(isSelected(name, file)) {
            included = true;
            inc.add(name);
        } else {
            des.add(name);
        }
        everythingIncluded &= included;
    }

Mime
View raw message