ewe.zip
Class ZipInputStream

java.lang.Object
  extended byewe.util.Errorable
      extended byewe.io.BasicStreamObject
          extended byewe.io.StreamObject
              extended byewe.zip.ZipInputStream
All Implemented Interfaces:
BasicStream, Stream, Streamable, ZipConstants

public class ZipInputStream
extends StreamObject
implements ZipConstants

This is a FilterInputStream that reads the files in an zip archive one after another. It has a special method to get the zip entry of the next file. The zip entry contains information about the file name size, compressed size, CRC, etc. It includes support for STORED and DEFLATED entries.


Field Summary
 
Fields inherited from class ewe.io.StreamObject
napIterations, napTime, READWRITE_CLOSED, READWRITE_ERROR, READWRITE_WOULDBLOCK
 
Fields inherited from class ewe.io.BasicStreamObject
closed
 
Fields inherited from class ewe.util.Errorable
error
 
Fields inherited from interface ewe.zip.ZipConstants
C_COMPRESSED_SIZE, C_COMPRESSION_METHOD, C_CRC32, C_DISK_NUMBER_START, C_EXTERNAL_FILE_ATTRIBUTES, C_EXTRA_FIELD_LENGTH, C_FILE_COMMENT_LENGTH, C_FILENAME_LENGTH, C_GENERAL_PURPOSE_BIT_FLAG, C_HDR_SIG, C_INTERNAL_FILE_ATTRIBUTES, C_LAST_MOD_FILE_DATE, C_LAST_MOD_FILE_TIME, C_RELATIVE_OFFSET_LOCAL_HEADER, C_SIGNATURE, C_SIZE, C_UNCOMPRESSED_SIZE, C_VERSION_MADE_BY, C_VERSION_NEEDED_TO_EXTRACT, D_COMPRESSED_SIZE, D_CRC32, D_HDR_SIG, D_SIGNATURE, D_SIZE, D_UNCOMPRESSED_SIZE, EC_HDR_SIG, EC_NUM_DISK_WITH_START_CENTRAL_DIR, EC_NUM_ENTRIES_CENTRL_DIR_THS_DISK, EC_NUMBER_THIS_DISK, EC_OFFSET_START_CENTRAL_DIRECTORY, EC_SIGNATURE, EC_SIZE, EC_SIZE_CENTRAL_DIRECTORY, EC_TOTAL_ENTRIES_CENTRAL_DIR, EC_ZIPFILE_COMMENT_LENGTH, L_COMPRESSED_SIZE, L_COMPRESSION_METHOD, L_CRC32, L_EXTRA_FIELD_LENGTH, L_FILENAME_LENGTH, L_GENERAL_PURPOSE_BIT_FLAG, L_HDR_SIG, L_LAST_MOD_FILE_DATE, L_LAST_MOD_FILE_TIME, L_SIGNATURE, L_SIZE, L_UNCOMPRESSED_SIZE, L_VERSION_NEEDED_TO_EXTRACT, Z_BEST_COMPRESSION, Z_BEST_SPEED, Z_DEFAULT_COMPRESSION, Z_NO_COMPRESSION
 
Constructor Summary
ZipInputStream(BasicStream input)
          Creates a new Zip input stream, reading a zip archive.
 
Method Summary
 int available()
           
 void closeEntry()
          Closes the current zip entry and moves to the next one.
 boolean closeStream()
          Closes the zip file.
protected  ZipEntry createZipEntry(String name)
          Creates a new zip entry for the given name.
 boolean flushStream()
          This is non-blocking.
 ZipEntry getNextEntry()
          Open the next entry from the zip archive, and return its description.
 int nonBlockingRead(byte[] b, int off, int len)
          Reads a block of bytes from the current zip entry.
 
Methods inherited from class ewe.io.StreamObject
close, doRead, doWrite, flush, isOpen, nap, nap, nonBlockingWrite, read, readAByte, readBytes, readBytes, write, writeAByte, writeBytes, writeBytes
 
Methods inherited from class ewe.io.BasicStreamObject
getException, getName, read, read, throwIOException, toInputStream, toOutputStream, toStream, write, write
 
Methods inherited from class ewe.util.Errorable
returnError, returnError, returnError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, toString
 

Constructor Detail

ZipInputStream

public ZipInputStream(BasicStream input)
Creates a new Zip input stream, reading a zip archive.

Method Detail

getNextEntry

public ZipEntry getNextEntry()
Open the next entry from the zip archive, and return its description. If the previous entry wasn't closed, this method will close it.


closeEntry

public void closeEntry()
Closes the current zip entry and moves to the next one.


available

public int available()

nonBlockingRead

public int nonBlockingRead(byte[] b,
                           int off,
                           int len)
Reads a block of bytes from the current zip entry.

Specified by:
nonBlockingRead in interface BasicStream
Overrides:
nonBlockingRead in class StreamObject
Parameters:
b - Destination byte array to hold incoming data.
off - Starting index in buff for incoming data.
len - Maximum number of bytes to read - should never be zero.
Returns:
the number of bytes read (may be smaller, even before EOF), or -1 on EOF.
Throws:
IOException - if a i/o error occured.
ZipException - if the deflated stream is corrupted.

closeStream

public boolean closeStream()
                    throws IOException
Closes the zip file.

Specified by:
closeStream in interface BasicStream
Overrides:
closeStream in class StreamObject
Throws:
IOException - if a i/o error occured.

createZipEntry

protected ZipEntry createZipEntry(String name)
Creates a new zip entry for the given name. This is equivalent to new ZipEntry(name).

Parameters:
name - the name of the zip entry.

flushStream

public boolean flushStream()
                    throws IOException
Description copied from interface: BasicStream
This is non-blocking. It returns true if the flush completed, false if it did not, or throws an exception on error.

Specified by:
flushStream in interface BasicStream
Throws:
IOException