|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
The ByteStore provides a generic interface for an object
used to store bytes. The ByteStore is used as the
middle byte storing mechanism between Megs. A custom
implementation of the ByteStore interface can be
provided by a Sublayer to provide altered behavior for dealing
with the bytes streamed between Megs. For example, a
ByteStore could be written to store bytes to disk if a
limiting high water mark is reached to conserve on memory usage.
| Method Summary | |
void |
append(byte val)
Appends the given byte argument to this ByteStore. |
void |
append(byte[] bytes)
Appends the given byte array argument to this buffer. |
void |
append(byte[] bytes,
int offset,
int length)
Appends the given byte subarray of the bytes array argument
to this buffer. |
byte |
byteAt(int index)
Returns the byte at a specific index in this ByteStore. |
int |
capacity()
Returns the current capacity of the ByteStore. |
void |
ensureCapacity(int minimumCapacity)
Ensures that the capacity of the buffer is at least equal to the specified minimum. |
byte[] |
getByteArrayRef()
Return a byte array of the current buffer size containing the bytes. |
byte[] |
getBytes()
Return a byte array of the current buffer size containing the bytes. |
void |
getBytes(int srcBegin,
int srcEnd,
byte[] dst,
int dstBegin)
Populate the given byte buffer by the specified bytes. |
void |
insert(int offset,
byte val)
Inserts the given byte argument into this ByteStore. |
void |
insert(int offset,
byte[] bytes)
Inserts the given byte array argument into this ByteStore. |
int |
length()
Returns the length of this ByteStore. |
void |
purge()
The current contents are released leaving an empty ByteStore |
void |
purge(int capacity)
The current contents are released and an empty ByteStore with the specified capacity is created. |
void |
setByteAt(int index,
byte val)
The byte at the specified index of this ByteStore is set to val
. |
void |
setLength(int newLength)
Sets the length of this ByteStore. |
int |
size()
Returns the length of this ByteStore. |
| Method Detail |
public void purge()
public void purge(int capacity)
capacity - The initial capacity.public int length()
public int size()
public int capacity()
public void ensureCapacity(int minimumCapacity)
minimumCapacity argument is nonpositive, this
method takes no action and simply returns.minimumCapacity - The minimum desired capacity.
public void setLength(int newLength)
throws java.lang.StringIndexOutOfBoundsException
newLength
argument is less than the current length of the ByteStore, the
ByteBuffer is truncated to contain exactly the number of characters
given by the newLength argument.
If the newLength argument is greater than or equal to the
current length, sufficient null bytes will be appended to the byte
buffer so that length becomes equal to the newLength
argument.
The newLength argument must be greater than or equal
to 0.
newLength - The new length of the buffer.java.lang.StringIndexOutOfBoundsException - The newLength
argument is invalid
public byte byteAt(int index)
throws java.lang.ArrayIndexOutOfBoundsException
The first byte of the ByteStore is considered to be at index
0, the next at index 1, and so on, for
array indexing.
The index argument must be greater than or equal to
0, and less than the length of this ByteStore.
index - The index of the desired byte.java.lang.ArrayIndexOutOfBoundsException - The index is invalid.public byte[] getBytes()
public byte[] getByteArrayRef()
public void getBytes(int srcBegin,
int srcEnd,
byte[] dst,
int dstBegin)
throws java.lang.ArrayIndexOutOfBoundsException
srcBegin - The beginning source index.srcEnd - The ending source index.dst - The destination buffer.dstBegin - The beginning index in the destination buffer.java.lang.ArrayIndexOutOfBoundsException - The index is invalid.
public void setByteAt(int index,
byte val)
throws java.lang.ArrayIndexOutOfBoundsException
val
.index - The index of the byte to overwrite.val - The new byte value.java.lang.ArrayIndexOutOfBoundsException - The index is invalid.public void append(byte val)
The argument is appended to the contents of this ByteStore.
The length of this ByteStore increases by 1.
val - A byte value.public void append(byte[] bytes)
The bytes of the array argument are appended, in order, to the contents of this ByteStore.
bytes - The bytes to be appended.
public void append(byte[] bytes,
int offset,
int length)
bytes array argument
to this buffer.
Bytes of the byte array bytes, starting at index
offset, are appended, in order, to the contents of this
byte buffer.
bytes - The bytes to be appended.offset - The index of the first byte to append.length - The number of bytes to append.
public void insert(int offset,
byte[] bytes)
throws java.lang.ArrayIndexOutOfBoundsException
The bytes of the array argument are inserted into the
contents of this ByteStore at the position indicated by
offset.
offset - The offset.bytes - A byte array.java.lang.ArrayIndexOutOfBoundsException - There is an invalid index
into the buffer.
public void insert(int offset,
byte val)
The second argument is inserted into the contents of this byte
buffer at the position indicated by offset. The length
of this ByteStore increases by one.
The offset argument must be greater than or equal to
0, and less than or equal to the length of this
ByteBuffer.
offset - The offset.val - The byte value.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||