|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.mmm.util.io.impl.AbstractByteArrayBufferBuffer
public abstract class AbstractByteArrayBufferBuffer
This is the abstract base implementation of the
ProcessableByteArrayBuffer interface for a byte[]-Buffer
that represents the concatenation of multiple ByteArrayBuffers. It
has its own state (read-pointer) and does NOT modify a contained
buffer when reading. If one of the underlying
buffers has been read to the
end this class steps to the next
one in a rotating way until the last buffer has been reached, that contains
data that has NOT been read before. Further this class allows to be
(re)filled.
NOTE:
This class is NOT public visible, because further releases might break it's
compatibility. Feel free to review and give feedback on the mailing list if
you want to use it directly.
| Constructor Summary | |
|---|---|
protected |
AbstractByteArrayBufferBuffer(AbstractByteArrayBufferBuffer template)
The constructor used to copy from the given template. |
|
AbstractByteArrayBufferBuffer(ByteArrayBuffer... buffers)
The constructor. |
| Method Summary | |
|---|---|
protected boolean |
fill(InputStream inputStream)
This method fills this buffer using the given inputStream. |
int |
getBytesAvailable()
This method gets the number of bytes currently available in this buffer. |
protected ByteArrayBuffer |
getCurrentBuffer()
This method gets the current ByteArrayBuffer. |
protected int |
getCurrentBufferIndex()
This method gets the current index in the current buffer. |
byte |
getNext()
This method gets the next byte to iterate. |
boolean |
hasNext()
This method determines if there is a next byte
available. |
protected boolean |
nextBuffer()
This method switches the current buffer to the
next available buffer. |
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. |
protected void |
sync(AbstractByteArrayBufferBuffer master)
This method synchronizes the buffer with the given master. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractByteArrayBufferBuffer(ByteArrayBuffer... buffers)
buffers - are the buffers to concat.protected AbstractByteArrayBufferBuffer(AbstractByteArrayBufferBuffer template)
template.
template - is the buffer to copy.| Method Detail |
|---|
protected ByteArrayBuffer getCurrentBuffer()
ByteArrayBuffer.
ByteArrayBuffer.protected int getCurrentBufferIndex()
current buffer.
current buffer.protected boolean nextBuffer()
current buffer to the
next available buffer. If this method is called when the last buffer has
already been reached, the index will be
set to
getCurrentBuffer().getMaximumIndex()+1
so the end of this buffer is reached and hasNext() will return
false.
true if there was a next buffer to switch to,
false if the
current buffer is already the last one.public int getBytesAvailable()
getBytesAvailable in interface ProcessableByteArrayBufferpublic boolean hasNext()
next byte
available.
hasNext in interface ByteIteratortrue if there is a next byte
available, false otherwise (if the end of this
buffer has been reached).
public byte getNext()
throws NoSuchElementException
ByteIterator.hasNext() returns
true.
getNext in interface ByteIteratorNoSuchElementException - if there is no next byte
available.public long skip(long byteCount)
byteCount.
skip in interface ByteIteratorbyteCount - 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 ByteProcessableprocessor - 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. 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 void sync(AbstractByteArrayBufferBuffer master)
master.
master - is the buffer this buffer was created from.
protected boolean fill(InputStream inputStream)
throws IOException
inputStream.
If the buffer is already filled, this method will have no effect and return
false.
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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||