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

public abstract Class ArchiveScanner

extends DirectoryScanner
Class Inheritance
Known Direct Subclasses
org.apache.tools.ant.types.TarScanner, org.apache.tools.ant.types.ZipScanner
Imports
java.io.File, java.util.Iterator, .Map, .TreeMap, org.apache.tools.ant.DirectoryScanner, .Project, org.apache.tools.ant.types.resources.FileProvider, .FileResource, .FileResourceIterator

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

Modifier and TypeField and Description
private Map<String, Resource>
dirEntries

record list of all directory zip entries

private String
encoding

encoding of file names.

private boolean
private Map<String, Resource>
fileEntries

record list of all file zip entries

private Resource
lastScannedResource

to record the last scanned zip file with its modification date

private Map<String, Resource>
matchDirEntries

record list of matching directory zip entries

private Map<String, Resource>
matchFileEntries

record list of matching file zip entries

private Resource
src

The archive resource which should be scanned.

protected File
srcFile

The archive file which should be scanned.

Inherited from org.apache.tools.ant.DirectoryScanner:
basedirDEFAULTEXCLUDESdirsDeselecteddirsExcludeddirsIncludeddirsNotIncludedDOES_NOT_EXIST_POSTFIXerrorOnMissingDireverythingIncludedexcludesfilesDeselectedfilesExcludedfilesIncludedfilesNotIncludedhaveSlowResultsincludesisCaseSensitiveMAX_LEVELS_OF_SYMLINKSselectors

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract void
fillMapsFromArchive(Resource
the archive to scan.
archive
,
String
encoding used to encode file names inside the archive.
encoding
,
Map<String, Resource>
Map (name to resource) of non-directory resources found inside the archive.
fileEntries
,
Map<String, Resource>
Map (name to resource) of non-directory resources found inside the archive that matched all include patterns and didn't match any exclude patterns.
matchFileEntries
,
Map<String, Resource>
Map (name to resource) of directory resources found inside the archive.
dirEntries
,
Map<String, Resource>
Map (name to resource) of directory resources found inside the archive that matched all include patterns and didn't match any exclude patterns.
matchDirEntries
)

Fills the file and directory maps with resources read from the archive.

public String[]

Returns:

the names of the directories which matched at least one of the include patterns and none of the exclude patterns.
getIncludedDirectories
()

Overrides org.apache.tools.ant.DirectoryScanner.getIncludedDirectories.

Implements org.apache.tools.ant.FileScanner.getIncludedDirectories.

Returns the names of the directories which matched at least one of the include patterns and none of the exclude patterns.
public int

Returns:

count of included directories.
getIncludedDirsCount
()

Overrides org.apache.tools.ant.DirectoryScanner.getIncludedDirsCount.

Override parent implementation.
public String[]

Returns:

the names of the files which matched at least one of the include patterns and none of the exclude patterns.
getIncludedFiles
()

Overrides org.apache.tools.ant.DirectoryScanner.getIncludedFiles.

Implements org.apache.tools.ant.FileScanner.getIncludedFiles.

Returns the names of the files which matched at least one of the include patterns and none of the exclude patterns.
public int

Returns:

count of included files.
getIncludedFilesCount
()

Overrides org.apache.tools.ant.DirectoryScanner.getIncludedFilesCount.

Override parent implementation.
public Resource

Returns:

the resource
getResource
(String
path name of the file sought in the archive
name
)

Overrides org.apache.tools.ant.DirectoryScanner.getResource.

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

Get the named Resource.
pack-priv Iterator<Resource>

Returns:

an Iterator of Resources.
getResourceDirectories
(Project
since Ant 1.8
project
)

Get the set of Resources that represent directories.

pack-priv Iterator<Resource>

Returns:

an Iterator of Resources.
getResourceFiles
(Project
since Ant 1.8
project
)

Get the set of Resources that represent files.

public void
init()

Initialize DirectoryScanner data structures.

public boolean

Returns:

true if the path should be included false otherwise.
match
(String
the (non-null) path name to test for inclusion
path
)

Matches a jar entry against the includes/excludes list, normalizing the path separator.

public void
scan()

Overrides org.apache.tools.ant.DirectoryScanner.scan.

Implements org.apache.tools.ant.FileScanner.scan.

Don't scan when we have no zipfile.
private void
scanme()

if the datetime of the archive did not change since lastScannedResource was initialized returns immediately else if the archive has not been scanned yet, then all the zip entries are put into the appropriate tables.

public void
setEncoding(String
the encoding format
encoding
)

Sets encoding of file names.

public void
setErrorOnMissingArchive(boolean
true if missing archives cause errors, false if not.
errorOnMissingArchive
)

Sets whether an error is thrown if an archive does not exist.

public void
setSrc(File
the (non-null) archive file name for scanning
srcFile
)

Sets the srcFile for scanning.

public void
setSrc(Resource
the (non-null) archive resource
src
)

Sets the src for scanning.

protected static final String

Returns:

the trimmed file name.
trimSeparator
(String
the file name to trim.
s
)

Remove trailing slash if present.

Inherited from org.apache.tools.ant.DirectoryScanner:
addDefaultExcludeaddDefaultExcludesaddExcludesclearResultscouldHoldIncludedgetBasedirgetDefaultExcludesgetDeselectedDirectoriesgetDeselectedFilesgetExcludedDirectoriesgetExcludedFilesgetNotFollowedSymlinksgetNotIncludedDirectoriesgetNotIncludedFilesisCaseSensitiveisEverythingIncludedisExcludedisFollowSymlinksisIncludedisSelectedmatchmatchmatchPathmatchPathmatchPatternStartmatchPatternStartremoveDefaultExcluderesetDefaultExcludesscandirsetBasedirsetBasedirsetCaseSensitivesetErrorOnMissingDirsetExcludessetFollowSymlinkssetIncludessetMaxLevelsOfSymlinkssetSelectorsslowScan

Field Detail

dirEntriesback to summary
private Map<String, Resource> dirEntries

record list of all directory zip entries

encodingback to summary
private String encoding

encoding of file names.

Since
Ant 1.6
errorOnMissingArchiveback to summary
private boolean errorOnMissingArchive
Since
Ant 1.8.0
fileEntriesback to summary
private Map<String, Resource> fileEntries

record list of all file zip entries

lastScannedResourceback to summary
private Resource lastScannedResource

to record the last scanned zip file with its modification date

matchDirEntriesback to summary
private Map<String, Resource> matchDirEntries

record list of matching directory zip entries

matchFileEntriesback to summary
private Map<String, Resource> matchFileEntries

record list of matching file zip entries

srcback to summary
private Resource src

The archive resource which should be scanned.

srcFileback to summary
protected File srcFile

The archive file which should be scanned.

Constructor Detail

ArchiveScannerback to summary
public ArchiveScanner()

Method Detail

fillMapsFromArchiveback to summary
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:Resource

the archive to scan.

encoding:String

encoding used to encode file names inside the archive.

fileEntries:Map<String, Resource>

Map (name to resource) of non-directory resources found inside the archive.

matchFileEntries:Map<String, Resource>

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<String, Resource>

Map (name to resource) of directory resources found inside the archive.

matchDirEntries:Map<String, Resource>

Map (name to resource) of directory resources found inside the archive that matched all include patterns and didn't match any exclude patterns.

getIncludedDirectoriesback to summary
public String[] getIncludedDirectories()

Overrides org.apache.tools.ant.DirectoryScanner.getIncludedDirectories.

Implements org.apache.tools.ant.FileScanner.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.

Returns:String[]

the names of the directories which matched at least one of the include patterns and none of the exclude patterns.

getIncludedDirsCountback to summary
public int getIncludedDirsCount()

Overrides org.apache.tools.ant.DirectoryScanner.getIncludedDirsCount.

Override parent implementation.

Returns:int

count of included directories.

Since
Ant 1.7
getIncludedFilesback to summary
public String[] getIncludedFiles()

Overrides org.apache.tools.ant.DirectoryScanner.getIncludedFiles.

Implements org.apache.tools.ant.FileScanner.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.

Returns:String[]

the names of the files which matched at least one of the include patterns and none of the exclude patterns.

getIncludedFilesCountback to summary
public int getIncludedFilesCount()

Overrides org.apache.tools.ant.DirectoryScanner.getIncludedFilesCount.

Override parent implementation.

Returns:int

count of included files.

Since
Ant 1.7
getResourceback to summary
public Resource getResource(String name)

Overrides org.apache.tools.ant.DirectoryScanner.getResource.

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

Get the named Resource.

Parameters
name:String

path name of the file sought in the archive

Returns:Resource

the resource

Annotations
@Override
Since
Ant 1.5.2
getResourceDirectoriesback to summary
pack-priv Iterator<Resource> getResourceDirectories(Project project)

Get the set of Resources that represent directories.

Parameters
project:Project

since Ant 1.8

Returns:Iterator<Resource>

an Iterator of Resources.

Since
Ant 1.7
getResourceFilesback to summary
pack-priv Iterator<Resource> getResourceFiles(Project project)

Get the set of Resources that represent files.

Parameters
project:Project

since Ant 1.8

Returns:Iterator<Resource>

an Iterator of Resources.

Since
Ant 1.7
initback to summary
public void init()

Initialize DirectoryScanner data structures.

matchback to summary
public boolean match(String path)

Matches a jar entry against the includes/excludes list, normalizing the path separator.

Parameters
path:String

the (non-null) path name to test for inclusion

Returns:boolean

true if the path should be included false otherwise.

scanback to summary
public void scan()

Overrides org.apache.tools.ant.DirectoryScanner.scan.

Implements org.apache.tools.ant.FileScanner.scan.

Don't scan when we have no zipfile.

Since
Ant 1.7
scanmeback to summary
private void scanme()

if the datetime of the archive did not change since lastScannedResource was initialized returns immediately else if the archive has not been scanned yet, then all the zip entries are put into the appropriate tables.

setEncodingback to summary
public void setEncoding(String encoding)

Sets encoding of file names.

Parameters
encoding:String

the encoding format

Since
Ant 1.6
setErrorOnMissingArchiveback to summary
public void setErrorOnMissingArchive(boolean errorOnMissingArchive)

Sets whether an error is thrown if an archive does not exist.

Parameters
errorOnMissingArchive:boolean

true if missing archives cause errors, false if not.

Since
Ant 1.8.0
setSrcback to summary
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:File

the (non-null) archive file name for scanning

setSrcback to summary
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:Resource

the (non-null) archive resource

trimSeparatorback to summary
protected static final String trimSeparator(String s)

Remove trailing slash if present.

Parameters
s:String

the file name to trim.

Returns:String

the trimmed file name.