public class ByteArrayImpl extends AbstractByteArray
ByteBuffer but a lot simpler.ByteBuffer.wrap(byte[], int, int)| Modifier and Type | Field and Description |
|---|---|
private byte[] |
buffer |
private int |
maximumIndex |
private int |
minimumIndex |
| Constructor and Description |
|---|
ByteArrayImpl(byte[] buffer)
The constructor.
|
ByteArrayImpl(byte[] buffer,
int startIndex,
int maximumIndex)
The constructor.
|
ByteArrayImpl(int capacity)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
ByteArrayImpl |
createSubArray(int minimum,
int maximum)
|
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() |
checkSubArray, getBytesAvailableprivate final byte[] buffer
private int minimumIndex
private int maximumIndex
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.public byte[] getBytes()
ByteArrayminimumIndex (typically currentIndex to
maximumIndex. Only the creator of this object may modify this array.ByteArray.getCurrentIndex(),
ByteArray.getMaximumIndex()public int getCurrentIndex()
ByteArraybyte array.public int getMinimumIndex()
ByteArraybyte 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()
ByteArraybuffer. 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)
ByteArrayByteArray 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 AbstractByteArrayminimum - 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.