net.sf.mmm.util.io.impl
Class ProcessableDetectorOutputStream.WrapperOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by net.sf.mmm.util.io.impl.ProcessableDetectorOutputStream.WrapperOutputStream
All Implemented Interfaces:
Closeable, Flushable, DetectorStreamProcessor
Enclosing class:
ProcessableDetectorOutputStream

protected class ProcessableDetectorOutputStream.WrapperOutputStream
extends OutputStream
implements DetectorStreamProcessor

This inner class is the actual wrapper stream.

See Also:
ProcessableDetectorOutputStream.getStream()

Field Summary
private  byte[] bytes
          An array of buffered bytes or null.
private  int count
          The number of bytes buffered in bytes.
private  OutputStream delegate
          The delegate adapted by this wrapper.
 
Constructor Summary
ProcessableDetectorOutputStream.WrapperOutputStream(OutputStream outputStream)
          The constructor.
 
Method Summary
 void close()
          
 void flush()
          
private  void flushBuffer()
          This method flushes the internal buffer.
 void process(DetectorStreamBuffer buffer, Map<String,Object> metadata, boolean eos)
          This method performs the actual detection and optionally manipulates the data.
 void write(byte[] b)
          
 void write(byte[] b, int off, int len)
          
 void write(int b)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delegate

private final OutputStream delegate
The delegate adapted by this wrapper.


bytes

private byte[] bytes
An array of buffered bytes or null.


count

private int count
The number of bytes buffered in bytes.

Constructor Detail

ProcessableDetectorOutputStream.WrapperOutputStream

public ProcessableDetectorOutputStream.WrapperOutputStream(OutputStream outputStream)
The constructor.

Parameters:
outputStream - is the OutputStream to adapt.
Method Detail

close

public void close()
           throws IOException

Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException

flush

public void flush()
           throws IOException

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

flushBuffer

private void flushBuffer()
                  throws IOException
This method flushes the internal buffer.

Throws:
IOException - if the underlying OutputStream caused such exception.

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException

Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(byte[] b)
           throws IOException

Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(int b)
           throws IOException

Specified by:
write in class OutputStream
Throws:
IOException

process

public void process(DetectorStreamBuffer buffer,
                    Map<String,Object> metadata,
                    boolean eos)
             throws IOException
This method performs the actual detection and optionally manipulates the data. All this happens via the given buffer that provides access to read buffered parts of the stream. As streams are typically larger pieces of data, this method will be called repetitive in order to process the entire stream.
ATTENTION:
A legal implementation of this interface has to consume data from the given buffer whenever it is invoked. To ensure your implementation can always make an appropriate decision it may have to ensure a specific lookahead.

Specified by:
process in interface DetectorStreamProcessor
Parameters:
buffer - allows you to read parts of the streamed data as well as to manipulate the data.
metadata - is the Map with the meta-data.
eos - - true if the end of the stream has been reached and the given buffer has to be
Throws:
IOException - in case of an Input/Output error. Should only be used internally.


Copyright © 2001-2010 mmm-Team. All Rights Reserved.