net.sf.mmm.util.io.api.spi
Interface DetectorStreamBuffer

All Superinterfaces:
ByteBuffer, ByteIterator, ByteProvider, ComposedByteBuffer
All Known Implementing Classes:
DetectorStreamBufferImpl

public interface DetectorStreamBuffer
extends ComposedByteBuffer

This is the interface for a buffer of bytes from a stream. It allows to consume such bytes in order to detect metadata or even manipulate the stream.

Since:
1.1.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Method Summary
 long getStreamPosition()
          This method gets the absolute position of the current pointer in the logical stream (the data provided by this interface that origins from the previous member of the chain).
 void insert(byte... data)
          This method inserts the given bytes at the current position into the stream.
 void insert(ByteArray data)
          This method inserts the given data at the current position into the stream.
 void remove(long byteCount)
          This method removes the number of bytes given by byteCount from the stream starting at the current position.
 long skip()
          This method skips all bytes available in this buffer.
 long skip(long byteCount)
          This method skips the number of bytes given by byteCount in the stream starting at the current position.
 
Methods inherited from interface net.sf.mmm.util.io.api.ComposedByteBuffer
fill, getByteArray, getByteArrayCount
 
Methods inherited from interface net.sf.mmm.util.io.api.ByteIterator
hasNext, next, peek
 
Methods inherited from interface net.sf.mmm.util.io.api.ByteProvider
getBytesAvailable
 

Method Detail

remove

void remove(long byteCount)
This method removes the number of bytes given by byteCount from the stream starting at the current position.

Parameters:
byteCount - is the number of bytes to remove. This value can be greater than the currently available bytes. You may supply Long.MAX_VALUE to remove the rest of the stream.
See Also:
skip(long)

skip

long skip(long byteCount)
This method skips the number of bytes given by byteCount in the stream starting at the current position. The given number of bytes will be untouched in stream (queued for the next processor in the chain).

Specified by:
skip in interface ByteIterator
Parameters:
byteCount - is the number of bytes to ignore. This value can be greater than the currently available bytes. You may supply Long.MAX_VALUE to ignore to the end of the stream.
Returns:
the given byteCount.
See Also:
InputStream.skip(long)

skip

long skip()
This method skips all bytes available in this buffer. This is logically the same as skip(ByteProvider.getBytesAvailable()) but more efficient.

Returns:
the number of bytes that have been skipped.

insert

void insert(byte... data)
This method inserts the given bytes at the current position into the stream.
It is only a convenience-method for insert(ByteArray).

Parameters:
data - is a ByteArray with the data to insert.

insert

void insert(ByteArray data)
This method inserts the given data at the current position into the stream.

Parameters:
data - is a ByteArray with the data to insert.

getStreamPosition

long getStreamPosition()
This method gets the absolute position of the current pointer in the logical stream (the data provided by this interface that origins from the previous member of the chain). The value represents the number of bytes that have been consumed. It excludes the number of bytes that have been inserted.

Returns:
the current position in the stream.


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