SourceFileScannerpublic class SourceFileScanner extends Object implements org.apache.tools.ant.types.ResourceFactoryUtility class that collects the functionality of the various
scanDir methods that have been scattered in several tasks before.
The only method returns an array of source files. The array is a
subset of the files given as a parameter and holds only those that
are newer than their corresponding target files. |
Fields Summary |
---|
protected org.apache.tools.ant.Task | task | private static final FileUtils | FILE_UTILS | private File | destDir |
Constructors Summary |
---|
public SourceFileScanner(org.apache.tools.ant.Task task)Construct a new SourceFileScanner. // base directory of the fileset
this.task = task;
|
Methods Summary |
---|
public org.apache.tools.ant.types.Resource | getResource(java.lang.String name)Returns resource information for a file at destination.
return new FileResource(destDir, name);
| public java.lang.String[] | restrict(java.lang.String[] files, java.io.File srcDir, java.io.File destDir, FileNameMapper mapper)Restrict the given set of files to those that are newer than
their corresponding target files.
return restrict(files, srcDir, destDir, mapper,
FILE_UTILS.getFileTimestampGranularity());
| public java.lang.String[] | restrict(java.lang.String[] files, java.io.File srcDir, java.io.File destDir, FileNameMapper mapper, long granularity)Restrict the given set of files to those that are newer than
their corresponding target files.
// record destdir for later use in getResource
this.destDir = destDir;
Vector v = new Vector();
for (int i = 0; i < files.length; i++) {
File src = FILE_UTILS.resolveFile(srcDir, files[i]);
v.addElement(new Resource(files[i], src.exists(),
src.lastModified(), src.isDirectory()));
}
Resource[] sourceresources = new Resource[v.size()];
v.copyInto(sourceresources);
// build the list of sources which are out of date with
// respect to the target
Resource[] outofdate =
ResourceUtils.selectOutOfDateSources(task, sourceresources,
mapper, this, granularity);
String[] result = new String[outofdate.length];
for (int counter = 0; counter < outofdate.length; counter++) {
result[counter] = outofdate[counter].getName();
}
return result;
| public java.io.File[] | restrictAsFiles(java.lang.String[] files, java.io.File srcDir, java.io.File destDir, FileNameMapper mapper)Convenience layer on top of restrict that returns the source
files as File objects (containing absolute paths if srcDir is
absolute).
return restrictAsFiles(files, srcDir, destDir, mapper,
FILE_UTILS.getFileTimestampGranularity());
| public java.io.File[] | restrictAsFiles(java.lang.String[] files, java.io.File srcDir, java.io.File destDir, FileNameMapper mapper, long granularity)Convenience layer on top of restrict that returns the source
files as File objects (containing absolute paths if srcDir is
absolute).
String[] res = restrict(files, srcDir, destDir, mapper, granularity);
File[] result = new File[res.length];
for (int i = 0; i < res.length; i++) {
result[i] = new File(srcDir, res[i]);
}
return result;
|
|