org.apache.tools.ant.types.resources

Class ZipResource

Implemented Interfaces:
Cloneable, Comparable, ResourceCollection

public class ZipResource
extends ArchiveResource

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

Field Summary

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

MAGIC, UNKNOWN_DATETIME, UNKNOWN_SIZE

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

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

Method Summary

void
addConfigured(ResourceCollection a)
Sets the archive that holds this as a single element Resource collection.
protected void
fetchEntry()
fetches information from the named entry inside the archive.
String
getEncoding()
Get the encoding to use with the zipfile.
InputStream
getInputStream()
Return an InputStream for reading the contents of this Resource.
OutputStream
getOutputStream()
Get an OutputStream for the Resource.
File
getZipfile()
Get the zipfile that holds this ZipResource.
void
setEncoding(String enc)
Set the encoding to use with the zipfile.
void
setRefid(Reference r)
Overrides the super version.
void
setZipfile(File z)
Set the zipfile that holds this ZipResource.

Methods inherited from class org.apache.tools.ant.types.resources.ArchiveResource

addConfigured, compareTo, equals, fetchEntry, getArchive, getLastModified, getMode, getSize, hashCode, isDirectory, isExists, setArchive, setMode, setRefid, toString

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

clone, compareTo, equals, getInputStream, getLastModified, getMagicNumber, getName, getOutputStream, getSize, hashCode, isDirectory, isExists, isFilesystemOnly, iterator, setDirectory, setExists, setLastModified, setName, setRefid, setSize, size, toLongString, 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

Constructor Details

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 Details

addConfigured

public void addConfigured(ResourceCollection a)
Sets the archive that holds this as a single element Resource collection.
Overrides:
addConfigured in interface ArchiveResource
Parameters:
a - the archive as a single element Resource collection.

fetchEntry

protected void fetchEntry()
fetches information from the named entry inside the archive.
Overrides:
fetchEntry in interface ArchiveResource

getEncoding

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

getInputStream

public InputStream getInputStream()
            throws IOException
Return an InputStream for reading the contents of this Resource.
Overrides:
getInputStream in interface Resource
Returns:
an InputStream object.

getOutputStream

public OutputStream getOutputStream()
            throws IOException
Get an OutputStream for the Resource.
Overrides:
getOutputStream in interface Resource
Returns:
an OutputStream to which content can be written.

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.
Overrides:
setRefid in interface ArchiveResource
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.