public interface MergedByteBuffers
| Modifier and Type | Field and Description |
|---|---|
static int |
BYTES_IN_INT |
static int |
BYTES_IN_LONG |
static int |
BYTES_IN_SHORT |
static short |
UNSIGNED_BYTE_MASK |
static long |
UNSIGNED_INT_MASK |
static int |
UNSIGNED_SHORT_MASK |
| Modifier and Type | Method and Description |
|---|---|
void |
add(byte[]... ba)
This method allows you to add ByteBuffers to the MergedByteBuffers.
|
void |
add(java.nio.ByteBuffer... buffer)
This method allows you to add ByteBuffers to the MergedByteBuffers.
|
void |
add(MergedByteBuffers... mbb)
This method allows you to add a MergedByteBuffers to another MergedByteBuffers.
|
void |
add(MergedByteBuffers mbb,
int maxLength)
This method allows you to add a MergedByteBuffers to another MergedByteBuffers.
|
java.io.InputStream |
asInputStream() |
void |
discard(int size)
Discard will drop how ever many bytes you tell it to on the floor.
|
void |
discardFromEnd(int size)
Similar to
discard(int) except that the bytes removed from this will be from the end
of the buffer and discard towards the head. |
MergedByteBuffers |
duplicate()
Make a complete duplicate of this MergedByteBuffer.
|
MergedByteBuffers |
duplicateAndClean()
This will flush all the data in this MergedByteBuffer into another MergedByteBuffer.
|
byte |
get()
Returns the next byte stored in the MergedByteBuffers.
|
int |
get(byte[] destBytes)
Fills the passed
byte[] completely with data from the MergedByteBuffer. |
int |
get(byte[] destBytes,
int start,
int length)
Fills the passed
byte[] completely with data from the MergedByteBuffer. |
java.lang.String |
getAsString(int size)
This will return the specified number of bytes as a String object.
|
java.lang.String |
getAsString(int size,
java.nio.charset.Charset charSet)
This will return the specified number of bytes as a String object.
|
int |
getInt()
Returns the next 4 bytes as an
int value. |
long |
getLong()
Returns the next 8 bytes as a
long value. |
short |
getShort()
Returns the next 2 bytes as a
short value. |
long |
getTotalConsumedBytes()
This will return the number of bytes that has been consumed by this MergedByteBuffer.
|
short |
getUnsignedByte()
Returns the next
byte unsigned as short stored in the MergedByteBuffers. |
long |
getUnsignedInt()
Returns an unsigned short (as an
int) from the next 2 stored bytes. |
int |
getUnsignedShort()
Returns an unsigned
short (as an int) from the next 2 stored bytes. |
boolean |
hasRemaining()
Returns if there is any data pending in this MergedByteBuffer or not.
|
int |
indexOf(byte[] pattern)
Like the indexOf in String object this find a pattern of bytes and reports the position they start at.
|
int |
indexOf(byte[] pattern,
int fromPosition)
Like the indexOf in String object this find a pattern of bytes and reports the position they start at.
|
int |
indexOf(java.lang.String pattern)
Like the indexOf in String object this find a pattern of bytes and reports the position they start at.
|
int |
indexOf(java.lang.String pattern,
java.nio.charset.Charset charSet)
Like the indexOf in String object this find a pattern of bytes and reports the position they start at.
|
int |
indexOf(java.lang.String pattern,
java.nio.charset.Charset charSet,
int fromPosition)
Like the indexOf in String object this find a pattern of bytes and reports the position they start at.
|
int |
indexOf(java.lang.String pattern,
int fromPosition)
Like the indexOf in String object this find a pattern of bytes and reports the position they start at.
|
boolean |
isAppendable() |
int |
nextBufferSize()
Get the size of the next full
ByteBuffer in the queue. |
java.nio.ByteBuffer |
popBuffer()
Get the next Complete
ByteBuffer in its entirety. |
java.nio.ByteBuffer |
pullBuffer(int size) |
int |
remaining()
Check how much data is available in the MergedByteBuffer.
|
static final int BYTES_IN_LONG
static final int BYTES_IN_INT
static final int BYTES_IN_SHORT
static final short UNSIGNED_BYTE_MASK
static final int UNSIGNED_SHORT_MASK
static final long UNSIGNED_INT_MASK
void add(byte[]... ba)
ba - - The byte[] to add to the MergedByteBuffersvoid add(java.nio.ByteBuffer... buffer)
buffer - - The byte buffer to add to the MergedByteBuffersvoid add(MergedByteBuffers... mbb)
mbb - - The MergedByteBuffers to put into this MergedByteBuffersvoid add(MergedByteBuffers mbb, int maxLength)
mbb - - The MergedByteBuffers to put into this MergedByteBuffersmaxLength - - Maximum number of bytes to copy out of provided mbbMergedByteBuffers duplicate()
MergedByteBuffers duplicateAndClean()
int indexOf(java.lang.String pattern)
pattern - String pattern to search for.int with the offset of the first occurrence of the given .int indexOf(java.lang.String pattern,
java.nio.charset.Charset charSet)
pattern - String pattern to search for.charSet - the Charset of the string.int with the offset of the first occurrence of the given .int indexOf(byte[] pattern)
pattern - byte[] pattern to search forint with the offset of the first occurrence of the given .int indexOf(java.lang.String pattern,
int fromPosition)
pattern - String pattern to search for.fromPosition - Starting index to search from, inclusiveint with the offset of the first occurrence of the given .int indexOf(java.lang.String pattern,
java.nio.charset.Charset charSet,
int fromPosition)
pattern - String pattern to search for.charSet - the Charset of the string.fromPosition - Starting index to search from, inclusiveint with the offset of the first occurrence of the given .int indexOf(byte[] pattern,
int fromPosition)
pattern - byte[] pattern to search forfromPosition - Starting index to search from, inclusiveint with the offset of the first occurrence of the given .int remaining()
boolean hasRemaining()
Returns if there is any data pending in this MergedByteBuffer or not.
This can be more efficient then calling remaining() on some implementations
of MergedByteBuffers.
byte get()
short getUnsignedByte()
byte unsigned as short stored in the MergedByteBuffers.byte as short from the MergedByteBuffers.int getUnsignedShort()
short (as an int) from the next 2 stored bytes.int (unsigned Short)short getShort()
short value.short of the next 2 bytes.int getInt()
int value.int from the next 4 byteslong getUnsignedInt()
int) from the next 2 stored bytes.int (unsigned Short)long getLong()
long value.long from the next 8 bytes.int get(byte[] destBytes)
byte[] completely with data from the MergedByteBuffer.destBytes - fills the given byteArray with the next bytes from the MergedByteBuffer.int get(byte[] destBytes,
int start,
int length)
byte[] completely with data from the MergedByteBuffer.destBytes - fills the given byteArray with the next bytes from the MergedByteBuffer.start - starting position to fill in the byte[].length - how much data to copy into the buffer.int nextBufferSize()
ByteBuffer in the queue.ByteBuffer in the queue.java.nio.ByteBuffer popBuffer()
ByteBuffer in its entirety. This byteBuffer could be
any size and it will just pull it off the queue and return it.
If remaining() is 0 you will get an empty ByteBuffer.ByteBuffer in the queue.java.nio.ByteBuffer pullBuffer(int size)
size - size of the ByteBuffer to pull out of the MergedByteBuffer.ByteBuffer of %SIZE% bytes.void discard(int size)
size - the number of bytes to discard.void discardFromEnd(int size)
discard(int) except that the bytes removed from this will be from the end
of the buffer and discard towards the head.size - the number of bytes to discard.java.lang.String getAsString(int size)
size - the number of bytes to put into the string.java.lang.String getAsString(int size,
java.nio.charset.Charset charSet)
size - the number of bytes to put into the string.charSet - the Charset of the String to return.long getTotalConsumedBytes()
This will return the number of bytes that has been consumed by this MergedByteBuffer.
boolean isAppendable()
MergedByteBuffers or false if they can not be.java.io.InputStream asInputStream()