public class ByteQueue extends Object
ByteBuffers as back-end for data. There are
two incremental memory pointers, read and write position. Write position returns the number of
bytes written to the queue, and read bytes read. ByteQueue allocates new memory as required in
chunks.| Constructor and Description |
|---|
ByteQueue()
Construct new byte queue usign default allocation size.
|
ByteQueue(int chunkSize)
Construct new byte queue.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears bytes and resets all pointers.
|
void |
get(byte[] buf)
Read from buf.
|
void |
get(byte[] buf,
int off,
int len)
Read from buf.
|
void |
get(ByteBuffer dst)
Reads to dst remaining bytes.
|
void |
get(ByteBuffer dst,
int length)
Reads to dst.
|
ByteBuffer |
get(int len)
Read bytes (Efficient).
|
void |
getAvailable(ByteBuffer dst)
Reads as much as there is available and dst has remaining allocation.
|
ByteBufferFactory |
getByteBufferFactory()
Get byte buffer factory.
|
long |
getBytesRead()
Get the total number of bytes read from the queue.
|
long |
getBytesWritten()
Get the total number of bytes written to the queue.
|
ByteBuffer[] |
getChunks(int len)
Reads bytes.
|
int |
getChunkSize()
Get the block size of back-end chunks.
|
ByteBuffer |
getReadChunk()
Expose the a byte buffer of backend.
|
int |
getWriteableBytesRemaining()
Get the number of bytes remaining for write.
|
ByteBuffer |
getWriteChunk()
Exposes internal bytebuffer of this object.
|
long |
getWriteLimit()
Get writable bytes limit.
|
boolean |
hasRemaining()
hasRemaining.
|
boolean |
isEmpty()
Is buffer empty.
|
void |
offer(ByteBuffer buf)
Offers a byte buffer object for the queue.
|
void |
omitAll()
Clears queue and moves read pointer to written pointer.
|
ByteOrder |
order()
Get byte order.
|
void |
order(ByteOrder order)
Set byte order.
|
void |
peek(byte[] buf)
Peek data, read without moving read pointer.
|
void |
peek(byte[] buf,
int off,
int len)
Peek data, read without moving read pointer.
|
void |
peek(ByteBuffer dst)
Peeks to dst.
|
ByteBuffer |
peek(int len)
Peek, read without moving read pointer.
|
void |
peekAvailable(ByteBuffer dst)
Peek available data.
|
ByteBuffer[] |
peekChunks(int len)
Peeks given number of bytes.
|
void |
put(byte value)
put.
|
void |
put(byte[] buf)
Write bytes.
|
void |
put(byte[] buf,
int off,
int len)
Write bytes.
|
void |
put(ByteBuffer src)
Write remaining bytes of src.
|
void |
put(ByteBuffer src,
int length)
Write remaining bytes of src.
|
long |
remaining()
Get the number of readable bytes.
|
void |
setByteBufferFactory(ByteBufferFactory factory)
Set byte buffer constructor.
|
void |
setChunkSize(int chunkSize)
Set the block size of back-end chunks.
|
void |
setWriteLimit(long writeLimit)
Set writable bytes limit.
|
void |
skip(int bytes)
Omit data by moving read pointer forward.
|
String |
toString() |
public ByteQueue()
public ByteQueue(int chunkSize)
chunkSize - allocation size for new memory chunkspublic void clear()
public void get(byte[] buf)
throws BufferUnderflowException
buf - buf to be filledBufferUnderflowException - if any.public void get(byte[] buf,
int off,
int len)
buf - an array of byte.off - a int.len - a int.BufferUnderflowException - if any.public void get(ByteBuffer dst) throws BufferUnderflowException
dst - a ByteBuffer object.BufferUnderflowException - if any.public void get(ByteBuffer dst, int length) throws BufferUnderflowException
dst - a ByteBuffer object.length - a int.BufferUnderflowException - if any.public ByteBuffer get(int len) throws BufferUnderflowException
len - a int.BufferUnderflowException - if any.public void getAvailable(ByteBuffer dst)
dst - a ByteBuffer object.public ByteBufferFactory getByteBufferFactory()
public long getBytesRead()
public long getBytesWritten()
public ByteBuffer[] getChunks(int len) throws BufferUnderflowException
len - number of bytes to readBufferUnderflowException - if any.public int getChunkSize()
public ByteBuffer getReadChunk()
public int getWriteableBytesRemaining()
public ByteBuffer getWriteChunk()
public long getWriteLimit()
public boolean hasRemaining()
hasRemaining.
public boolean isEmpty()
public void offer(ByteBuffer buf) throws BufferOverflowException
buf - buffer to writeBufferOverflowException - write limit exeededpublic void omitAll()
public ByteOrder order()
public void peek(byte[] buf)
throws BufferUnderflowException
buf - an array of byte.BufferUnderflowException - if any.public void peek(byte[] buf,
int off,
int len)
throws BufferUnderflowException
buf - an array of byte.off - a int.len - a int.BufferUnderflowException - if any.public void peek(ByteBuffer dst) throws BufferUnderflowException
dst - a ByteBuffer object.BufferUnderflowException - if any.public ByteBuffer peek(int len) throws BufferUnderflowException
len - a int.BufferUnderflowException - if any.public void peekAvailable(ByteBuffer dst)
dst - a ByteBuffer object.public ByteBuffer[] peekChunks(int len) throws BufferUnderflowException
len - a int.BufferUnderflowException - if any.public void put(byte value)
put.
value - a byte.public void put(byte[] buf)
throws BufferOverflowException
buf - bytes to writeBufferOverflowException - write limit exeededpublic void put(byte[] buf,
int off,
int len)
throws BufferOverflowException
buf - bytesoff - offsetlen - lengthBufferOverflowException - if any.public void put(ByteBuffer src)
src - a ByteBuffer object.BufferOverflowException - write limit exeededpublic void put(ByteBuffer src, int length)
src - a ByteBuffer object.length - a int.BufferOverflowException - write limit exeededpublic long remaining()
public void setByteBufferFactory(ByteBufferFactory factory)
factory - a ByteBufferFactory object.public void setChunkSize(int chunkSize)
chunkSize - a int.public void setWriteLimit(long writeLimit)
writeLimit - new writeable bytes constraintpublic void skip(int bytes)
throws BufferOverflowException
bytes - to omitBufferOverflowException - if any.Copyright © 2026. All rights reserved.