Top Description Fields Constructors Methods
org.apache.tools.ant.util

public Class SourceFileScanner

extends Object
implements ResourceFactory
Class Inheritance
All Implemented Interfaces
org.apache.tools.ant.types.ResourceFactory
Imports
java.io.File, java.util.stream.Stream, org.apache.tools.ant.Task, org.apache.tools.ant.types.Resource, .ResourceFactory, org.apache.tools.ant.types.resources.FileResource

Utility 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.

Field Summary

Modifier and TypeField and Description
private File
private static final FileUtils
protected Task

Constructor Summary

AccessConstructor and Description
public
SourceFileScanner(Task
The task we should log messages through.
task
)

Construct a new SourceFileScanner.

Method Summary

Modifier and TypeMethod and Description
public Resource

Returns:

data concerning a file whose relative path to destDir is name.
getResource
(String
relative path of file at destination.
name
)

Implements org.apache.tools.ant.types.ResourceFactory.getResource.

Returns resource information for a file at destination.
public String[]

Returns:

an array of filenames.
restrict
(String[]
the original set of files.
files
,
File
all files are relative to this directory.
srcDir
,
File
target files live here. if null file names returned by the mapper are assumed to be absolute.
destDir
,
FileNameMapper
knows how to construct a target file names from source file names.
mapper
)

Restrict the given set of files to those that are newer than their corresponding target files.

public String[]

Returns:

an array of filenames.
restrict
(String[]
the original set of files.
files
,
File
all files are relative to this directory.
srcDir
,
File
target files live here. If null file names returned by the mapper are assumed to be absolute.
destDir
,
FileNameMapper
knows how to construct a target file names from source file names.
mapper
,
long
The number of milliseconds leeway to give before deciding a target is out of date.
granularity
)

Restrict the given set of files to those that are newer than their corresponding target files.

public File[]

Returns:

an array of files.
restrictAsFiles
(String[]
the original set of files.
files
,
File
all files are relative to this directory.
srcDir
,
File
target files live here. If null file names returned by the mapper are assumed to be absolute.
destDir
,
FileNameMapper
knows how to construct a target file names from source file names.
mapper
)

Convenience layer on top of restrict that returns the source files as File objects (containing absolute paths if srcDir is absolute).

public File[]

Returns:

an array of files.
restrictAsFiles
(String[]
the original set of files.
files
,
File
all files are relative to this directory.
srcDir
,
File
target files live here. If null file names returned by the mapper are assumed to be absolute.
destDir
,
FileNameMapper
knows how to construct a target file names from source file names.
mapper
,
long
The number of milliseconds leeway to give before deciding a target is out of date.
granularity
)

Convenience layer on top of restrict that returns the source files as File objects (containing absolute paths if srcDir is absolute).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

destDirback to summary
private File destDir
FILE_UTILSback to summary
private static final FileUtils FILE_UTILS
taskback to summary
protected Task task

Constructor Detail

SourceFileScannerback to summary
public SourceFileScanner(Task task)

Construct a new SourceFileScanner.

Parameters
task:Task

The task we should log messages through.

Method Detail

getResourceback to summary
public Resource getResource(String name)

Implements org.apache.tools.ant.types.ResourceFactory.getResource.

Returns resource information for a file at destination.

Parameters
name:String

relative path of file at destination.

Returns:Resource

data concerning a file whose relative path to destDir is name.

Annotations
@Override
Since
Ant 1.5.2
restrictback to summary
public String[] restrict(String[] files, File srcDir, File destDir, FileNameMapper mapper)

Restrict the given set of files to those that are newer than their corresponding target files.

Parameters
files:String[]

the original set of files.

srcDir:File

all files are relative to this directory.

destDir:File

target files live here. if null file names returned by the mapper are assumed to be absolute.

mapper:FileNameMapper

knows how to construct a target file names from source file names.

Returns:String[]

an array of filenames.

restrictback to summary
public String[] restrict(String[] files, File srcDir, File destDir, FileNameMapper mapper, long granularity)

Restrict the given set of files to those that are newer than their corresponding target files.

Parameters
files:String[]

the original set of files.

srcDir:File

all files are relative to this directory.

destDir:File

target files live here. If null file names returned by the mapper are assumed to be absolute.

mapper:FileNameMapper

knows how to construct a target file names from source file names.

granularity:long

The number of milliseconds leeway to give before deciding a target is out of date.

Returns:String[]

an array of filenames.

Since
Ant 1.6.2
restrictAsFilesback to summary
public File[] restrictAsFiles(String[] files, File srcDir, 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).

Parameters
files:String[]

the original set of files.

srcDir:File

all files are relative to this directory.

destDir:File

target files live here. If null file names returned by the mapper are assumed to be absolute.

mapper:FileNameMapper

knows how to construct a target file names from source file names.

Returns:File[]

an array of files.

restrictAsFilesback to summary
public File[] restrictAsFiles(String[] files, File srcDir, 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).

Parameters
files:String[]

the original set of files.

srcDir:File

all files are relative to this directory.

destDir:File

target files live here. If null file names returned by the mapper are assumed to be absolute.

mapper:FileNameMapper

knows how to construct a target file names from source file names.

granularity:long

The number of milliseconds leeway to give before deciding a target is out of date.

Returns:File[]

an array of files.

Since
Ant 1.6.2