public interface ByteArray extends ByteProvider
byte-array together with a range where the
user of this interface may start and end reading in that array.
ByteArray is similar to ByteBuffer. However it is a lot simpler, has an interface as API
and can permit modifying indices. byte[] than can be iterated as efficient.
Unlike many APIs of the JDK this interface trusts the user NOT to modify the underlying byte-array and therefore avoids arraycopy overhead.ByteArrayImpl| Modifier and Type | Method and Description |
|---|---|
ByteArray |
createSubArray(int minimum,
int maximum)
|
byte[] |
getBytes()
This method gets the underlying byte-array of this buffer.
|
int |
getBytesAvailable()
This method gets the number of bytes available in this array.
|
int |
getCurrentIndex()
This method gets the offset in the
byte array. |
int |
getMaximumIndex()
This method gets the maximum index in the
buffer. |
int |
getMinimumIndex()
This method gets the minimum index where to start reading in the
byte array. |
byte[] getBytes()
minimumIndex (typically currentIndex to
maximumIndex. Only the creator of this object may modify this array.getCurrentIndex(),
getMaximumIndex()int getMinimumIndex()
byte array. It will be in the
range from 0 to maximumIndex + 1. This is typically the same as the
current index. However a mutable variant
of a ByteArray may allow to modify (increase) the current-index. The value
returned by this method can NOT be modified.int getCurrentIndex()
byte array.int getMaximumIndex()
buffer. It will be in the range from -1 to
getBytes().length - 1. -1) indicates that the buffer does NOT contain data (payload).int getBytesAvailable()
getMaximumIndex() - getCurrentIndex() + 1.getBytesAvailable in interface ByteProviderByteArray 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.minimum - 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.Copyright © 2001–2016 mmm-Team. All rights reserved.