FileDocCategorySizeDatePackage
ClassfileSet.javaAPI DocApache Ant 1.705111Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.types.optional.depend

ClassfileSet

public class ClassfileSet extends org.apache.tools.ant.types.FileSet
A ClassfileSet is a FileSet that enlists all classes that depend on a certain set of root classes. ClassfileSet extends FileSet, its inherited properties defining the domain searched for dependent classes.

Fields Summary
private Vector
rootClasses
The list of root classes for this class file set. These are the classes which must be included in the fileset and which are the starting point for the dependency search.
private Vector
rootFileSets
The list of filesets which contain root classes.
Constructors Summary
public ClassfileSet()
Default constructor.

    
protected ClassfileSet(ClassfileSet s)
Create a ClassfileSet from another ClassfileSet.

param
s the other classfileset.

        super(s);
        rootClasses = (Vector) s.rootClasses.clone();
    
Methods Summary
public voidaddConfiguredRoot(org.apache.tools.ant.types.optional.depend.ClassfileSet$ClassRoot root)
Add a nested root class definition to this class file set.

param
root the configured class root.

        rootClasses.addElement(root.getClassname());
    
public voidaddRootFileset(org.apache.tools.ant.types.FileSet rootFileSet)
Add a fileset to which contains a collection of root classes used to drive the search from classes.

param
rootFileSet a root file set to be used to search for dependent classes.

        rootFileSets.addElement(rootFileSet);
    
public java.lang.Objectclone()
Clone this data type.

return
a clone of the class file set.

        return new ClassfileSet(isReference()
            ? (ClassfileSet) (getRef(getProject())) : this);
    
public org.apache.tools.ant.DirectoryScannergetDirectoryScanner(org.apache.tools.ant.Project p)
Return the DirectoryScanner associated with this FileSet.

param
p the project used to resolve dirs, etc.
return
a dependency scanner.

        if (isReference()) {
            return getRef(p).getDirectoryScanner(p);
        }
        Vector allRootClasses = (Vector) rootClasses.clone();
        for (Enumeration e = rootFileSets.elements(); e.hasMoreElements();) {
            FileSet additionalRootSet = (FileSet) e.nextElement();
            DirectoryScanner additionalScanner
                = additionalRootSet.getDirectoryScanner(p);
            String[] files = additionalScanner.getIncludedFiles();
            for (int i = 0; i < files.length; ++i) {
                if (files[i].endsWith(".class")) {
                    String classFilePath
                        = files[i].substring(0, files[i].length() - 6);
                    String className
                        = classFilePath.replace('/", '.").replace('\\", '.");
                    allRootClasses.addElement(className);
                }
            }
        }
        DirectoryScanner parentScanner = super.getDirectoryScanner(p);
        DependScanner scanner = new DependScanner(parentScanner);
        scanner.setBasedir(getDir(p));
        scanner.setRootClasses(allRootClasses);
        scanner.scan();
        return scanner;
    
public voidsetRootClass(java.lang.String rootClass)
Set the root class attribute.

param
rootClass the name of the root class.

        rootClasses.addElement(rootClass);