Java 类org.apache.tools.ant.types.AbstractFileSet 实例源码

项目:build-management    文件:CreateConfig.java   
/**
 * Obtain a list of files in the fileset.
 *
 * @return Vector list of file names
 */
private Vector<String> getFilenames(AbstractFileSet fileset) throws IOException {
    Vector<String> files = new Vector<String>();

    DirectoryScanner scanner = fileset.getDirectoryScanner(getProject());
    File basedir = scanner.getBasedir();
    String dirname = basedir.getAbsolutePath();

    // Iterate through each item in the fileset
    String[] filelist = null;
    if (fileset instanceof FileSet) {
        filelist = scanner.getIncludedFiles();
    } else if (fileset instanceof DirSet) {
        filelist = scanner.getIncludedDirectories();
    } else {
        System.out.println("Unable to determine the type of fileset: " + dirname);
        return files;
    }

    for (int idx = 0; idx < filelist.length; idx++) {
        String filename = filelist[idx];

        // Make the file path relative to the fileset directory if necessary 
        if ((filename != null) && (dirname != null) && (dirname.length() > 0)) {
            if (!useAbsolutePath && filename.startsWith(dirname)) {
                // Remove the directory prefix
                filename = filename.substring(dirname.length());
            } else if (useAbsolutePath && !filename.startsWith(dirname)) {
                // Append the directory prefix
                filename = dirname + File.separator + filename;
            }
        }

        // Add the filename to the list
        if (filename != null) {
            //System.out.println(filename);
            files.add(filename);
        }
    }

    return files;
}
项目:ant-contrib    文件:ConditionalFileSet.java   
/**
 * overrides FileSet's implementation which would throw an exception since
 * the referenced object isn't this type.
 */
protected AbstractFileSet getRef(Project p) {
    return (AbstractFileSet) ref.getReferencedObject(p);
}