TrueZIP 6.8

de.schlichtherle.io.archive.zip
Class ZipInputArchive

java.lang.Object
  extended by de.schlichtherle.util.zip.BasicZipFile
      extended by de.schlichtherle.io.archive.zip.ZipInputArchive
All Implemented Interfaces:
InputArchive
Direct Known Subclasses:
CheckedZipInputArchive, JarInputArchive, Zip32InputArchive

public class ZipInputArchive
extends BasicZipFile
implements InputArchive

An implementation of InputArchive to read ZIP archives.

Since:
TrueZIP 6.7
Version:
$Id: ZipInputArchive.java,v 1.3 2010/08/16 10:55:44 christian_schlichtherle Exp $
Author:
Christian Schlichtherle
See Also:
ZipDriver

Field Summary
 
Fields inherited from class de.schlichtherle.util.zip.BasicZipFile
DEFAULT_CHARSET
 
Constructor Summary
ZipInputArchive(ReadOnlyFile rof, String charset, boolean preambled, boolean postambled)
           
 
Method Summary
protected  ZipEntry createZipEntry(String entryName)
          A factory method returning a newly created ZipEntry for the given name.
 Enumeration getArchiveEntries()
          Returns an enumeration of the ArchiveEntry instances in this archive.
 ArchiveEntry getArchiveEntry(String entryName)
          Returns the ArchiveEntry for the given entry name or null if no entry with this name exists.
 InputStream getInputStream(ArchiveEntry entry, ArchiveEntry dstEntry)
          Returns a new InputStream for reading the contents of the given archive entry.
 InputArchiveMetaData getMetaData()
          Returns the meta data for this input archive.
 int getNumArchiveEntries()
          Returns the number of ArchiveEntry instances in this archive.
 void setMetaData(InputArchiveMetaData metaData)
          Sets the meta data for this input archive.
 
Methods inherited from class de.schlichtherle.util.zip.BasicZipFile
busy, close, createReadOnlyFile, entries, getCharset, getCheckedInputStream, getCheckedInputStream, getComment, getEntry, getInputStream, getInputStream, getInputStream, getInputStream, getInputStream, getPostambleInputStream, getPostambleLength, getPreambleInputStream, getPreambleLength, length, offsetsConsiderPreamble, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.schlichtherle.io.archive.spi.InputArchive
close
 

Constructor Detail

ZipInputArchive

public ZipInputArchive(ReadOnlyFile rof,
                       String charset,
                       boolean preambled,
                       boolean postambled)
                throws NullPointerException,
                       UnsupportedEncodingException,
                       FileNotFoundException,
                       ZipException,
                       IOException
Throws:
NullPointerException
UnsupportedEncodingException
FileNotFoundException
ZipException
IOException
Method Detail

createZipEntry

protected ZipEntry createZipEntry(String entryName)
Description copied from class: BasicZipFile
A factory method returning a newly created ZipEntry for the given name.

Overrides:
createZipEntry in class BasicZipFile

getNumArchiveEntries

public int getNumArchiveEntries()
Description copied from interface: InputArchive
Returns the number of ArchiveEntry instances in this archive.

Specified by:
getNumArchiveEntries in interface InputArchive

getArchiveEntries

public Enumeration getArchiveEntries()
Description copied from interface: InputArchive
Returns an enumeration of the ArchiveEntry instances in this archive.

Specified by:
getArchiveEntries in interface InputArchive

getArchiveEntry

public ArchiveEntry getArchiveEntry(String entryName)
Description copied from interface: InputArchive
Returns the ArchiveEntry for the given entry name or null if no entry with this name exists.

Specified by:
getArchiveEntry in interface InputArchive
Parameters:
entryName - A valid archive entry name - never null.
See Also:
Requirements for Archive Entry Names

getInputStream

public InputStream getInputStream(ArchiveEntry entry,
                                  ArchiveEntry dstEntry)
                           throws IOException
Description copied from interface: InputArchive
Returns a new InputStream for reading the contents of the given archive entry.

The returned stream should preferrably be unbuffered, as buffering is usually done in higher layers (all copy routines in TrueZIP do this and most client applications do it, too). Buffering twice does not increase, but decrease performance.

Note that the stream is guaranteed to be closed before the InputArchive.close() method of this archive is called!

Specified by:
getInputStream in interface InputArchive
Parameters:
entry - A valid reference to an archive entry. The runtime class of this entry is the same as the runtime class of the entries returned by InputArchive.getArchiveEntries().
dstEntry - If not null, this identifies the entry to which TrueZIP is actually copying data to and should be used to implement the Direct Data Copying (DDC) feature. Note that there is no guarantee on the runtime type of this object; it may have been created by other drivers.

For example, the ZIP driver family uses this to determine if data should be provided in its deflated form if the destination entry is another ZIP file entry.

Returns:
A (preferrably unbuffered) InputStream to read the archive entry data from. null is not allowed!
Throws:
InputArchiveBusyException - If the archive is currently busy on input for another entry. This exception is guaranteed to be recoverable, meaning it should be possible to read the same entry again as soon as the archive is not busy on input anymore.
FileNotFoundException - If the archive entry does not exist or is not accessible for some reason.
IOException - On any other exceptional condition.

getMetaData

public InputArchiveMetaData getMetaData()
Description copied from interface: InputArchive
Returns the meta data for this input archive. The default value is null.

Specified by:
getMetaData in interface InputArchive

setMetaData

public void setMetaData(InputArchiveMetaData metaData)
Description copied from interface: InputArchive
Sets the meta data for this input archive.

Specified by:
setMetaData in interface InputArchive
Parameters:
metaData - The meta data - may not be null.

TrueZIP 6.8

Copyright © 2005-2010 Schlichtherle IT Services. All Rights Reserved.