FileDocCategorySizeDatePackage
FileList.javaAPI DocApache Ant 1.706348Wed Dec 13 06:16:18 GMT 2006org.apache.tools.ant.types

FileList

public class FileList extends DataType implements ResourceCollection
FileList represents an explicitly named list of files. FileLists are useful when you want to capture a list of files regardless of whether they currently exist. By contrast, FileSet operates as a filter, only returning the name of a matched file if it currently exists in the file system.

Fields Summary
private Vector
filenames
private File
dir
Constructors Summary
public FileList()
The default constructor.


            
      
        super();
    
protected FileList(FileList filelist)
A copy constructor.

param
filelist a FileList value

        this.dir       = filelist.dir;
        this.filenames = filelist.filenames;
        setProject(filelist.getProject());
    
Methods Summary
public voidaddConfiguredFile(org.apache.tools.ant.types.FileList$FileName name)
Add a nested <file> nested element.

param
name a configured file element with a name.
since
Ant 1.6.2

        if (name.getName() == null) {
            throw new BuildException(
                "No name specified in nested file element");
        }
        filenames.addElement(name.getName());
    
public java.io.FilegetDir(org.apache.tools.ant.Project p)

param
p the current project
return
the directory attribute

        if (isReference()) {
            return getRef(p).getDir(p);
        }
        return dir;
    
public java.lang.String[]getFiles(org.apache.tools.ant.Project p)
Returns the list of files represented by this FileList.

param
p the current project
return
the list of files represented by this FileList.

        if (isReference()) {
            return getRef(p).getFiles(p);
        }

        if (dir == null) {
            throw new BuildException("No directory specified for filelist.");
        }

        if (filenames.size() == 0) {
            throw new BuildException("No files specified for filelist.");
        }

        String[] result = new String[filenames.size()];
        filenames.copyInto(result);
        return result;
    
protected org.apache.tools.ant.types.FileListgetRef(org.apache.tools.ant.Project p)
Performs the check for circular references and returns the referenced FileList.

param
p the current project
return
the FileList represented by a referenced filelist.

        return (FileList) getCheckedRef(p);
    
public booleanisFilesystemOnly()
Always returns true.

return
true indicating that all elements will be FileResources.
since
Ant 1.7

        return true;
    
public java.util.Iteratoriterator()
Fulfill the ResourceCollection contract.

return
an Iterator of Resources.
since
Ant 1.7

        if (isReference()) {
            return ((FileList) getRef(getProject())).iterator();
        }
        return new FileResourceIterator(dir,
            (String[]) (filenames.toArray(new String[filenames.size()])));
    
public voidsetDir(java.io.File dir)
Set the dir attribute.

param
dir the directory this filelist is relative to.
exception
BuildException if an error occurs

        checkAttributesAllowed();
        this.dir = dir;
    
public voidsetFiles(java.lang.String filenames)
Set the filenames attribute.

param
filenames a string contains filenames, separated by , or by whitespace.

        checkAttributesAllowed();
        if (filenames != null && filenames.length() > 0) {
            StringTokenizer tok = new StringTokenizer(
                filenames, ", \t\n\r\f", false);
            while (tok.hasMoreTokens()) {
               this.filenames.addElement(tok.nextToken());
            }
        }
    
public voidsetRefid(Reference r)
Makes this instance in effect a reference to another FileList instance.

You must not set another attribute or nest elements inside this element if you make it a reference.

param
r the reference to another filelist.
exception
BuildException if an error occurs.

        if ((dir != null) || (filenames.size() != 0)) {
            throw tooManyAttributes();
        }
        super.setRefid(r);
    
public intsize()
Fulfill the ResourceCollection contract.

return
number of elements as int.
since
Ant 1.7

        if (isReference()) {
            return ((FileList) getRef(getProject())).size();
        }
        return filenames.size();