|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ByteArray
This is the interface for some object that holds a byte-array
together with a range
where the user of this interface may start
and end
reading in that array.
A ByteArray
is similar to ByteBuffer
. However it is a lot simpler, has an
interface as API and can permit modifying indices.
ATTENTION:
Unfortunately there is no way in java to give a read-only view on a 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
Method Summary | |
---|---|
ByteArray |
createSubArray(int minimum,
int maximum)
This method creates a new ByteArray with the same bytes but the given
indices.ATTENTION: If the implementation is immutable and the given 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. |
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 . |
Method Detail |
---|
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
. It will be in the range from
0
to maximumIndex
+ 1
.
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 ByteProvider
ByteArray 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |