Class ZipResource
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.types.DataType
org.apache.tools.ant.types.Resource
org.apache.tools.ant.types.resources.ArchiveResource
org.apache.tools.ant.types.resources.ZipResource
- All Implemented Interfaces:
Cloneable
,Comparable<Resource>
,Iterable<Resource>
,ResourceCollection
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.ProjectComponent
description, location, project
-
Constructor Summary
ConstructorDescriptionDefault constructor.ZipResource
(File z, String enc, ZipEntry e) Construct a ZipResource representing the specified entry in the specified zipfile. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Sets the archive that holds this as a single element Resource collection.protected void
fetches information from the named entry inside the archive.Get the encoding to use with the zipfile.Retrieves extra fields.Return an InputStream for reading the contents of this Resource.int
The compression method that has been used.Get an OutputStream for the Resource.protected ZipResource
getRef()
Perform the check for circular references and return the referenced Resource.static InputStream
getZipEntryStream
(ZipFile zipFile, String zipEntry) Return an InputStream for reading the contents of a ZipEntry with autoclose.Get the zipfile that holds this ZipResource.void
setEncoding
(String enc) Set the encoding to use with the zipfile.void
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
checkEntry, compareTo, dieOnCircularReference, equals, getArchive, getLastModified, getMode, getSize, hashCode, isDirectory, isExists, setArchive, setMode, toString
Methods inherited from class org.apache.tools.ant.types.Resource
as, asOptional, clone, getMagicNumber, getName, isFilesystemOnly, iterator, setDirectory, setExists, setLastModified, setName, setSize, size, toLongString
Methods inherited from class org.apache.tools.ant.types.DataType
checkAttributesAllowed, checkChildrenAllowed, circularReference, dieOnCircularReference, dieOnCircularReference, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getCheckedRef, getDataTypeName, getRefid, invokeCircularReferenceCheck, isChecked, isReference, noChildrenAllowed, pushAndInvokeCircularReferenceCheck, setChecked, tooManyAttributes
Methods inherited from class org.apache.tools.ant.ProjectComponent
getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface org.apache.tools.ant.types.ResourceCollection
isEmpty, stream
-
Constructor Details
-
ZipResource
public ZipResource()Default constructor. -
ZipResource
-
-
Method Details
-
setZipfile
Set the zipfile that holds this ZipResource.- Parameters:
z
- the zipfile as a File.
-
getZipfile
Get the zipfile that holds this ZipResource.- Returns:
- the zipfile as a File.
-
addConfigured
Sets the archive that holds this as a single element Resource collection.- Overrides:
addConfigured
in classArchiveResource
- Parameters:
a
- the archive as a single element Resource collection.
-
setEncoding
Set the encoding to use with the zipfile.- Parameters:
enc
- the String encoding.
-
getEncoding
-
setRefid
Overrides the super version.- Overrides:
setRefid
in classArchiveResource
- Parameters:
r
- the Reference to set.
-
getInputStream
Return an InputStream for reading the contents of this Resource.- Overrides:
getInputStream
in classResource
- Returns:
- an InputStream object.
- Throws:
IOException
- if the zip file cannot be opened, or the entry cannot be read.
-
getOutputStream
Get an OutputStream for the Resource.- Overrides:
getOutputStream
in classResource
- 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.
-
getExtraFields
Retrieves extra fields.- Returns:
- an array of the extra fields
- Since:
- Ant 1.8.0
-
getMethod
public int getMethod()The compression method that has been used.- Returns:
- int
- Since:
- Ant 1.8.0
-
getZipEntryStream
Return an InputStream for reading the contents of a ZipEntry with autoclose.- Parameters:
zipFile
- a org.apache.tools.zip.ZipFilezipEntry
- String a name of a zip entry- Returns:
- an InputStream object
- Throws:
IOException
- if the entry cannot be read
-
fetchEntry
protected void fetchEntry()fetches information from the named entry inside the archive.- Specified by:
fetchEntry
in classArchiveResource
-
getRef
Description copied from class:Resource
Perform the check for circular references and return the referenced Resource.- Overrides:
getRef
in classArchiveResource
- Returns:
Resource
.
-