org.apache.tools.ant.types.resources

Class ZipResource

public class ZipResource extends ArchiveResource

A Resource representation of an entry in a zipfile.

Since: Ant 1.7

Constructor Summary
ZipResource()
Default constructor.
ZipResource(File z, String enc, ZipEntry e)
Construct a ZipResource representing the specified entry in the specified zipfile.
Method Summary
voidaddConfigured(ResourceCollection a)
Sets the archive that holds this as a single element Resource collection.
protected voidfetchEntry()
fetches information from the named entry inside the archive.
StringgetEncoding()
Get the encoding to use with the zipfile.
ZipExtraField[]getExtraFields()
Retrieves extra fields.
InputStreamgetInputStream()
Return an InputStream for reading the contents of this Resource.
intgetMethod()
The compression method that has been used.
OutputStreamgetOutputStream()
Get an OutputStream for the Resource.
FilegetZipfile()
Get the zipfile that holds this ZipResource.
voidsetEncoding(String enc)
Set the encoding to use with the zipfile.
voidsetRefid(Reference r)
Overrides the super version.
voidsetZipfile(File z)
Set the zipfile that holds this ZipResource.

Constructor Detail

ZipResource

public ZipResource()
Default constructor.

ZipResource

public ZipResource(File z, String enc, ZipEntry e)
Construct a ZipResource representing the specified entry in the specified zipfile.

Parameters: z the zipfile as File. enc the encoding used for filenames. e the ZipEntry.

Method Detail

addConfigured

public void addConfigured(ResourceCollection a)
Sets the archive that holds this as a single element Resource collection.

Parameters: a the archive as a single element Resource collection.

fetchEntry

protected void fetchEntry()
fetches information from the named entry inside the archive.

getEncoding

public String getEncoding()
Get the encoding to use with the zipfile.

Returns: String encoding.

getExtraFields

public ZipExtraField[] getExtraFields()
Retrieves extra fields.

Returns: an array of the extra fields

Since: Ant 1.8.0

getInputStream

public InputStream getInputStream()
Return an InputStream for reading the contents of this Resource.

Returns: an InputStream object.

Throws: IOException if the zip file cannot be opened, or the entry cannot be read.

getMethod

public int getMethod()
The compression method that has been used.

Since: Ant 1.8.0

getOutputStream

public OutputStream getOutputStream()
Get an OutputStream for the Resource.

Returns: an OutputStream to which content can be written.

Throws: IOException if unable to provide the content of this Resource as a stream. UnsupportedOperationException if OutputStreams are not supported for this Resource type.

getZipfile

public File getZipfile()
Get the zipfile that holds this ZipResource.

Returns: the zipfile as a File.

setEncoding

public void setEncoding(String enc)
Set the encoding to use with the zipfile.

Parameters: enc the String encoding.

setRefid

public void setRefid(Reference r)
Overrides the super version.

Parameters: r the Reference to set.

setZipfile

public void setZipfile(File z)
Set the zipfile that holds this ZipResource.

Parameters: z the zipfile as a File.