net.sf.mmm.util.io.impl
Class BufferInputStream.CopyProcessor

java.lang.Object
  extended by net.sf.mmm.util.io.impl.BufferInputStream.CopyProcessor
All Implemented Interfaces:
ByteProcessor
Enclosing class:
BufferInputStream

protected static class BufferInputStream.CopyProcessor
extends Object
implements ByteProcessor

This inner class is the ByteProcessor used to copy bytes from the buffer to the caller consuming data from this stream.


Field Summary
private  byte[] targetBuffer
          The buffer to copy to.
private  int targetOffset
          The offset in targetBuffer.
 
Constructor Summary
BufferInputStream.CopyProcessor()
          The constructor.
BufferInputStream.CopyProcessor(byte[] targetBuffer, int targetOffset)
          The constructor.
 
Method Summary
 int process(byte[] buffer, int offset, int length)
          This method is called to process the number of length bytes from the given buffer starting from the given offset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

targetBuffer

private byte[] targetBuffer
The buffer to copy to.


targetOffset

private int targetOffset
The offset in targetBuffer.

Constructor Detail

BufferInputStream.CopyProcessor

public BufferInputStream.CopyProcessor()
The constructor.


BufferInputStream.CopyProcessor

public BufferInputStream.CopyProcessor(byte[] targetBuffer,
                                       int targetOffset)
The constructor.

Parameters:
targetBuffer - the buffer to copy to.
targetOffset - the offset in targetBuffer.
Method Detail

process

public int process(byte[] buffer,
                   int offset,
                   int length)
This method is called to process the number of length bytes from the given buffer starting from the given offset.
ATTENTION:
An implementation of this interface should only read bytes from the given buffer. It is NOT permitted to modify the given buffer unless this is explicitly specified by the calling object (typically an implementation of ByteProcessable).

Specified by:
process in interface ByteProcessor
Parameters:
buffer - contains the bytes to process.
offset - is the index where to start in the buffer.
length - is the number of bytes to proceed.
Returns:
the number of bytes that should be consumed. Typically you will simply return length. However you can also return a value less than length and greater or equal to zero, in order to stop processing at a specific position.


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