|
@@ -30,19 +30,25 @@ import org.apache.tools.ant.Project; |
|
|
* whether they currently exist. By contrast, FileSet operates as a |
|
|
* whether they currently exist. By contrast, FileSet operates as a |
|
|
* filter, only returning the name of a matched file if it currently |
|
|
* filter, only returning the name of a matched file if it currently |
|
|
* exists in the file system. |
|
|
* exists in the file system. |
|
|
* |
|
|
|
|
|
* @author <a href="mailto:cstrong@arielpartners.com">Craeg Strong</a> |
|
|
|
|
|
* @version $Revision$ $Date$ |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
public class FileList extends DataType { |
|
|
public class FileList extends DataType { |
|
|
|
|
|
|
|
|
private Vector filenames = new Vector(); |
|
|
private Vector filenames = new Vector(); |
|
|
private File dir; |
|
|
private File dir; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* The default constructor. |
|
|
|
|
|
* |
|
|
|
|
|
*/ |
|
|
public FileList() { |
|
|
public FileList() { |
|
|
super(); |
|
|
super(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* A copy constructor. |
|
|
|
|
|
* |
|
|
|
|
|
* @param filelist a <code>FileList</code> value |
|
|
|
|
|
*/ |
|
|
protected FileList(FileList filelist) { |
|
|
protected FileList(FileList filelist) { |
|
|
this.dir = filelist.dir; |
|
|
this.dir = filelist.dir; |
|
|
this.filenames = filelist.filenames; |
|
|
this.filenames = filelist.filenames; |
|
@@ -55,6 +61,8 @@ public class FileList extends DataType { |
|
|
* |
|
|
* |
|
|
* <p>You must not set another attribute or nest elements inside |
|
|
* <p>You must not set another attribute or nest elements inside |
|
|
* this element if you make it a reference.</p> |
|
|
* this element if you make it a reference.</p> |
|
|
|
|
|
* @param r the reference to another filelist. |
|
|
|
|
|
* @exception BuildException if an error occurs. |
|
|
*/ |
|
|
*/ |
|
|
public void setRefid(Reference r) throws BuildException { |
|
|
public void setRefid(Reference r) throws BuildException { |
|
|
if ((dir != null) || (filenames.size() != 0)) { |
|
|
if ((dir != null) || (filenames.size() != 0)) { |
|
@@ -63,6 +71,12 @@ public class FileList extends DataType { |
|
|
super.setRefid(r); |
|
|
super.setRefid(r); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Set the dir attribute. |
|
|
|
|
|
* |
|
|
|
|
|
* @param dir the directory this filelist is relative to. |
|
|
|
|
|
* @exception BuildException if an error occurs |
|
|
|
|
|
*/ |
|
|
public void setDir(File dir) throws BuildException { |
|
|
public void setDir(File dir) throws BuildException { |
|
|
if (isReference()) { |
|
|
if (isReference()) { |
|
|
throw tooManyAttributes(); |
|
|
throw tooManyAttributes(); |
|
@@ -70,6 +84,10 @@ public class FileList extends DataType { |
|
|
this.dir = dir; |
|
|
this.dir = dir; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @param p the current project |
|
|
|
|
|
* @return the directory attribute |
|
|
|
|
|
*/ |
|
|
public File getDir(Project p) { |
|
|
public File getDir(Project p) { |
|
|
if (isReference()) { |
|
|
if (isReference()) { |
|
|
return getRef(p).getDir(p); |
|
|
return getRef(p).getDir(p); |
|
@@ -77,12 +95,19 @@ public class FileList extends DataType { |
|
|
return dir; |
|
|
return dir; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Set the filenames attribute. |
|
|
|
|
|
* |
|
|
|
|
|
* @param filenames a string contains filenames, separated by , or |
|
|
|
|
|
* by whitespace. |
|
|
|
|
|
*/ |
|
|
public void setFiles(String filenames) { |
|
|
public void setFiles(String filenames) { |
|
|
if (isReference()) { |
|
|
if (isReference()) { |
|
|
throw tooManyAttributes(); |
|
|
throw tooManyAttributes(); |
|
|
} |
|
|
} |
|
|
if (filenames != null && filenames.length() > 0) { |
|
|
if (filenames != null && filenames.length() > 0) { |
|
|
StringTokenizer tok = new StringTokenizer(filenames, ", \t\n\r\f", false); |
|
|
|
|
|
|
|
|
StringTokenizer tok = new StringTokenizer( |
|
|
|
|
|
filenames, ", \t\n\r\f", false); |
|
|
while (tok.hasMoreTokens()) { |
|
|
while (tok.hasMoreTokens()) { |
|
|
this.filenames.addElement(tok.nextToken()); |
|
|
this.filenames.addElement(tok.nextToken()); |
|
|
} |
|
|
} |
|
@@ -91,6 +116,8 @@ public class FileList extends DataType { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Returns the list of files represented by this FileList. |
|
|
* Returns the list of files represented by this FileList. |
|
|
|
|
|
* @param p the current project |
|
|
|
|
|
* @return the list of files represented by this FileList. |
|
|
*/ |
|
|
*/ |
|
|
public String[] getFiles(Project p) { |
|
|
public String[] getFiles(Project p) { |
|
|
if (isReference()) { |
|
|
if (isReference()) { |
|
@@ -113,6 +140,8 @@ public class FileList extends DataType { |
|
|
/** |
|
|
/** |
|
|
* Performs the check for circular references and returns the |
|
|
* Performs the check for circular references and returns the |
|
|
* referenced FileList. |
|
|
* referenced FileList. |
|
|
|
|
|
* @param p the current project |
|
|
|
|
|
* @return the FileList represented by a referenced filelist. |
|
|
*/ |
|
|
*/ |
|
|
protected FileList getRef(Project p) { |
|
|
protected FileList getRef(Project p) { |
|
|
if (!isChecked()) { |
|
|
if (!isChecked()) { |
|
@@ -130,4 +159,4 @@ public class FileList extends DataType { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} //-- FileList.java |
|
|
|
|
|
|
|
|
} |