|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ComposedByteBuffer
This is the interface of a ByteBuffer
that is internally composed out
of multiple ByteArray
s. It allows to access
these ByteArray
s for read-only lookahead operations or more
efficient processing.
Method Summary | |
---|---|
int |
fill(byte[] buffer,
int offset,
int length)
This method fills the given buffer starting at
offset with the next bytes from this
ComposedByteBuffer . |
ByteArray |
getByteArray(int index)
This method gets the ByteArray at the given index . |
int |
getByteArrayCount()
This method gets the number of ByteArray s currently available via
getByteArray(int) . |
Methods inherited from interface net.sf.mmm.util.io.api.ByteIterator |
---|
hasNext, next, peek, skip |
Methods inherited from interface net.sf.mmm.util.io.api.ByteProvider |
---|
getBytesAvailable |
Method Detail |
---|
ByteArray getByteArray(int index)
ByteArray
at the given index
. The
DetectorStreamBuffer
is composed out of
ByteArray
s. This method allows efficient processing of bytes from
byte[]
rather then calling ByteIterator.hasNext()
and
ByteIterator.next()
and repetitive. Additionally this way allows full lookahead
up to the end of the buffer without consuming the data.ByteIterator.next()
or ByteIterator.skip(long)
will
invalidate the returned ByteArray
. Please do NOT call these methods
while working with ByteArray
s.
index
- is the index of the requested ByteArray
. It has to be
in the range from 0
to
getByteArrayCount()
- 1
. A value of 0
indicates the current ByteArray
this buffer is currently
pointing to. For that current buffer
ByteArray.getBytes()
[ByteArray.getCurrentIndex()
]
will have the same result as ByteIterator.peek()
.
ByteArray
.getByteArrayCount()
int getByteArrayCount()
ByteArray
s currently available via
getByteArray(int)
.ByteIterator.next()
or ByteIterator.skip(long)
will
invalidate the returned ByteArray
. Please do NOT call these methods
while working with ByteArray
s.
ByteArray
s.int fill(byte[] buffer, int offset, int length)
buffer
starting at
offset
with the next
bytes from this
ComposedByteBuffer
. The bytes that are filled into the given
buffer
will therefore be consumed. This method can be used to
write data from this buffer to an OutputStream
or supply it
to the consumer of an InputStream
.
buffer
- is the buffer to fill.offset
- is the index in the given buffer
where to fill
in the first byte. See ByteArray.getCurrentIndex()
.length
- is the expected number of bytes to fill into
buffer
. Has to be positive and less or equal to
buffer.length - offset
. However at most the number of
available bytes
can be filled even if
length
is greater.
buffer
. Will be positive and less or equal to the
given length
. Should be only less than
maxLength
if NOT enough bytes are available
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |