net.sf.mmm.util.io.api
Interface ByteProcessable
- All Known Subinterfaces:
- ProcessableByteArrayBuffer
- All Known Implementing Classes:
- AbstractByteArrayBufferBuffer, BufferInputStream, ByteArrayBufferBuffer, LookaheadByteArrayBufferBuffer
public interface ByteProcessable
This is the interface for an object providing data represented as sequence of
byte
s - typically some sort of buffer.
Following the idiom separations of concerns the idea is to allow
fast and easy processing
of
the data without any dependency or knowledge of the internals of this
data-provider.
The user of this API can implement a ByteProcessor
(e.g. as anonymous
or inner class) with its custom logic. He is entirely independent from the
underlying implementation of this interface that may use one big byte-array
to store the provided data or have it sliced into multiple smaller
byte-arrays.
- Since:
- 1.0.1
- Author:
- Joerg Hohwiller (hohwille at users.sourceforge.net)
Method Summary |
long |
process(ByteProcessor processor,
long length)
This method processes the number of bytes given by length (as
far as available) using the given processor . |
process
long process(ByteProcessor processor,
long length)
- This method processes the number of bytes given by
length
(as
far as available) using the given processor
.
- Parameters:
processor
- is the ByteProcessor
called to process the bytes.
It may be called multiple types if the data is sliced into multiple
byte-arrays.length
- is the desired number of bytes to process. The value has to
be greater or equal to 0
. A value of 0
will have no effect. If you want to process all available data to
the end of stream or buffer you may use Long.MAX_VALUE
.
- Returns:
- the number of bytes that have actually been processed. For a
sufficient
length
this will typically be equal to
length
. However if the end of the data has been
reached, a smaller value is returned. The value will always be
greater or equal to 0
.
Copyright © 2001-2010 mmm-Team. All Rights Reserved.