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.
| Method from org.apache.tools.ant.types.FileList Detail: |
public void addConfiguredFile(FileList.FileName name) {
if (name.getName() == null) {
throw new BuildException(
"No name specified in nested file element");
}
filenames.addElement(name.getName());
}
Add a nested <file> nested element. |
public File getDir(Project p) {
if (isReference()) {
return getRef(p).getDir(p);
}
return dir;
}
|
public String[] getFiles(Project p) {
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;
}
Returns the list of files represented by this FileList. |
protected FileList getRef(Project p) {
return (FileList) getCheckedRef(p);
}
Performs the check for circular references and returns the
referenced FileList. |
public boolean isFilesystemOnly() {
return true;
}
|
public Iterator iterator() {
if (isReference()) {
return ((FileList) getRef(getProject())).iterator();
}
return new FileResourceIterator(dir,
(String[]) (filenames.toArray(new String[filenames.size()])));
}
Fulfill the ResourceCollection contract. |
public void setDir(File dir) throws BuildException {
checkAttributesAllowed();
this.dir = dir;
}
|
public void setFiles(String filenames) {
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());
}
}
}
Set the filenames attribute. |
public void setRefid(Reference r) throws BuildException {
if ((dir != null) || (filenames.size() != 0)) {
throw tooManyAttributes();
}
super.setRefid(r);
}
|
public int size() {
if (isReference()) {
return ((FileList) getRef(getProject())).size();
}
return filenames.size();
}
Fulfill the ResourceCollection contract. |