Package org.apache.tools.ant.types
Class ArchiveScanner
java.lang.Object
org.apache.tools.ant.DirectoryScanner
org.apache.tools.ant.types.ArchiveScanner
- All Implemented Interfaces:
FileScanner
,ResourceFactory
,SelectorScanner
- Direct Known Subclasses:
TarScanner
,ZipScanner
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
Fields inherited from class org.apache.tools.ant.DirectoryScanner
basedir, DEFAULTEXCLUDES, dirsDeselected, dirsExcluded, dirsIncluded, dirsNotIncluded, DOES_NOT_EXIST_POSTFIX, errorOnMissingDir, everythingIncluded, excludes, filesDeselected, filesExcluded, filesIncluded, filesNotIncluded, haveSlowResults, includes, isCaseSensitive, MAX_LEVELS_OF_SYMLINKS, selectors
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
fillMapsFromArchive
(Resource archive, String encoding, Map<String, Resource> fileEntries, Map<String, Resource> matchFileEntries, Map<String, Resource> dirEntries, Map<String, Resource> matchDirEntries) Fills the file and directory maps with resources read from the archive.String[]
Returns the names of the directories which matched at least one of the include patterns and none of the exclude patterns.int
Override parent implementation.String[]
Returns the names of the files which matched at least one of the include patterns and none of the exclude patterns.int
Override parent implementation.getResource
(String name) Get the named Resource.void
init()
Initialize DirectoryScanner data structures.boolean
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
setErrorOnMissingArchive
(boolean errorOnMissingArchive) Sets whether an error is thrown if an archive does not exist.void
Sets the srcFile for scanning.void
Sets the src for scanning.protected static final String
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, getNotFollowedSymlinks, getNotIncludedDirectories, getNotIncludedFiles, isCaseSensitive, isEverythingIncluded, isExcluded, isFollowSymlinks, isIncluded, isSelected, match, match, matchPath, matchPath, matchPatternStart, matchPatternStart, removeDefaultExclude, resetDefaultExcludes, scandir, setBasedir, setBasedir, setCaseSensitive, setErrorOnMissingDir, setExcludes, setFollowSymlinks, setIncludes, setMaxLevelsOfSymlinks, setSelectors, slowScan
-
Field Details
-
srcFile
The archive file which should be scanned.
-
-
Constructor Details
-
ArchiveScanner
public ArchiveScanner()
-
-
Method Details
-
setErrorOnMissingArchive
public void setErrorOnMissingArchive(boolean errorOnMissingArchive) Sets whether an error is thrown if an archive does not exist.- Parameters:
errorOnMissingArchive
- true if missing archives cause errors, false if not.- Since:
- Ant 1.8.0
-
scan
public void scan()Don't scan when we have no zipfile.- Specified by:
scan
in interfaceFileScanner
- Overrides:
scan
in classDirectoryScanner
- Since:
- Ant 1.7
-
setSrc
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
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
-
setEncoding
Sets encoding of file names.- Parameters:
encoding
- the encoding format- Since:
- Ant 1.6
-
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 interfaceFileScanner
- Overrides:
getIncludedFiles
in classDirectoryScanner
- 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 classDirectoryScanner
- Returns:
- count of included files.
- Since:
- Ant 1.7
-
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 interfaceFileScanner
- Overrides:
getIncludedDirectories
in classDirectoryScanner
- 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 classDirectoryScanner
- Returns:
- count of included directories.
- Since:
- Ant 1.7
-
init
public void init()Initialize DirectoryScanner data structures. -
match
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 includedfalse
otherwise.
-
getResource
Get the named Resource.- Specified by:
getResource
in interfaceResourceFactory
- Overrides:
getResource
in classDirectoryScanner
- Parameters:
name
- path name of the file sought in the archive- Returns:
- the resource
- Since:
- Ant 1.5.2
-
fillMapsFromArchive
protected abstract void fillMapsFromArchive(Resource archive, String encoding, Map<String, Resource> fileEntries, Map<String, Resource> matchFileEntries, Map<String, Resource> dirEntries, Map<String, Resource> 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.
-
trimSeparator
-