uk.org.ogsadai.activity.transform
Class IncrementalProcessorInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--uk.org.ogsadai.activity.transform.IncrementalProcessorInputStream

public class IncrementalProcessorInputStream
extends java.io.InputStream

An InputStream designed to read the output of some kind of process in incremental stages. An IncrementalProcessor is used to perform this actual processing.

There are many cases where a process writes to an output stream and it is necessary to retrieve this data produced in stages during the processing, rather than in a single block when the processing is complete. This class together with the IncrementalProcessor interface provides a solution to this problem.

This class contains an inner class, which extends OutputStream. An instance of this can write to the same buffer that the read method reads from. The IncrementalProcessorInputStream must be constructed using an IncrementalProcessor that uses an instance of this OutputStream. Whenever a read method is invoked, processing is performed using the IncrementalProcessor, to generate some output that can be returned.

Author:
The OGSA-DAI Project Team

Nested Class Summary
private  class IncrementalProcessorInputStream.QueueSharingOutputStream
          An inner class OutputStream that writes to the same byte buffer that the surrounding class reads from.
 
Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
private static int DEFAULT_BUFFER_SIZE
          Default buffer size.
private  byte[] mByte
          Used to optimise the read and write methods.
private  IncrementalProcessor mProcessor
          Used to generate the output that will be read, in incremental stages.
private  ByteQueue mQueue
          The internal byte buffer, written to and read from.
 
Fields inherited from class java.io.InputStream
 
Constructor Summary
IncrementalProcessorInputStream(IncrementalProcessor processor)
          Constructs an instance using the specified parameters and the default internal buffer size.
IncrementalProcessorInputStream(IncrementalProcessor processor, int bufferSize)
          Constructs an instance using the specified parameters.
 
Method Summary
 int read()
           
 int read(byte[] bytes, int start, int length)
           
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, reset, skip
 
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

DEFAULT_BUFFER_SIZE

private static final int DEFAULT_BUFFER_SIZE
Default buffer size.

See Also:
Constant Field Values

mQueue

private ByteQueue mQueue
The internal byte buffer, written to and read from.


mProcessor

private IncrementalProcessor mProcessor
Used to generate the output that will be read, in incremental stages.


mByte

private byte[] mByte
Used to optimise the read and write methods.

Constructor Detail

IncrementalProcessorInputStream

public IncrementalProcessorInputStream(IncrementalProcessor processor)
                                throws java.io.IOException
Constructs an instance using the specified parameters and the default internal buffer size.

Parameters:
processor - The IncrementalProcessor used to perform the processing. This should be constructed but not initialised.
Throws:
java.io.IOException - If there is an I/O problem.

IncrementalProcessorInputStream

public IncrementalProcessorInputStream(IncrementalProcessor processor,
                                       int bufferSize)
                                throws java.io.IOException
Constructs an instance using the specified parameters.

Parameters:
processor - The IncrementalProcessor used to perform the processing. This should be constructed but not initialised.
bufferSize - The internal buffer size.
Throws:
java.io.IOException - If there is an I/O problem.
Method Detail

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
java.io.IOException

read

public int read(byte[] bytes,
                int start,
                int length)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
java.io.IOException