org.apache.tools.ant.types

Class ArchiveScanner

Implemented Interfaces:
FileScanner, ResourceFactory, SelectorScanner
Known Direct Subclasses:
TarScanner, ZipScanner

public abstract class ArchiveScanner
extends DirectoryScanner

ArchiveScanner accesses the pattern matching algorithm in DirectoryScanner, which are protected methods that can only be accessed by subclassing. This implementation of FileScanner defines getIncludedFiles to return the matching archive entries.
Since:
Ant 1.7

Field Summary

protected File
srcFile
The archive file which should be scanned.

Fields inherited from class org.apache.tools.ant.DirectoryScanner

DEFAULTEXCLUDES, basedir, dirsDeselected, dirsExcluded, dirsIncluded, dirsNotIncluded, everythingIncluded, excludes, filesDeselected, filesExcluded, filesIncluded, filesNotIncluded, haveSlowResults, includes, isCaseSensitive, selectors

Method Summary

protected abstract void
fillMapsFromArchive(Resource archive, String encoding, Map fileEntries, Map matchFileEntries, Map dirEntries, Map matchDirEntries)
Fills the file and directory maps with resources read from the archive.
String[]
getIncludedDirectories()
Returns the names of the directories which matched at least one of the include patterns and none of the exclude patterns.
int
getIncludedDirsCount()
Override parent implementation.
String[]
getIncludedFiles()
Returns the names of the files which matched at least one of the include patterns and none of the exclude patterns.
int
getIncludedFilesCount()
Override parent implementation.
Resource
getResource(String name)
Get the named Resource.
void
init()
Initialize DirectoryScanner data structures.
boolean
match(String path)
Matches a jar entry against the includes/excludes list, normalizing the path separator.
void
scan()
Don't scan when we have no zipfile.
void
setEncoding(String encoding)
Sets encoding of file names.
void
setSrc(File srcFile)
Sets the srcFile for scanning.
void
setSrc(Resource src)
Sets the src for scanning.
protected static String
trimSeparator(String s)
Remove trailing slash if present.

Methods inherited from class org.apache.tools.ant.DirectoryScanner

addDefaultExclude, addDefaultExcludes, addExcludes, clearResults, couldHoldIncluded, getBasedir, getDefaultExcludes, getDeselectedDirectories, getDeselectedFiles, getExcludedDirectories, getExcludedFiles, getIncludedDirectories, getIncludedDirsCount, getIncludedFiles, getIncludedFilesCount, getNotIncludedDirectories, getNotIncludedFiles, getResource, isCaseSensitive, isEverythingIncluded, isExcluded, isFollowSymlinks, isIncluded, isSelected, match, match, matchPath, matchPath, matchPatternStart, matchPatternStart, removeDefaultExclude, resetDefaultExcludes, scan, scandir, setBasedir, setBasedir, setCaseSensitive, setExcludes, setFollowSymlinks, setIncludes, setSelectors, slowScan

Field Details

srcFile

protected File srcFile
The archive file which should be scanned.

Method Details

fillMapsFromArchive

protected abstract void fillMapsFromArchive(Resource archive,
                                            String encoding,
                                            Map fileEntries,
                                            Map matchFileEntries,
                                            Map dirEntries,
                                            Map matchDirEntries)
Fills the file and directory maps with resources read from the archive.
Parameters:
archive - the archive to scan.
encoding - encoding used to encode file names inside the archive.
fileEntries - Map (name to resource) of non-directory resources found inside the archive.
matchFileEntries - Map (name to resource) of non-directory resources found inside the archive that matched all include patterns and didn't match any exclude patterns.
dirEntries - Map (name to resource) of directory resources found inside the archive.
matchDirEntries - Map (name to resource) of directory resources found inside the archive that matched all include patterns and didn't match any exclude patterns.

getIncludedDirectories

public String[] getIncludedDirectories()
Returns the names of the directories which matched at least one of the include patterns and none of the exclude patterns. The names are relative to the base directory.
Specified by:
getIncludedDirectories in interface FileScanner
Overrides:
getIncludedDirectories in interface DirectoryScanner
Returns:
the names of the directories which matched at least one of the include patterns and none of the exclude patterns.

getIncludedDirsCount

public int getIncludedDirsCount()
Override parent implementation.
Overrides:
getIncludedDirsCount in interface DirectoryScanner
Returns:
count of included directories.
Since:
Ant 1.7

getIncludedFiles

public String[] getIncludedFiles()
Returns the names of the files which matched at least one of the include patterns and none of the exclude patterns. The names are relative to the base directory.
Specified by:
getIncludedFiles in interface FileScanner
Overrides:
getIncludedFiles in interface DirectoryScanner
Returns:
the names of the files which matched at least one of the include patterns and none of the exclude patterns.

getIncludedFilesCount

public int getIncludedFilesCount()
Override parent implementation.
Overrides:
getIncludedFilesCount in interface DirectoryScanner
Returns:
count of included files.
Since:
Ant 1.7

getResource

public Resource getResource(String name)
Get the named Resource.
Specified by:
getResource in interface ResourceFactory
Overrides:
getResource in interface DirectoryScanner
Parameters:
name - path name of the file sought in the archive
Returns:
the resource
Since:
Ant 1.5.2

init

public void init()
Initialize DirectoryScanner data structures.

match

public boolean match(String path)
Matches a jar entry against the includes/excludes list, normalizing the path separator.
Parameters:
path - the (non-null) path name to test for inclusion
Returns:
true if the path should be included false otherwise.

scan

public void scan()
Don't scan when we have no zipfile.
Specified by:
scan in interface FileScanner
Overrides:
scan in interface DirectoryScanner
Since:
Ant 1.7

setEncoding

public void setEncoding(String encoding)
Sets encoding of file names.
Parameters:
encoding - the encoding format
Since:
Ant 1.6

setSrc

public void setSrc(File srcFile)
Sets the srcFile for scanning. This is the jar or zip file that is scanned for matching entries.
Parameters:
srcFile - the (non-null) archive file name for scanning

setSrc

public void setSrc(Resource src)
Sets the src for scanning. This is the jar or zip file that is scanned for matching entries.
Parameters:
src - the (non-null) archive resource

trimSeparator

protected static final String trimSeparator(String s)
Remove trailing slash if present.
Parameters:
s - the file name to trim.
Returns:
the trimed file name.