|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.opcfoundation.ua.utils.bytebuffer.ByteQueue
public class ByteQueue
Byte Queue is a LIFO queue of bytes. It uses 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 Summary | |
|---|---|
ByteQueue()
Construct new byte queue usign default allocation size. |
|
ByteQueue(int chunkSize)
Construct new byte queue. |
|
| Method Summary | |
|---|---|
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. |
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()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ByteQueue()
public ByteQueue(int chunkSize)
chunkSize - allocation size for new memory chunks| Method Detail |
|---|
public void put(byte[] buf)
throws BufferOverflowException
buf - bytes to write
BufferOverflowException - write limit exeeded
public void put(byte[] buf,
int off,
int len)
throws BufferOverflowException
buf - bytesoff - offsetlen - length
BufferOverflowException - if any.public void put(byte value)
put.
value - a byte.public void put(ByteBuffer src)
src - a ByteBuffer object.
BufferOverflowException - write limit exeeded
public void put(ByteBuffer src,
int length)
src - a ByteBuffer object.length - a int.
BufferOverflowException - write limit exeeded
public void offer(ByteBuffer buf)
throws BufferOverflowException
buf - buffer to write
BufferOverflowException - write limit exeeded
public void get(byte[] buf)
throws BufferUnderflowException
buf - buf to be filled
BufferUnderflowException - 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 ByteBuffer[] getChunks(int len)
throws BufferUnderflowException
len - number of bytes to read
BufferUnderflowException - if any.
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 long remaining()
public boolean isEmpty()
public boolean hasRemaining()
hasRemaining.
public long getBytesRead()
public long getBytesWritten()
public void omitAll()
public void clear()
public void skip(int bytes)
throws BufferOverflowException
bytes - to omit
BufferOverflowException - if any.public ByteBuffer getReadChunk()
public ByteBuffer getWriteChunk()
public int getWriteableBytesRemaining()
public ByteOrder order()
public void order(ByteOrder order)
order - a ByteOrder object.public void setByteBufferFactory(ByteBufferFactory factory)
factory - a ByteBufferFactory object.public ByteBufferFactory getByteBufferFactory()
public int getChunkSize()
public void setChunkSize(int chunkSize)
chunkSize - a int.public long getWriteLimit()
public void setWriteLimit(long writeLimit)
writeLimit - new writeable bytes constraintpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||