ewe.zip
Class DeflaterOutputStream

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

public class DeflaterOutputStream
extends StreamObject
implements ZipConstants, OverridesClose


Field Summary
protected  ByteArray byteIn
           
protected  ByteArray byteOut
           
 int inputBytes
          The number of bytes written to the deflater.
protected  BasicStream output
           
 int outputBytes
          The number of bytes writeen out by the deflater.
protected  Object reserved
          Don't use this.
protected static int Z_BUF_ERROR
           
protected static int Z_DATA_ERROR
           
protected static int Z_ERRNO
           
protected static int Z_MEM_ERROR
           
protected static int Z_NEED_DICT
           
protected static int Z_OK
           
protected static int Z_STREAM_END
           
protected static int Z_STREAM_ERROR
           
protected static int Z_VERSION_ERROR
           
 
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
DeflaterOutputStream(BasicStream output)
           
DeflaterOutputStream(BasicStream output, int level)
           
DeflaterOutputStream(BasicStream output, int level, boolean noWrap)
           
DeflaterOutputStream(OutputStream output)
           
DeflaterOutputStream(OutputStream output, int level, boolean noWrap)
           
 
Method Summary
 boolean close()
          Closes the stream.
protected  int deflate(ByteArray in, ByteArray out, boolean done)
           
protected  int deflateEnd()
           
protected  int deflateInit(int level, boolean noWrap)
           
 boolean flushStream()
          This is non-blocking.
 int nonBlockingWrite(byte[] buff, int start, int count)
          This is the non-blocking write operation.
 void setBufferSize(int size)
          Don't call this after starting to write output!
 
Methods inherited from class ewe.io.StreamObject
closeStream, doRead, doWrite, flush, isOpen, nap, nap, nonBlockingRead, 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
 

Field Detail

reserved

protected Object reserved
Don't use this. It is a placeholder for a native resource.


byteIn

protected ByteArray byteIn

byteOut

protected ByteArray byteOut

output

protected BasicStream output

inputBytes

public int inputBytes
The number of bytes written to the deflater.


outputBytes

public int outputBytes
The number of bytes writeen out by the deflater.


Z_OK

protected static final int Z_OK
See Also:
Constant Field Values

Z_STREAM_END

protected static final int Z_STREAM_END
See Also:
Constant Field Values

Z_NEED_DICT

protected static final int Z_NEED_DICT
See Also:
Constant Field Values

Z_ERRNO

protected static final int Z_ERRNO
See Also:
Constant Field Values

Z_STREAM_ERROR

protected static final int Z_STREAM_ERROR
See Also:
Constant Field Values

Z_DATA_ERROR

protected static final int Z_DATA_ERROR
See Also:
Constant Field Values

Z_MEM_ERROR

protected static final int Z_MEM_ERROR
See Also:
Constant Field Values

Z_BUF_ERROR

protected static final int Z_BUF_ERROR
See Also:
Constant Field Values

Z_VERSION_ERROR

protected static final int Z_VERSION_ERROR
See Also:
Constant Field Values
Constructor Detail

DeflaterOutputStream

public DeflaterOutputStream(BasicStream output)

DeflaterOutputStream

public DeflaterOutputStream(BasicStream output,
                            int level)

DeflaterOutputStream

public DeflaterOutputStream(BasicStream output,
                            int level,
                            boolean noWrap)

DeflaterOutputStream

public DeflaterOutputStream(OutputStream output)

DeflaterOutputStream

public DeflaterOutputStream(OutputStream output,
                            int level,
                            boolean noWrap)
Method Detail

setBufferSize

public void setBufferSize(int size)
Don't call this after starting to write output!


deflateInit

protected int deflateInit(int level,
                          boolean noWrap)

deflate

protected int deflate(ByteArray in,
                      ByteArray out,
                      boolean done)

deflateEnd

protected int deflateEnd()

close

public boolean close()
Description copied from interface: BasicStream
Closes the stream. Returns true if the operation is successful and false otherwise.

Specified by:
close in interface BasicStream
Overrides:
close in class StreamObject

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

nonBlockingWrite

public int nonBlockingWrite(byte[] buff,
                            int start,
                            int count)
Description copied from class: StreamObject
This is the non-blocking write operation. It should never attempt to wait() or sleep() in a Coroutine. It should return as quickly as possible. This makes it safe to be called from within a native method.

The default StreamObject implementation of this uses the single byte write() method.

Specified by:
nonBlockingWrite in interface BasicStream
Overrides:
nonBlockingWrite in class StreamObject
Parameters:
buff - Source byte array holding data to be written.
start - Starting index in buff for data to be written.
count - Number of bytes to write - should never be zero.
Returns:
greater than 0 = Number of bytes actually written.
0 = No bytes could be written yet - but the stream is still open.
-1 = Stream has been closed - no further writes are possible.
-2 = IO error - something went wrong.
Note that these values are different to the Stream.writeBytes method.