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

public abstract Class ArchiveFileSet

extends FileSet
Class Inheritance
Known Direct Subclasses
org.apache.tools.ant.types.TarFileSet, org.apache.tools.ant.types.ZipFileSet
Imports
java.io.File, java.util.Iterator, .Stack, org.apache.tools.ant.BuildException, .DirectoryScanner, .Project, org.apache.tools.ant.types.resources.FileProvider, .FileResource, org.apache.tools.zip.UnixStat

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 attribute. It also supports Unix file permissions for files and directories.
Since
Ant 1.7

Field Summary

Modifier and TypeField and Description
private static final int
public static final int
DEFAULT_DIR_MODE

Default value for the dirmode attribute.

public static final int
DEFAULT_FILE_MODE

Default value for the filemode attribute.

private int
private boolean
private String
private static final String
private static final String
private boolean
private int
private boolean
private String
private boolean
private String
private Resource

Constructor Summary

AccessConstructor and Description
public
ArchiveFileSet()

Constructor for ArchiveFileSet

protected
ArchiveFileSet(FileSet
the fileset to use
fileset
)

Constructor using a fileset argument.

protected
ArchiveFileSet(ArchiveFileSet
the archivefileset to use
fileset
)

Constructor using a archive fileset argument.

Method Summary

Modifier and TypeMethod and Description
public void
addConfigured(ResourceCollection
the archive as a single element Resource collection.
a
)

Set the source Archive file for the archivefileset.

private void
checkArchiveAttributesAllowed()

A check attributes for archiveFileSet.

public Object

Returns:

the cloned archiveFileSet
clone
()

Overrides org.apache.tools.ant.types.FileSet.clone.

Return a ArchiveFileSet that has the same properties as this one.
protected void
configureFileSet(ArchiveFileSet
the project to use
zfs
)

A ArchiveFileset accepts another ArchiveFileSet or a FileSet as reference FileSets are often used by the war task for the lib attribute

protected synchronized void
dieOnCircularReference(Stack<Object>
the stack of references to check.
stk
,
Project
the project to use to dereference the references.
p
)

Overrides org.apache.tools.ant.types.AbstractFileSet.dieOnCircularReference.

Check to see whether any DataType we hold references to is included in the Stack (which holds all DataType instances that directly or indirectly reference this instance, including this instance itself).
public DirectoryScanner

Returns:

a directory scanner
getDirectoryScanner
(Project
the project to use
p
)

Overrides org.apache.tools.ant.types.AbstractFileSet.getDirectoryScanner.

Return the DirectoryScanner associated with this FileSet.
public int

Returns:

the mode
getDirMode
(Project
the project to use
p
)

Get the dir mode of the archive fileset

public int

Returns:

the dir mode.
getDirMode
()

Deprecated since 1.7.
public String

Returns:

String encoding.
getEncoding
()

Get the encoding used for this ZipFileSet.

public int

Returns:

the mode
getFileMode
(Project
the project to use
p
)

Get the mode of the archive fileset

public int

Returns:

the file mode.
getFileMode
()

Deprecated since 1.7.
public String

Returns:

the full path
getFullpath
(Project
the project to use
p
)

Return the full pathname of the single entry in this fileset.

public String

Returns:

the full pathname.
getFullpath
()

Deprecated since 1.7.
Return the full pathname of the single entryZ in this fileset.
public String

Returns:

the prefix
getPrefix
(Project
the project to use
p
)

Return the prefix prepended to entries in the archive file.

public String

Returns:

the prefix.
getPrefix
()

Deprecated since 1.7.
Return the prefix prepended to entries in the archive file.
protected AbstractFileSet

Returns:

the dereferenced object.
getRef
()

Hides org.apache.tools.ant.types.FileSet.getRef.

Performs the check for circular references and returns the referenced object.
public File

Returns:

the source file
getSrc
(Project
the project to use
p
)

Get the archive from which entries will be extracted.

public File

Returns:

the archive in case the archive is a file, null otherwise.
getSrc
()

Get the archive file from which entries will be extracted.

public boolean

Returns:

true if it has been set
hasDirModeBeenSet
()

Whether the user has specified the mode explicitly.

public boolean

Returns:

true if it has been set
hasFileModeBeenSet
()

Whether the user has specified the mode explicitly.

public void
integerSetDirMode(int
a int value
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.

public void
integerSetFileMode(int
a int value
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.

public boolean

Returns:

whether this is a filesystem-only resource collection.
isFilesystemOnly
()

Overrides org.apache.tools.ant.types.FileSet.isFilesystemOnly.

Implements org.apache.tools.ant.types.ResourceCollection.isFilesystemOnly.

Indicate whether this ResourceCollection is composed entirely of Resources accessible via local filesystem conventions.
public Iterator<Resource>

Returns:

Iterator of Resources.
iterator
()

Overrides org.apache.tools.ant.types.FileSet.iterator.

Implements java.lang.Iterable.iterator.

Fulfill the ResourceCollection contract.
protected abstract ArchiveScanner

Returns:

the scanner.
newArchiveScanner
()

Creates a scanner for this type of archive.

public void
setDir(File
the directory for the fileset
dir
)

Overrides org.apache.tools.ant.types.AbstractFileSet.setDir.

Set the directory for the fileset.
public void
setDirMode(String
a String value
octalString
)

A 3 digit octal string, specify the user, group and other modes in the standard Unix fashion; optional, default=0755

public void
setEncoding(String
encoding as String.
enc
)

Set the encoding used for this ZipFileSet.

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
setFileMode(String
a String value
octalString
)

A 3 digit octal string, specify the user, group and other modes in the standard Unix fashion; optional, default=0644

public void
setFullpath(String
the full pathname of the single entry in this fileset.
fullpath
)

Set the full pathname of the single entry in this fileset.

public void
setPrefix(String
The prefix to prepend to entries in the archive file.
prefix
)

Prepend this prefix to the path for each archive entry.

public void
setSrc(File
The archive from which to extract entries.
srcFile
)

Set the source Archive file for the archivefileset.

public void
setSrcResource(Resource
The archive from which to extract entries.
src
)

Set the source Archive file for the archivefileset.

public int

Returns:

size of the collection as int.
size
()

Overrides org.apache.tools.ant.types.FileSet.size.

Implements org.apache.tools.ant.types.ResourceCollection.size.

Fulfill the ResourceCollection contract.
public String

Returns:

for file based archivefilesets, included files as a list of semicolon-separated filenames. else just the name of the zip.
toString
()

Overrides org.apache.tools.ant.types.AbstractFileSet.toString.

For file-based archivefilesets, return the same as for normal filesets; else just return the path of the zip.
Inherited from org.apache.tools.ant.types.FileSet:
getRef

Field Detail

BASE_OCTALback to summary
private static final int BASE_OCTAL
DEFAULT_DIR_MODEback to summary
public static final int DEFAULT_DIR_MODE

Default value for the dirmode attribute.

Since
Ant 1.5.2
DEFAULT_FILE_MODEback to summary
public static final int DEFAULT_FILE_MODE

Default value for the filemode attribute.

Since
Ant 1.5.2
dirModeback to summary
private int dirMode
dirModeHasBeenSetback to summary
private boolean dirModeHasBeenSet
encodingback to summary
private String encoding
ERROR_DIR_AND_SRC_ATTRIBUTESback to summary
private static final String ERROR_DIR_AND_SRC_ATTRIBUTES
ERROR_PATH_AND_PREFIXback to summary
private static final String ERROR_PATH_AND_PREFIX
errorOnMissingArchiveback to summary
private boolean errorOnMissingArchive
fileModeback to summary
private int fileMode
fileModeHasBeenSetback to summary
private boolean fileModeHasBeenSet
fullpathback to summary
private String fullpath
hasDirback to summary
private boolean hasDir
prefixback to summary
private String prefix
srcback to summary
private Resource src

Constructor Detail

ArchiveFileSetback to summary
public ArchiveFileSet()

Constructor for ArchiveFileSet

ArchiveFileSetback to summary
protected ArchiveFileSet(FileSet fileset)

Constructor using a fileset argument.

Parameters
fileset:FileSet

the fileset to use

ArchiveFileSetback to summary
protected ArchiveFileSet(ArchiveFileSet fileset)

Constructor using a archive fileset argument.

Parameters
fileset:ArchiveFileSet

the archivefileset to use

Method Detail

addConfiguredback to summary
public void addConfigured(ResourceCollection a)

Set the source Archive file for the archivefileset. Prevents both "dir" and "src" from being specified.

Parameters
a:ResourceCollection

the archive as a single element Resource collection.

checkArchiveAttributesAllowedback to summary
private void checkArchiveAttributesAllowed()

A check attributes for archiveFileSet. If there is a reference, and it is a ArchiveFileSet, the archive fileset attributes cannot be used. (Note, we can only see if the reference is an archive fileset if the project has been set).

cloneback to summary
public Object clone()

Overrides org.apache.tools.ant.types.FileSet.clone.

Return a ArchiveFileSet that has the same properties as this one.

Returns:Object

the cloned archiveFileSet

Annotations
@Override
Since
Ant 1.6
configureFileSetback to summary
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:ArchiveFileSet

the project to use

dieOnCircularReferenceback to summary
protected synchronized void dieOnCircularReference(Stack<Object> stk, Project p) throws BuildException

Overrides org.apache.tools.ant.types.AbstractFileSet.dieOnCircularReference.

Doc from org.apache.tools.ant.types.DataType.dieOnCircularReference.

Check to see whether any DataType we hold references to is included in the Stack (which holds all DataType instances that directly or indirectly reference this instance, including this instance itself).

If one is included, throw a BuildException created by circularReference.

This implementation is appropriate only for a DataType that cannot hold other DataTypes as children.

The general contract of this method is that it shouldn't do anything if checked is true and set it to true on exit.

Parameters
stk:Stack<Object>

the stack of references to check.

p:Project

the project to use to dereference the references.

Annotations
@Override
Exceptions
BuildException:
on error.
getDirectoryScannerback to summary
public DirectoryScanner getDirectoryScanner(Project p)

Overrides org.apache.tools.ant.types.AbstractFileSet.getDirectoryScanner.

Return the DirectoryScanner associated with this FileSet. If the ArchiveFileSet defines a source Archive file, then an ArchiveScanner is returned instead.

Parameters
p:Project

the project to use

Returns:DirectoryScanner

a directory scanner

Annotations
@Override
getDirModeback to summary
public int getDirMode(Project p)

Get the dir mode of the archive fileset

Parameters
p:Project

the project to use

Returns:int

the mode

getDirModeback to summary
public int getDirMode()

Deprecated

since 1.7.

Returns:int

the dir mode.

Annotations
@Deprecated
getEncodingback to summary
public String getEncoding()

Get the encoding used for this ZipFileSet.

Returns:String

String encoding.

Since
Ant 1.9.5
getFileModeback to summary
public int getFileMode(Project p)

Get the mode of the archive fileset

Parameters
p:Project

the project to use

Returns:int

the mode

getFileModeback to summary
public int getFileMode()

Deprecated

since 1.7.

Returns:int

the file mode.

Annotations
@Deprecated
getFullpathback to summary
public String getFullpath(Project p)

Return the full pathname of the single entry in this fileset.

Parameters
p:Project

the project to use

Returns:String

the full path

getFullpathback to summary
public String getFullpath()

Deprecated

since 1.7.

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

Returns:String

the full pathname.

Annotations
@Deprecated
getPrefixback to summary
public String getPrefix(Project p)

Return the prefix prepended to entries in the archive file.

Parameters
p:Project

the project to use

Returns:String

the prefix

getPrefixback to summary
public String getPrefix()

Deprecated

since 1.7.

Return the prefix prepended to entries in the archive file.

Returns:String

the prefix.

Annotations
@Deprecated
getRefback to summary
protected AbstractFileSet getRef()

Hides org.apache.tools.ant.types.FileSet.getRef.

Performs the check for circular references and returns the referenced object. This method must be overridden together with getRef(Project) providing implementations containing the special support for FileSet references, which can be handled by all ArchiveFileSets. NB! This method cannot be implemented in AbstractFileSet in order to allow FileSet and DirSet to implement it as a private method.

Returns:AbstractFileSet

the dereferenced object.

Exceptions
BuildException:
if the reference is invalid (circular ref, wrong class, etc).
getSrcback to summary
public File getSrc(Project p)

Get the archive from which entries will be extracted.

Parameters
p:Project

the project to use

Returns:File

the source file

getSrcback to summary
public File getSrc()

Get the archive file from which entries will be extracted.

Returns:File

the archive in case the archive is a file, null otherwise.

hasDirModeBeenSetback to summary
public boolean hasDirModeBeenSet()

Whether the user has specified the mode explicitly.

Returns:boolean

true if it has been set

hasFileModeBeenSetback to summary
public boolean hasFileModeBeenSet()

Whether the user has specified the mode explicitly.

Returns:boolean

true if it has been set

integerSetDirModeback to summary
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:int

a int value

Since
Ant 1.7
integerSetFileModeback to summary
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:int

a int value

Since
Ant 1.7
isFilesystemOnlyback to summary
public boolean isFilesystemOnly()

Overrides org.apache.tools.ant.types.FileSet.isFilesystemOnly.

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

Returns:boolean

whether this is a filesystem-only resource collection.

Annotations
@Override
Since
Ant 1.7
iteratorback to summary
public Iterator<Resource> iterator()

Overrides org.apache.tools.ant.types.FileSet.iterator.

Implements java.lang.Iterable.iterator.

Fulfill the ResourceCollection contract.

Returns:Iterator<Resource>

Iterator of Resources.

Annotations
@Override
Since
Ant 1.7
newArchiveScannerback to summary
protected abstract ArchiveScanner newArchiveScanner()

Creates a scanner for this type of archive.

Returns:ArchiveScanner

the scanner.

setDirback to summary
public void setDir(File dir) throws BuildException

Overrides org.apache.tools.ant.types.AbstractFileSet.setDir.

Set the directory for the fileset.

Parameters
dir:File

the directory for the fileset

Annotations
@Override
Exceptions
BuildException:
on error
setDirModeback to summary
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:String

a String value

setEncodingback to summary
public void setEncoding(String enc)

Set the encoding used for this ZipFileSet.

Parameters
enc:String

encoding as String.

Since
Ant 1.9.5
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
setFileModeback to summary
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:String

a String value

setFullpathback to summary
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:String

the full pathname of the single entry in this fileset.

setPrefixback to summary
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:String

The prefix to prepend to entries in the archive file.

setSrcback to summary
public void setSrc(File srcFile)

Set the source Archive file for the archivefileset. Prevents both "dir" and "src" from being specified.

Parameters
srcFile:File

The archive from which to extract entries.

setSrcResourceback to summary
public void setSrcResource(Resource src)

Set the source Archive file for the archivefileset. Prevents both "dir" and "src" from being specified.

Parameters
src:Resource

The archive from which to extract entries.

sizeback to summary
public int size()

Overrides org.apache.tools.ant.types.FileSet.size.

Implements org.apache.tools.ant.types.ResourceCollection.size.

Fulfill the ResourceCollection contract.

Returns:int

size of the collection as int.

Annotations
@Override
Since
Ant 1.7
toStringback to summary
public String toString()

Overrides org.apache.tools.ant.types.AbstractFileSet.toString.

For file-based archivefilesets, return the same as for normal filesets; else just return the path of the zip.

Returns:String

for file based archivefilesets, included files as a list of semicolon-separated filenames. else just the name of the zip.

Annotations
@Override