org.apache.tools.ant.types

Class ArchiveFileSet

Implemented Interfaces:
Cloneable, ResourceCollection, SelectorContainer
Known Direct Subclasses:
TarFileSet, ZipFileSet

public abstract class ArchiveFileSet
extends FileSet

A ArchiveFileSet is a FileSet with extra attributes useful in the context of archiving tasks. It includes a prefix attribute which is prepended to each entry in the output archive file as well as a fullpath ttribute. It also supports Unix file permissions for files and directories.
Since:
Ant 1.7

Field Summary

static int
DEFAULT_DIR_MODE
Default value for the dirmode attribute.
static int
DEFAULT_FILE_MODE
Default value for the filemode attribute.

Fields inherited from class org.apache.tools.ant.types.DataType

checked, ref

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

description, location, project

Constructor Summary

ArchiveFileSet()
Constructor for ArchiveFileSet
ArchiveFileSet(ArchiveFileSet fileset)
Constructor using a archive fileset arguement.
ArchiveFileSet(FileSet fileset)
Constructor using a fileset arguement.

Method Summary

void
addConfigured(ResourceCollection a)
Set the source Archive file for the archivefileset.
Object
clone()
Return a ArchiveFileSet that has the same properties as this one.
protected void
configureFileSet(ArchiveFileSet zfs)
A ArchiveFileset accepts another ArchiveFileSet or a FileSet as reference FileSets are often used by the war task for the lib attribute
int
getDirMode()
Deprecated. since 1.7.
int
getDirMode(Project p)
Get the dir mode of the archive fileset
DirectoryScanner
getDirectoryScanner(Project p)
Return the DirectoryScanner associated with this FileSet.
int
getFileMode()
Deprecated. since 1.7.
int
getFileMode(Project p)
Get the mode of the archive fileset
String
getFullpath()
Deprecated. since 1.7.
String
getFullpath(Project p)
Return the full pathname of the single entry in this fileset.
String
getPrefix()
Deprecated. since 1.7.
String
getPrefix(Project p)
Return the prefix prepended to entries in the archive file.
File
getSrc()
Get the archive file from which entries will be extracted.
File
getSrc(Project p)
Get the archive from which entries will be extracted.
boolean
hasDirModeBeenSet()
Whether the user has specified the mode explicitly.
boolean
hasFileModeBeenSet()
Whether the user has specified the mode explicitly.
void
integerSetDirMode(int mode)
specify the user, group and other modes in the standard Unix fashion; optional, default=0755

We use the strange name so this method doesn't appear in IntrospectionHelpers list of attribute setters.

void
integerSetFileMode(int mode)
specify the user, group and other modes in the standard Unix fashion; optional, default=0644

We use the strange name so this method doesn't appear in IntrospectionHelpers list of attribute setters.

boolean
isFilesystemOnly()
Indicate whether this ResourceCollection is composed entirely of Resources accessible via local filesystem conventions.
Iterator
iterator()
Fulfill the ResourceCollection contract.
protected abstract ArchiveScanner
newArchiveScanner()
Creates a scanner for this type of archive.
void
setDir(File dir)
Set the directory for the fileset.
void
setDirMode(String octalString)
A 3 digit octal string, specify the user, group and other modes in the standard Unix fashion; optional, default=0755
void
setFileMode(String octalString)
A 3 digit octal string, specify the user, group and other modes in the standard Unix fashion; optional, default=0644
void
setFullpath(String fullpath)
Set the full pathname of the single entry in this fileset.
void
setPrefix(String prefix)
Prepend this prefix to the path for each archive entry.
void
setSrc(File srcFile)
Set the source Archive file for the archivefileset.
void
setSrcResource(Resource src)
Set the source Archive file for the archivefileset.
int
size()
Fulfill the ResourceCollection contract.
String
toString()
for file based zipfilesets, return the same as for normal filesets else just return the path of the zip

Methods inherited from class org.apache.tools.ant.types.FileSet

clone, isFilesystemOnly, iterator, size

Methods inherited from class org.apache.tools.ant.types.AbstractFileSet

add, addAnd, addContains, addContainsRegexp, addCustom, addDate, addDepend, addDepth, addDifferent, addFilename, addMajority, addModified, addNone, addNot, addOr, addPresent, addSelector, addSize, addType, appendExcludes, appendIncludes, appendSelector, clone, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDefaultexcludes, getDir, getDir, getDirectoryScanner, getDirectoryScanner, getRef, getSelectors, hasPatterns, hasSelectors, isCaseSensitive, isFollowSymlinks, mergeExcludes, mergeIncludes, mergePatterns, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setDir, setExcludes, setExcludesfile, setFile, setFollowSymlinks, setIncludes, setIncludesfile, setRefid, setupDirectoryScanner, setupDirectoryScanner, toString

Methods inherited from class org.apache.tools.ant.types.DataType

checkAttributesAllowed, checkChildrenAllowed, circularReference, clone, dieOnCircularReference, dieOnCircularReference, dieOnCircularReference, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getDataTypeName, getRefid, invokeCircularReferenceCheck, isChecked, isReference, noChildrenAllowed, setChecked, setRefid, toString, tooManyAttributes

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

clone, getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject

Field Details

DEFAULT_DIR_MODE

public static final int DEFAULT_DIR_MODE
Default value for the dirmode attribute.
Field Value:
16877
Since:
Ant 1.5.2

DEFAULT_FILE_MODE

public static final int DEFAULT_FILE_MODE
Default value for the filemode attribute.
Field Value:
33188
Since:
Ant 1.5.2

Constructor Details

ArchiveFileSet

public ArchiveFileSet()
Constructor for ArchiveFileSet

ArchiveFileSet

protected ArchiveFileSet(ArchiveFileSet fileset)
Constructor using a archive fileset arguement.
Parameters:
fileset - the archivefileset to use

ArchiveFileSet

protected ArchiveFileSet(FileSet fileset)
Constructor using a fileset arguement.
Parameters:
fileset - the fileset to use

Method Details

addConfigured

public void addConfigured(ResourceCollection a)
Set the source Archive file for the archivefileset. Prevents both "dir" and "src" from being specified.
Parameters:
a - the archive as a single element Resource collection.

clone

public Object clone()
Return a ArchiveFileSet that has the same properties as this one.
Overrides:
clone in interface FileSet
Returns:
the cloned archiveFileSet
Since:
Ant 1.6

configureFileSet

protected void configureFileSet(ArchiveFileSet zfs)
A ArchiveFileset accepts another ArchiveFileSet or a FileSet as reference FileSets are often used by the war task for the lib attribute
Parameters:
zfs - the project to use

getDirMode

public int getDirMode()

Deprecated. since 1.7.

Returns:
the dir mode.

getDirMode

public int getDirMode(Project p)
Get the dir mode of the archive fileset
Parameters:
p - the project to use
Returns:
the mode

getDirectoryScanner

public DirectoryScanner getDirectoryScanner(Project p)
Return the DirectoryScanner associated with this FileSet. If the ArchiveFileSet defines a source Archive file, then a ArchiveScanner is returned instead.
Overrides:
getDirectoryScanner in interface AbstractFileSet
Parameters:
p - the project to use
Returns:
a directory scanner

getFileMode

public int getFileMode()

Deprecated. since 1.7.

Returns:
the file mode.

getFileMode

public int getFileMode(Project p)
Get the mode of the archive fileset
Parameters:
p - the project to use
Returns:
the mode

getFullpath

public String getFullpath()

Deprecated. since 1.7.

Return the full pathname of the single entryZ in this fileset.
Returns:
the full pathname.

getFullpath

public String getFullpath(Project p)
Return the full pathname of the single entry in this fileset.
Parameters:
p - the project to use
Returns:
the full path

getPrefix

public String getPrefix()

Deprecated. since 1.7.

Return the prefix prepended to entries in the archive file.
Returns:
the prefix.

getPrefix

public String getPrefix(Project p)
Return the prefix prepended to entries in the archive file.
Parameters:
p - the project to use
Returns:
the prefix

getSrc

public File getSrc()
Get the archive file from which entries will be extracted.
Returns:
the archive in case the archive is a file, null otherwise.

getSrc

public File getSrc(Project p)
Get the archive from which entries will be extracted.
Parameters:
p - the project to use
Returns:
the source file

hasDirModeBeenSet

public boolean hasDirModeBeenSet()
Whether the user has specified the mode explicitly.
Returns:
true if it has been set

hasFileModeBeenSet

public boolean hasFileModeBeenSet()
Whether the user has specified the mode explicitly.
Returns:
true if it has been set

integerSetDirMode

public void integerSetDirMode(int mode)
specify the user, group and other modes in the standard Unix fashion; optional, default=0755

We use the strange name so this method doesn't appear in IntrospectionHelpers list of attribute setters.

Parameters:
mode - a int value
Since:
Ant 1.7

integerSetFileMode

public void integerSetFileMode(int mode)
specify the user, group and other modes in the standard Unix fashion; optional, default=0644

We use the strange name so this method doesn't appear in IntrospectionHelpers list of attribute setters.

Parameters:
mode - a int value
Since:
Ant 1.7

isFilesystemOnly

public boolean isFilesystemOnly()
Indicate whether this ResourceCollection is composed entirely of Resources accessible via local filesystem conventions. If true, all Resources returned from this ResourceCollection should be instances of FileResource.
Specified by:
isFilesystemOnly in interface ResourceCollection
Overrides:
isFilesystemOnly in interface FileSet
Returns:
whether this is a filesystem-only resource collection.
Since:
Ant 1.7

iterator

public Iterator iterator()
Fulfill the ResourceCollection contract.
Specified by:
iterator in interface ResourceCollection
Overrides:
iterator in interface FileSet
Returns:
Iterator of Resources.
Since:
Ant 1.7

newArchiveScanner

protected abstract ArchiveScanner newArchiveScanner()
Creates a scanner for this type of archive.
Returns:
the scanner.

setDir

public void setDir(File dir)
            throws BuildException
Set the directory for the fileset.
Overrides:
setDir in interface AbstractFileSet
Parameters:
dir - the directory for the fileset
Throws:
BuildException - on error

setDirMode

public void setDirMode(String octalString)
A 3 digit octal string, specify the user, group and other modes in the standard Unix fashion; optional, default=0755
Parameters:
octalString - a String value

setFileMode

public void setFileMode(String octalString)
A 3 digit octal string, specify the user, group and other modes in the standard Unix fashion; optional, default=0644
Parameters:
octalString - a String value

setFullpath

public void setFullpath(String fullpath)
Set the full pathname of the single entry in this fileset. Prevents both prefix and fullpath from being specified
Parameters:
fullpath - the full pathname of the single entry in this fileset.

setPrefix

public void setPrefix(String prefix)
Prepend this prefix to the path for each archive entry. Prevents both prefix and fullpath from being specified
Parameters:
prefix - The prefix to prepend to entries in the archive file.

setSrc

public void setSrc(File srcFile)
Set the source Archive file for the archivefileset. Prevents both "dir" and "src" from being specified.
Parameters:
srcFile - The archive from which to extract entries.

setSrcResource

public void setSrcResource(Resource src)
Set the source Archive file for the archivefileset. Prevents both "dir" and "src" from being specified.
Parameters:
src - The archive from which to extract entries.

size

public int size()
Fulfill the ResourceCollection contract.
Specified by:
size in interface ResourceCollection
Overrides:
size in interface FileSet
Returns:
size of the collection as int.
Since:
Ant 1.7

toString

public String toString()
for file based zipfilesets, return the same as for normal filesets else just return the path of the zip
Overrides:
toString in interface AbstractFileSet
Returns:
for file based archivefilesets, included files as a list of semicolon-separated filenames. else just the name of the zip.