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

public Class Expand

extends Task
Class Inheritance
Known Direct Subclasses
org.apache.tools.ant.taskdefs.Untar
Imports
java.io.File, .FileNotFoundException, .IOException, .InputStream, .OutputStream, java.nio.file.Files, java.util.Date, .Enumeration, .HashSet, .List, .Set, .Vector, org.apache.tools.ant.BuildException, .Project, .Task, org.apache.tools.ant.types.FileSet, .Mapper, .PatternSet, .Resource, .ResourceCollection, org.apache.tools.ant.types.resources.FileProvider, .Union, org.apache.tools.ant.types.selectors.SelectorUtils, org.apache.tools.ant.util.FileNameMapper, .FileUtils, .IdentityMapper, org.apache.tools.zip.ZipEntry, .ZipFile

Unzip a file.
Since
Ant 1.1

Field Summary

Modifier and TypeField and Description
private Boolean
private static final int
private File
private String
public static final String
ERROR_MULTIPLE_MAPPERS

Error message when more that one mapper is defined

private boolean
private static final FileUtils
private Mapper
public static final String
private boolean
private List<PatternSet>
private Union
private boolean
private boolean
private File
private boolean
Inherited from org.apache.tools.ant.Task:
targettaskNametaskTypewrapper

Constructor Summary

AccessConstructor and Description
public
Expand()

Creates an Expand instance and sets encoding to UTF-8.

protected
Expand(String
String
encoding
)

Creates an Expand instance and sets the given encoding.

Method Summary

Modifier and TypeMethod and Description
public void
add(ResourceCollection
a resource collection.
rc
)

Add a resource collection.

public void
add(FileNameMapper
the mapper to add
fileNameMapper
)

A nested filenamemapper

public void
addFileset(FileSet
a file set
set
)

Add a fileset

public void
addPatternset(PatternSet
a pattern set
set
)

Add a patternset.

public Mapper

Returns:

a mapper to be configured
createMapper
()

Defines the mapper to map source entries to destination files.

public void
execute()

Overrides org.apache.tools.ant.Task.execute.

Do the work.
protected void
expandFile(FileUtils
the fileUtils
fileUtils
,
File
the source file
srcF
,
File
the destination directory
dir
)

This method is to be overridden by extending unarchival tasks.

protected void
expandResource(Resource
the source resource
srcR
,
File
the destination directory
dir
)

This method is to be overridden by extending unarchival tasks.

protected void
extractFile(FileUtils
a fileUtils object
fileUtils
,
File
the source file
srcF
,
File
the destination directory
dir
,
InputStream
the input stream
compressedInputStream
,
String
the name of the entry
entryName
,
Date
the date of the entry
entryDate
,
boolean
if this is true the entry is a directory
isDirectory
,
FileNameMapper
the filename mapper to use
mapper
)

extract a file to a directory

public Boolean

Returns:

null if the flag hasn't been set explicitly, otherwise the value set by the user.
getAllowFilesToEscapeDest
()

Whether to allow the extracted file or directory to be outside of the dest directory.

public String

Returns:

String
getEncoding
()

public boolean

Returns:

boolean
getFailOnEmptyArchive
()

Whether try ing to expand an empty archive would be an error.

protected FileNameMapper

Returns:

a filenamemapper for a file
getMapper
()

get a mapper for a file

public boolean

Returns:

boolean
getScanForUnicodeExtraFields
()

protected void
internalSetEncoding(String
String
encoding
)

Supports grand-children that want to support the attribute where the child-class doesn't (i.e. Unzip in the compress Antlib).

protected void
internalSetScanForUnicodeExtraFields(boolean
boolean
b
)

Supports grand-children that want to support the attribute where the child-class doesn't (i.e. Unzip in the compress Antlib).

public void
setAllowFilesToEscapeDest(boolean
the flag
b
)

Whether to allow the extracted file or directory to be outside of the dest directory.

public void
setDest(File
Path to the directory.
d
)

Set the destination directory.

public void
setEncoding(String
the name of the character encoding
encoding
)

Sets the encoding to assume for file names and comments.

public void
setFailOnEmptyArchive(boolean
boolean
b
)

Whether try ing to expand an empty archive would be an error.

public void
setOverwrite(boolean
a boolean value
b
)

Should we overwrite files in dest, even if they are newer than the corresponding entries in the archive?

public void
setScanForUnicodeExtraFields(boolean
boolean
b
)

Whether unicode extra fields will be used if present.

public void
setSrc(File
Path to zip-file.
s
)

Set the path to zip-file.

public void
setStripAbsolutePathSpec(boolean
boolean
b
)

Whether leading path separators should be stripped.

Inherited from org.apache.tools.ant.Task:
bindToOwnergetOwningTargetgetRuntimeConfigurableWrappergetTaskNamegetTaskTypegetWrapperhandleErrorFlushhandleErrorOutputhandleFlushhandleInputhandleOutputinitisInvalidloglogloglogmaybeConfigureperformreconfiguresetOwningTargetsetRuntimeConfigurableWrappersetTaskNamesetTaskType

Field Detail

allowFilesToEscapeDestback to summary
private Boolean allowFilesToEscapeDest
BUFFER_SIZEback to summary
private static final int BUFFER_SIZE
destback to summary
private File dest
encodingback to summary
private String encoding
ERROR_MULTIPLE_MAPPERSback to summary
public static final String ERROR_MULTIPLE_MAPPERS

Error message when more that one mapper is defined

failOnEmptyArchiveback to summary
private boolean failOnEmptyArchive
FILE_UTILSback to summary
private static final FileUtils FILE_UTILS
mapperElementback to summary
private Mapper mapperElement
NATIVE_ENCODINGback to summary
public static final String NATIVE_ENCODING
overwriteback to summary
private boolean overwrite
patternsetsback to summary
private List<PatternSet> patternsets
resourcesback to summary
private Union resources
resourcesSpecifiedback to summary
private boolean resourcesSpecified
scanForUnicodeExtraFieldsback to summary
private boolean scanForUnicodeExtraFields
sourceback to summary
private File source
stripAbsolutePathSpecback to summary
private boolean stripAbsolutePathSpec

Constructor Detail

Expandback to summary
public Expand()

Creates an Expand instance and sets encoding to UTF-8.

Expandback to summary
protected Expand(String encoding)

Creates an Expand instance and sets the given encoding.

Parameters
encoding:String

String

Since
Ant 1.9.5

Method Detail

addback to summary
public void add(ResourceCollection rc)

Add a resource collection.

Parameters
rc:ResourceCollection

a resource collection.

Since
Ant 1.7
addback to summary
public void add(FileNameMapper fileNameMapper)

A nested filenamemapper

Parameters
fileNameMapper:FileNameMapper

the mapper to add

Since
Ant 1.6.3
addFilesetback to summary
public void addFileset(FileSet set)

Add a fileset

Parameters
set:FileSet

a file set

addPatternsetback to summary
public void addPatternset(PatternSet set)

Add a patternset.

Parameters
set:PatternSet

a pattern set

createMapperback to summary
public Mapper createMapper() throws BuildException

Defines the mapper to map source entries to destination files.

Returns:Mapper

a mapper to be configured

Exceptions
BuildException:
if more than one mapper is defined
Since
Ant1.7
executeback to summary
public void execute() throws BuildException

Overrides org.apache.tools.ant.Task.execute.

Do the work.

Annotations
@Override
Exceptions
BuildException:
Thrown in unrecoverable error.
expandFileback to summary
protected void expandFile(FileUtils fileUtils, File srcF, File dir)

This method is to be overridden by extending unarchival tasks.

Parameters
fileUtils:FileUtils

the fileUtils

srcF:File

the source file

dir:File

the destination directory

expandResourceback to summary
protected void expandResource(Resource srcR, File dir)

This method is to be overridden by extending unarchival tasks.

Parameters
srcR:Resource

the source resource

dir:File

the destination directory

extractFileback to summary
protected void extractFile(FileUtils fileUtils, File srcF, File dir, InputStream compressedInputStream, String entryName, Date entryDate, boolean isDirectory, FileNameMapper mapper) throws IOException

extract a file to a directory

Parameters
fileUtils:FileUtils

a fileUtils object

srcF:File

the source file

dir:File

the destination directory

compressedInputStream:InputStream

the input stream

entryName:String

the name of the entry

entryDate:Date

the date of the entry

isDirectory:boolean

if this is true the entry is a directory

mapper:FileNameMapper

the filename mapper to use

Exceptions
IOException:
on error
getAllowFilesToEscapeDestback to summary
public Boolean getAllowFilesToEscapeDest()

Whether to allow the extracted file or directory to be outside of the dest directory.

Returns:Boolean

null if the flag hasn't been set explicitly, otherwise the value set by the user.

Since
Ant 1.10.4
getEncodingback to summary
public String getEncoding()
Returns:String

String

Since
Ant 1.8.0
getFailOnEmptyArchiveback to summary
public boolean getFailOnEmptyArchive()

Whether try ing to expand an empty archive would be an error.

Returns:boolean

boolean

Since
Ant 1.8.0
getMapperback to summary
protected FileNameMapper getMapper()

get a mapper for a file

Returns:FileNameMapper

a filenamemapper for a file

getScanForUnicodeExtraFieldsback to summary
public boolean getScanForUnicodeExtraFields()
Returns:boolean

boolean

Since
Ant 1.8.0
internalSetEncodingback to summary
protected void internalSetEncoding(String encoding)

Supports grand-children that want to support the attribute where the child-class doesn't (i.e. Unzip in the compress Antlib).

Parameters
encoding:String

String

Since
Ant 1.8.0
internalSetScanForUnicodeExtraFieldsback to summary
protected void internalSetScanForUnicodeExtraFields(boolean b)

Supports grand-children that want to support the attribute where the child-class doesn't (i.e. Unzip in the compress Antlib).

Parameters
b:boolean

boolean

Since
Ant 1.8.0
setAllowFilesToEscapeDestback to summary
public void setAllowFilesToEscapeDest(boolean b)

Whether to allow the extracted file or directory to be outside of the dest directory.

Parameters
b:boolean

the flag

Since
Ant 1.10.4
setDestback to summary
public void setDest(File d)

Set the destination directory. File will be unzipped into the destination directory.

Parameters
d:File

Path to the directory.

setEncodingback to summary
public void setEncoding(String encoding)

Sets the encoding to assume for file names and comments.

Set to native-encoding if you want your platform's native encoding, defaults to UTF8.

Parameters
encoding:String

the name of the character encoding

Since
Ant 1.6
setFailOnEmptyArchiveback to summary
public void setFailOnEmptyArchive(boolean b)

Whether try ing to expand an empty archive would be an error.

Parameters
b:boolean

boolean

Since
Ant 1.8.0
setOverwriteback to summary
public void setOverwrite(boolean b)

Should we overwrite files in dest, even if they are newer than the corresponding entries in the archive?

Parameters
b:boolean

a boolean value

setScanForUnicodeExtraFieldsback to summary
public void setScanForUnicodeExtraFields(boolean b)

Whether unicode extra fields will be used if present.

Parameters
b:boolean

boolean

Since
Ant 1.8.0
setSrcback to summary
public void setSrc(File s)

Set the path to zip-file.

Parameters
s:File

Path to zip-file.

setStripAbsolutePathSpecback to summary
public void setStripAbsolutePathSpec(boolean b)

Whether leading path separators should be stripped.

Parameters
b:boolean

boolean

Since
Ant 1.8.0