|
||||||||||
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
public class ByteArrayImpl
This class is similar to ByteBuffer
but a lot simpler.
ByteBuffer.wrap(byte[], int, int)
Field Summary | |
---|---|
private byte[] |
buffer
|
private int |
maximumIndex
|
private int |
minimumIndex
|
Constructor Summary | |
---|---|
ByteArrayImpl(byte[] buffer)
The constructor. |
|
ByteArrayImpl(byte[] buffer,
int startIndex,
int maximumIndex)
The constructor. |
|
ByteArrayImpl(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. |
byte[] |
getBytes()
This method gets the underlying byte-array of this buffer. |
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 . |
protected void |
setMaximumIndex(int maximumIndex)
This method sets the maximumIndex . |
String |
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 |
Field Detail |
---|
private final byte[] buffer
getBytes()
private int minimumIndex
getMinimumIndex()
private int maximumIndex
getMaximumIndex()
Constructor Detail |
---|
public ByteArrayImpl(int capacity)
capacity
- is the length
of the internal
buffer
.public ByteArrayImpl(byte[] buffer)
buffer
- is the internal buffer
.public ByteArrayImpl(byte[] buffer, int startIndex, int maximumIndex)
buffer
- is the internal buffer
.startIndex
- is the current index
as well
as the minimum index
.maximumIndex
- is the maximum index
.Method Detail |
---|
public byte[] getBytes()
minimumIndex
(typically currentIndex
to
maximumIndex
. Only the creator of this object
may modify this array.
ByteArray.getCurrentIndex()
,
ByteArray.getMaximumIndex()
public int getCurrentIndex()
byte array
. It will
be in the range from 0
to
maximumIndex
+ 1
.
byte array
.public 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.
public int getMaximumIndex()
buffer
. It
will be in the range from -1
to
ByteArray.getBytes()
.length - 1
.-1
) indicates that the buffer
does NOT contain data (payload).
protected void setMaximumIndex(int maximumIndex)
maximumIndex
. This may be
useful if the buffer should be reused.
maximumIndex
- is the maximumIndex
to set.
It has to be in the range from 0
(
currentIndex
- 1
) to
getBytes()
.length
.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 ByteArray
createSubArray
in class AbstractByteArray
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.public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |