|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.mmm.util.io.base.AbstractByteArray
net.sf.mmm.util.io.base.ByteArrayImpl
net.sf.mmm.util.io.impl.ByteArrayBufferImpl
public class ByteArrayBufferImpl
This class is similar to ByteBuffer but a lot simpler.
However it allows to set the current index so
the internal buffer-array can be consumed externally and
proceeded very fast.
ATTENTION:
This class is NOT intended to be exposed. It should only be used internally
by some class or component.
ByteBuffer.wrap(byte[], int, int)| Field Summary | |
|---|---|
private int |
currentIndex
|
| Constructor Summary | |
|---|---|
ByteArrayBufferImpl(byte[] buffer)
The constructor. |
|
ByteArrayBufferImpl(byte[] buffer,
int currentIndex,
int maximumIndex)
The constructor. |
|
ByteArrayBufferImpl(int capacity)
The constructor. |
|
| Method Summary | |
|---|---|
ByteArrayImpl |
createSubArray(int minimum,
int maximum)
This method creates a new ByteArray with the same
bytes but the given indices. |
int |
getCurrentIndex()
This method gets the offset in the byte array. |
boolean |
hasNext()
This method determines if there is a next byte available. |
byte |
next()
This method gets the current byte in the iteration. |
byte |
peek()
This method gets the current byte in the iteration. |
void |
setCurrentIndex(int currentIndex)
This method sets the currentIndex. |
void |
setMaximumIndex(int maximumIndex)
This method sets the maximumIndex. |
long |
skip(long byteCount)
This method skips the number of bytes given by byteCount. |
| Methods inherited from class net.sf.mmm.util.io.base.ByteArrayImpl |
|---|
getBytes, getMaximumIndex, getMinimumIndex, toString |
| Methods inherited from class net.sf.mmm.util.io.base.AbstractByteArray |
|---|
checkSubArray, getBytesAvailable |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface net.sf.mmm.util.io.api.ByteArray |
|---|
getBytes, getBytesAvailable, getMaximumIndex, getMinimumIndex |
| Field Detail |
|---|
private int currentIndex
getCurrentIndex()| Constructor Detail |
|---|
public ByteArrayBufferImpl(int capacity)
capacity - is the length of the internal
buffer.public ByteArrayBufferImpl(byte[] buffer)
buffer - is the internal buffer.
public ByteArrayBufferImpl(byte[] buffer,
int currentIndex,
int maximumIndex)
buffer - is the internal buffer.currentIndex - is the current index.maximumIndex - is the maximum index.| Method Detail |
|---|
public int getCurrentIndex()
byte array. It will
be in the range from 0 to
maximumIndex + 1.
getCurrentIndex in interface ByteArraygetCurrentIndex in class ByteArrayImplbyte array.public void setCurrentIndex(int currentIndex)
currentIndex. This can be
useful e.g. if data from the buffer has been consumed
externally.
setCurrentIndex in interface ByteArrayBuffercurrentIndex - is the currentIndex to set.
It has to be in the range from
minimumIndex to
maximumIndex + 1. A value of
maximumIndex + 1 indicates that the
buffer is consumed.public void setMaximumIndex(int maximumIndex)
maximumIndex. This may be
useful if the buffer should be reused.
setMaximumIndex in class ByteArrayImplmaximumIndex - is the maximumIndex to set.
It has to be in the range from 0 (
currentIndex - 1) to
ByteArrayImpl.getBytes().length.
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 ByteIteratorNoSuchElementException - if there is no such byte available.Iterator.next()
public byte peek()
throws NoSuchElementException
ByteIterator.next()
this method does NOT modify the state of this ByteIterator.
Therefore the peeked byte does NOT get consumed and repetitive calls will
return the same value.ByteIterator.hasNext() returns
true.
peek in interface ByteIteratorNoSuchElementException - if there is no such byte available.ByteIterator.next()public 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 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 ByteArrayImpl createSubArray(int minimum,
int maximum)
ByteArray with the same
bytes but the given indices.minimum and
maximum index are both equal to the current indices of this
ByteArray this method may return the instance itself (
this) rather than creating a new one.
createSubArray in interface ByteArraycreateSubArray in class ByteArrayImplminimum - is the minimumIndex and the
currentIndex for the new
ByteArray. It has to be greater or equal to the
minimumIndex of this
ByteArray.maximum - is the maximumIndex for the new
ByteArray.
ByteArray with the given indices.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||