|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.littleshoot.util.ByteBufferUtils
public final class ByteBufferUtils
Utility class for manipulating ByteBuffers.
| Constructor Summary | |
|---|---|
ByteBufferUtils()
|
|
| Method Summary | |
|---|---|
static ByteBuffer |
combine(Collection<ByteBuffer> buffers)
Combines the remaining data from the given Collection of
ByteBuffers into a single consolidated
ByteBuffer. |
static String |
getHexdump(ByteBuffer in)
Utility method for dumping a buffer in hex. |
static void |
logBufferToWrite(ByteBuffer buffer)
Logs the data contained in a ByteBuffer that's ready to be
written to the network. |
static byte[] |
readBytes16(ByteBuffer buf)
|
static int |
remaining(Collection<ByteBuffer> buffers)
|
static Collection<ByteBuffer> |
split(ByteBuffer buffer,
int chunkSize)
Splits the specified ByteBuffer into smaller
ByteBuffers of the specified size. |
static ByteBuffer[] |
toArray(byte[] byteArray,
int sizeLimit)
Splits the specified byte array into an array of ByteBuffers,
each with the specified maximum size. |
static byte[] |
toRawBytes(ByteBuffer buf)
|
static String |
toString(ByteBuffer buffer)
Returns the buffer as a string while preserving the buffer position and limit. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ByteBufferUtils()
| Method Detail |
|---|
public static ByteBuffer[] toArray(byte[] byteArray,
int sizeLimit)
ByteBuffers,
each with the specified maximum size. This is useful, for example,
when trying to limit sizes to a network MTU.
byteArray - The array to segment.sizeLimit - The maximum size of each byte buffer.
ByteBuffers.
public static Collection<ByteBuffer> split(ByteBuffer buffer,
int chunkSize)
ByteBuffer into smaller
ByteBuffers of the specified size. The remaining bytes in
the buffer must be greater than the chunk size. This method will create
smaller buffers of the specified size until there are fewer remaining
bytes than the chunk size, when it will simply add a buffer the same size
as the number of bytes remaining.
buffer - The ByteBuffer to split.chunkSize - The size of the smaller buffers to create.
Collection of ByteBuffers of the
specified size. The final buffer in the Collection
will have a size > 0 and <= the chunk size.public static ByteBuffer combine(Collection<ByteBuffer> buffers)
Collection of
ByteBuffers into a single consolidated
ByteBuffer.
buffers - The Collection of ByteBuffers to
make into a single buffer.
ByteBuffer combining the remaining data of the
Collection of ByteBuffers.public static int remaining(Collection<ByteBuffer> buffers)
public static void logBufferToWrite(ByteBuffer buffer)
ByteBuffer that's ready to be
written to the network.
buffer - The buffer to log.public static String toString(ByteBuffer buffer)
buffer - The buffer to create a string from.
public static byte[] readBytes16(ByteBuffer buf)
public static String getHexdump(ByteBuffer in)
in - The buffer to dump.
public static byte[] toRawBytes(ByteBuffer buf)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||