org.littleshoot.util.mina
Class ByteBufferUtils

java.lang.Object
  extended by org.littleshoot.util.mina.ByteBufferUtils

public final class ByteBufferUtils
extends Object

Utility class for manipulating ByteBuffers.


Constructor Summary
ByteBufferUtils()
           
 
Method Summary
static org.littleshoot.mina.common.ByteBuffer combine(Collection<org.littleshoot.mina.common.ByteBuffer> buffers)
          Combines the remaining data from the given Collection of ByteBuffers into a single consolidated ByteBuffer.
static void logBufferToWrite(org.littleshoot.mina.common.ByteBuffer buffer)
          Logs the data contained in a ByteBuffer that's ready to be written to the network.
static int remaining(Collection<org.littleshoot.mina.common.ByteBuffer> buffers)
           
static Collection<org.littleshoot.mina.common.ByteBuffer> split(org.littleshoot.mina.common.ByteBuffer buffer, int chunkSize)
          Splits the specified ByteBuffer into smaller ByteBuffers of the specified size.
static String toString(org.littleshoot.mina.common.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

ByteBufferUtils

public ByteBufferUtils()
Method Detail

split

public static Collection<org.littleshoot.mina.common.ByteBuffer> split(org.littleshoot.mina.common.ByteBuffer buffer,
                                                                       int chunkSize)
Splits the specified 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.

Parameters:
buffer - The ByteBuffer to split.
chunkSize - The size of the smaller buffers to create.
Returns:
A Collection of ByteBuffers of the specified size. The final buffer in the Collection will have a size > 0 and <= the chunk size.

combine

public static org.littleshoot.mina.common.ByteBuffer combine(Collection<org.littleshoot.mina.common.ByteBuffer> buffers)
Combines the remaining data from the given Collection of ByteBuffers into a single consolidated ByteBuffer.

Parameters:
buffers - The Collection of ByteBuffers to make into a single buffer.
Returns:
A new ByteBuffer combining the remaining data of the Collection of ByteBuffers.

remaining

public static int remaining(Collection<org.littleshoot.mina.common.ByteBuffer> buffers)

logBufferToWrite

public static void logBufferToWrite(org.littleshoot.mina.common.ByteBuffer buffer)
Logs the data contained in a ByteBuffer that's ready to be written to the network.

Parameters:
buffer - The buffer to log.

toString

public static String toString(org.littleshoot.mina.common.ByteBuffer buffer)
Returns the buffer as a string while preserving the buffer position and limit.

Parameters:
buffer - The buffer to create a string from.
Returns:
The buffer string.


Copyright © 2013 LittleShoot. All Rights Reserved.