uk.org.ogsadai.activity.transform
Class ZIPIncrementalProcessor

java.lang.Object
  |
  +--uk.org.ogsadai.activity.transform.ZIPIncrementalProcessor
All Implemented Interfaces:
IncrementalProcessor

public class ZIPIncrementalProcessor
extends java.lang.Object
implements IncrementalProcessor

An IncrementalProcessor to produce ZIP archives.

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
private static int DEFAULT_BUFFER_SIZE
          Default buffer size
private static DAILogger LOG
          Logger object for logging in this class
private  boolean mActive
          Indicates whether or not there is more processing to be done.
private  byte[] mBuffer
          Internal buffer.
private  java.util.zip.Checksum mChecksum
          The checksum used for the archiving.
private  java.lang.String mComment
          The comment to store with the archive.
private  java.io.InputStream mCurrentInput
          References the input that is currently being processed.
private  java.util.Map mEntryMap
          Maps entry names to input streams.
private  java.util.Iterator mEntryNames
          Used to iterate over the entry names in mEntryMap.
private static int METHOD
          This specifies the archiving method.
private  int mLevel
          The compression level.
private  java.util.zip.ZipOutputStream mOutput
          The archived output is written here.
 
Constructor Summary
ZIPIncrementalProcessor()
          Constructs an instance with the default internal buffer size.
ZIPIncrementalProcessor(int bufferSize)
          Constructs an instance with the specified internal buffer size.
 
Method Summary
 boolean active()
          Indicates whether or not processing is complete.
 void close()
          Closes the IncrementalProcessor, freeing up any resources.
 void initialise(java.io.OutputStream output)
          Initialises the instance to process to the specified output.
private  void initialiseNextEntry()
          Initialise the next entry for the ZIP archive.
 void process()
          Performs some processing that may write data to the OutputStream that the instance was initialised with.
 void setChecksum(java.util.zip.Checksum checksum)
          Sets the checksum object to use with the archiving operation.
 void setComment(java.lang.String comment)
           
 void setEntryMap(java.util.Map entryMap)
          Sets the ZIP entries.
 void setLevel(int level)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
Copyright statement

See Also:
Constant Field Values

LOG

private static final DAILogger LOG
Logger object for logging in this class


mOutput

private java.util.zip.ZipOutputStream mOutput
The archived output is written here.


mChecksum

private java.util.zip.Checksum mChecksum
The checksum used for the archiving.


mEntryMap

private java.util.Map mEntryMap
Maps entry names to input streams.


mEntryNames

private java.util.Iterator mEntryNames
Used to iterate over the entry names in mEntryMap.


mCurrentInput

private java.io.InputStream mCurrentInput
References the input that is currently being processed.


mComment

private java.lang.String mComment
The comment to store with the archive.


METHOD

private static final int METHOD
This specifies the archiving method. The DEFLATED method must always be used because the STORED method requires that each entry is read into memory so that the size and CRC checksum can be specified explicitly.

See Also:
Constant Field Values

mLevel

private int mLevel
The compression level.


mActive

private boolean mActive
Indicates whether or not there is more processing to be done.


mBuffer

private byte[] mBuffer
Internal buffer.


DEFAULT_BUFFER_SIZE

private static final int DEFAULT_BUFFER_SIZE
Default buffer size

See Also:
Constant Field Values
Constructor Detail

ZIPIncrementalProcessor

public ZIPIncrementalProcessor()
Constructs an instance with the default internal buffer size.


ZIPIncrementalProcessor

public ZIPIncrementalProcessor(int bufferSize)
Constructs an instance with the specified internal buffer size.

Parameters:
bufferSize - The size of the buffer
Throws:
java.lang.IllegalArgumentException - If bufferSize <= 0.
Method Detail

setEntryMap

public void setEntryMap(java.util.Map entryMap)
Sets the ZIP entries.

Parameters:
entryMap - A Map mapping entry name to entry java.io.InputStreams.
Throws:
java.lang.IllegalArgumentException - If entryMap is null or has length 0 or contains entries that are not java.io.InputStreams.

setChecksum

public void setChecksum(java.util.zip.Checksum checksum)
Sets the checksum object to use with the archiving operation.

Parameters:
checksum - The Checksum to use for the archiving operation. If this is null then no checksum is used.

setComment

public void setComment(java.lang.String comment)

setLevel

public void setLevel(int level)

initialise

public void initialise(java.io.OutputStream output)
Description copied from interface: IncrementalProcessor
Initialises the instance to process to the specified output.

Specified by:
initialise in interface IncrementalProcessor
Parameters:
output - The OutputStream

active

public boolean active()
Description copied from interface: IncrementalProcessor
Indicates whether or not processing is complete. If processing is not complete, then more processing can be performed by invoking the process method.

Specified by:
active in interface IncrementalProcessor
Returns:
true if processing is not complete, otherwise false.

process

public void process()
             throws java.io.IOException
Description copied from interface: IncrementalProcessor
Performs some processing that may write data to the OutputStream that the instance was initialised with.

Specified by:
process in interface IncrementalProcessor
Throws:
java.io.IOException - If there is an I/O problem.

initialiseNextEntry

private void initialiseNextEntry()
                          throws java.io.IOException
Initialise the next entry for the ZIP archive.

Throws:
java.io.IOException - If any problem arises.

close

public void close()
           throws java.io.IOException
Description copied from interface: IncrementalProcessor
Closes the IncrementalProcessor, freeing up any resources.

Specified by:
close in interface IncrementalProcessor
Throws:
java.io.IOException - If there is an I/O problem.