com.mucommander.file.impl.zip.provider
Class ZipEntryOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.mucommander.file.impl.zip.provider.ZipEntryOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable
Direct Known Subclasses:
DeflatedOutputStream, StoredOutputStream

public abstract class ZipEntryOutputStream
extends java.io.OutputStream

ZipEntryOutputStream is an abstract OutputStream used for compressing a Zip entry's data to an underlying OutputStream.

The CRC32 checksum is calculated on-the-fly as data gets written to the stream, getCrc() returns the current checksum value. The getTotalIn() and getTotalOut() methods keep track of the uncompressed and compressed of the supplied data.

There currently are two implementations of this class:

--------------------------------------------------------------------------------------------------------------

This class is based off the org.apache.tools.zip package of the Apache Ant project. The Ant code has been modified under the terms of the Apache License which you can find in the bundled muCommander license file. It was forked at version 1.7.0 of Ant.

Author:
Maxence Bernard

Field Summary
protected  java.util.zip.CRC32 crc
          The CRC32 instance that calculates the checksum
protected  int method
          Compression method (DEFLATED or STORED)
protected  java.io.OutputStream out
          The underlying stream where the compressed data is sent
 
Constructor Summary
ZipEntryOutputStream(java.io.OutputStream out, int method)
          Creates a new EntryOutputStream that writes compressed data to the given OutputStream and automatically updates the supplied CRC32 checksum.
 
Method Summary
 void flush()
          Flushes the underlying OutputStream.
 long getCrc()
          Returns the CRC value of the data written so far.
 int getMethod()
          Returns the compression method used for writing the supplied data.
abstract  int getTotalIn()
          Returns the uncompressed size of the data written so far.
abstract  int getTotalOut()
          Returns the compressed size of the data written so far.
 void write(int b)
           
 
Methods inherited from class java.io.OutputStream
close, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

out

protected java.io.OutputStream out
The underlying stream where the compressed data is sent


method

protected int method
Compression method (DEFLATED or STORED)


crc

protected java.util.zip.CRC32 crc
The CRC32 instance that calculates the checksum

Constructor Detail

ZipEntryOutputStream

public ZipEntryOutputStream(java.io.OutputStream out,
                            int method)
Creates a new EntryOutputStream that writes compressed data to the given OutputStream and automatically updates the supplied CRC32 checksum.

Parameters:
out - the OutputStream where the compressed data is sent to
method - the compression method, ZipConstants.DEFLATED or ZipConstants.STORED
Method Detail

getMethod

public int getMethod()
Returns the compression method used for writing the supplied data.

Returns:
the compression method used for writing the supplied data

getCrc

public long getCrc()
Returns the CRC value of the data written so far.

Returns:
the CRC value of the data written so far.

write

public void write(int b)
           throws java.io.IOException
Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Flushes the underlying OutputStream.

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException

getTotalIn

public abstract int getTotalIn()
Returns the uncompressed size of the data written so far.

Returns:
the uncompressed size of the data written so far

getTotalOut

public abstract int getTotalOut()
Returns the compressed size of the data written so far.

Returns:
the compressed size of the data written so far


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard