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

public Class ZipResource

extends ArchiveResource
Class Inheritance
Imports
java.io.File, .FilterInputStream, .IOException, .InputStream, .OutputStream, org.apache.tools.ant.BuildException, .Project, org.apache.tools.ant.types.Reference, .ResourceCollection, org.apache.tools.ant.util.FileUtils, org.apache.tools.zip.ZipEntry, .ZipExtraField, .ZipFile

A Resource representation of an entry in a zipfile.
Since
Ant 1.7

Field Summary

Modifier and TypeField and Description
private String
private ZipExtraField[]
private int

Constructor Summary

AccessConstructor and Description
public
ZipResource()

Default constructor.

public
ZipResource(File
the zipfile as File.
z
,
String
the encoding used for filenames.
enc
,
ZipEntry
the ZipEntry.
e
)

Construct a ZipResource representing the specified entry in the specified zipfile.

Method Summary

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

Overrides org.apache.tools.ant.types.resources.ArchiveResource.addConfigured.

Sets the archive that holds this as a single element Resource collection.
protected void
fetchEntry()

Implements abstract org.apache.tools.ant.types.resources.ArchiveResource.fetchEntry.

fetches information from the named entry inside the archive.
public String

Returns:

String encoding.
getEncoding
()

Get the encoding to use with the zipfile.

public ZipExtraField[]

Returns:

an array of the extra fields
getExtraFields
()

Retrieves extra fields.

public InputStream

Returns:

an InputStream object.
getInputStream
()

Overrides org.apache.tools.ant.types.Resource.getInputStream.

Return an InputStream for reading the contents of this Resource.
public int

Returns:

int
getMethod
()

The compression method that has been used.

public OutputStream

Returns:

an OutputStream to which content can be written.
getOutputStream
()

Overrides org.apache.tools.ant.types.Resource.getOutputStream.

Get an OutputStream for the Resource.
protected ZipResource
getRef()

Overrides org.apache.tools.ant.types.resources.ArchiveResource.getRef.

Perform the check for circular references and return the referenced Resource.
public static InputStream

Returns:

an InputStream object
getZipEntryStream
(ZipFile
a org.apache.tools.zip.ZipFile
zipFile
,
String
String a name of a zip entry
zipEntry
)

Return an InputStream for reading the contents of a ZipEntry with autoclose.

public File

Returns:

the zipfile as a File.
getZipfile
()

Get the zipfile that holds this ZipResource.

public void
setEncoding(String
the String encoding.
enc
)

Set the encoding to use with the zipfile.

private void
public void
setRefid(Reference
the Reference to set.
r
)

Overrides org.apache.tools.ant.types.resources.ArchiveResource.setRefid.

Overrides the super version.
public void
setZipfile(File
the zipfile as a File.
z
)

Set the zipfile that holds this ZipResource.

Inherited from org.apache.tools.ant.types.resources.ArchiveResource:
checkEntrycompareTodieOnCircularReferenceequalsgetArchivegetLastModifiedgetModegetSizehashCodeisDirectoryisExistssetArchivesetModetoString

Field Detail

encodingback to summary
private String encoding
extrasback to summary
private ZipExtraField[] extras
methodback to summary
private int method

Constructor Detail

ZipResourceback to summary
public ZipResource()

Default constructor.

ZipResourceback to summary
public ZipResource(File z, String enc, ZipEntry e)

Construct a ZipResource representing the specified entry in the specified zipfile.

Parameters
z:File

the zipfile as File.

enc:String

the encoding used for filenames.

e:ZipEntry

the ZipEntry.

Method Detail

addConfiguredback to summary
public void addConfigured(ResourceCollection a)

Overrides org.apache.tools.ant.types.resources.ArchiveResource.addConfigured.

Sets the archive that holds this as a single element Resource collection.

Parameters
a:ResourceCollection

the archive as a single element Resource collection.

fetchEntryback to summary
protected void fetchEntry()

Implements abstract org.apache.tools.ant.types.resources.ArchiveResource.fetchEntry.

fetches information from the named entry inside the archive.

getEncodingback to summary
public String getEncoding()

Get the encoding to use with the zipfile.

Returns:String

String encoding.

getExtraFieldsback to summary
public ZipExtraField[] getExtraFields()

Retrieves extra fields.

Returns:ZipExtraField[]

an array of the extra fields

Since
Ant 1.8.0
getInputStreamback to summary
public InputStream getInputStream() throws IOException

Overrides org.apache.tools.ant.types.Resource.getInputStream.

Return an InputStream for reading the contents of this Resource.

Returns:InputStream

an InputStream object.

Exceptions
IOException:
if the zip file cannot be opened, or the entry cannot be read.
getMethodback to summary
public int getMethod()

The compression method that has been used.

Returns:int

int

Since
Ant 1.8.0
getOutputStreamback to summary
public OutputStream getOutputStream() throws IOException

Overrides org.apache.tools.ant.types.Resource.getOutputStream.

Get an OutputStream for the Resource.

Returns:OutputStream

an OutputStream to which content can be written.

Exceptions
IOException:
if unable to provide the content of this Resource as a stream.
UnsupportedOperationException:
if OutputStreams are not supported for this Resource type.
getRefback to summary
protected ZipResource getRef()

Overrides org.apache.tools.ant.types.resources.ArchiveResource.getRef.

Doc from org.apache.tools.ant.types.Resource.getRef.

Perform the check for circular references and return the referenced Resource.

Returns:ZipResource

Resource.

Annotations
@Override
getZipEntryStreamback to summary
public static InputStream getZipEntryStream(ZipFile zipFile, String zipEntry) throws IOException

Return an InputStream for reading the contents of a ZipEntry with autoclose.

Parameters
zipFile:ZipFile

a org.apache.tools.zip.ZipFile

zipEntry:String

String a name of a zip entry

Returns:InputStream

an InputStream object

Exceptions
IOException:
if the entry cannot be read
getZipfileback to summary
public File getZipfile()

Get the zipfile that holds this ZipResource.

Returns:File

the zipfile as a File.

setEncodingback to summary
public void setEncoding(String enc)

Set the encoding to use with the zipfile.

Parameters
enc:String

the String encoding.

setEntryback to summary
private void setEntry(ZipEntry e)
setRefidback to summary
public void setRefid(Reference r)

Overrides org.apache.tools.ant.types.resources.ArchiveResource.setRefid.

Overrides the super version.

Parameters
r:Reference

the Reference to set.

setZipfileback to summary
public void setZipfile(File z)

Set the zipfile that holds this ZipResource.

Parameters
z:File

the zipfile as a File.