public class LookaheadByteArrayBufferBuffer extends AbstractByteArrayBufferBuffer
byte
-Buffer that represents the concatenation of multiple
ByteArrayBufferImpl
s. The resulting LookaheadByteArrayBufferBuffer
has its own state and
does NOT modify a contained ByteArrayBufferImpl
. Modifier and Type | Field and Description |
---|---|
private AbstractByteArrayBufferBuffer |
master
The master buffer adapted by this buffer.
|
Constructor and Description |
---|
LookaheadByteArrayBufferBuffer(AbstractByteArrayBufferBuffer master)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
fill(InputStream inputStream)
This method fills this buffer using the given
inputStream . |
boolean |
hasNext()
This method determines if there is a
next byte available. |
byte |
next()
This method gets the current byte in the iteration.
|
long |
process(ByteProcessor processor,
long byteCount)
This method processes the number of bytes given by
length (as far as available) using the
given processor . |
long |
skip(long byteCount)
This method skips the number of bytes given by
byteCount . |
fill, getByteArray, getByteArrayCount, getBytesAvailable, getCurrentBuffer, getCurrentBufferIndex, nextBuffer, peek, sync
private final AbstractByteArrayBufferBuffer master
public LookaheadByteArrayBufferBuffer(AbstractByteArrayBufferBuffer master)
master
- is the master-buffer to copy for lookahead reads.public byte next() throws NoSuchElementException
ByteIterator
points to the next byte in the iteration or to the end if there is no such byte
available
. ByteIterator.hasNext()
returns true
.next
in interface ByteIterator
next
in class AbstractByteArrayBufferBuffer
NoSuchElementException
- if there is no such byte available
.Iterator.next()
public boolean hasNext()
next byte
available.hasNext
in interface ByteIterator
hasNext
in class AbstractByteArrayBufferBuffer
true
if there is a next byte
available, false
otherwise
(if the end of this buffer has been reached).public long skip(long byteCount)
byteCount
.skip
in interface ByteIterator
skip
in class AbstractByteArrayBufferBuffer
byteCount
- is the expected number of bytes to skip.byteCount
. However the value may be less if the end of this iterator has been
reached before the according number of bytes have been skipped. The value will always be greater
or equal to 0
.InputStream.skip(long)
public long process(ByteProcessor processor, long byteCount)
length
(as far as available) using the
given processor
.process
in interface ByteProcessable
process
in class AbstractByteArrayBufferBuffer
processor
- is the ByteProcessor
called to process the bytes. It may be called multiple
types if the data is sliced into multiple byte-arrays.byteCount
- 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
.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
.protected boolean fill(InputStream inputStream) throws IOException
inputStream
. If the buffer is already filled,
this method will have no effect and return false
.fill
in class AbstractByteArrayBufferBuffer
inputStream
- is the InputStream
providing the data to fill this buffer with.true
if the end of the stream was encountered while (re)filling this buffer,
false
otherwise.IOException
- if caused by the inputStream
whilst reading.Copyright © 2001–2014 mmm-Team. All rights reserved.