Package org.jboss.netty.buffer
Class ChannelBuffers
- java.lang.Object
-
- org.jboss.netty.buffer.ChannelBuffers
-
public final class ChannelBuffers extends java.lang.ObjectCreates a newChannelBufferby allocating new space or by wrapping or copying existing byte arrays, byte buffers and a string.Use static import
This classes is intended to be used with Java 5 static import statement:import static org.jboss.netty.buffer.
ChannelBuffers.*;ChannelBufferheapBuffer = buffer(128);ChannelBufferdirectBuffer = directBuffer(256);ChannelBufferdynamicBuffer = dynamicBuffer(512);ChannelBufferwrappedBuffer = wrappedBuffer(new byte[128], new byte[256]);ChannelBuffercopiedBuffe r = copiedBuffer(ByteBuffer.allocate(128));Allocating a new buffer
Three buffer types are provided out of the box.buffer(int)allocates a new fixed-capacity heap buffer.directBuffer(int)allocates a new fixed-capacity direct buffer.dynamicBuffer(int)allocates a new dynamic-capacity heap buffer, whose capacity increases automatically as needed by a write operation.
Creating a wrapped buffer
Wrapped buffer is a buffer which is a view of one or more existing byte arrays and byte buffers. Any changes in the content of the original array or buffer will be visible in the wrapped buffer. Various wrapper methods are provided and their name is allwrappedBuffer(). You might want to take a look at the methods that accept varargs closely if you want to create a buffer which is composed of more than one array to reduce the number of memory copy.Creating a copied buffer
Copied buffer is a deep copy of one or more existing byte arrays, byte buffers or a string. Unlike a wrapped buffer, there's no shared data between the original data and the copied buffer. Various copy methods are provided and their name is allcopiedBuffer(). It is also convenient to use this operation to merge multiple buffers into one buffer.Miscellaneous utility methods
This class also provides various utility methods to help implementation of a new buffer type, generation of hex dump and swapping an integer's byte order.
-
-
Field Summary
Fields Modifier and Type Field Description static java.nio.ByteOrderBIG_ENDIANBig endian byte order.static ChannelBufferEMPTY_BUFFERA buffer whose capacity is0.private static char[]HEXDUMP_TABLEstatic java.nio.ByteOrderLITTLE_ENDIANLittle endian byte order.
-
Constructor Summary
Constructors Modifier Constructor Description privateChannelBuffers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ChannelBufferbuffer(int capacity)Creates a new big-endian Java heap buffer with the specifiedcapacity.static ChannelBufferbuffer(java.nio.ByteOrder endianness, int capacity)Creates a new Java heap buffer with the specifiedendiannessandcapacity.static intcompare(ChannelBuffer bufferA, ChannelBuffer bufferB)Compares the two specified buffers as described inChannelBuffer.compareTo(ChannelBuffer).private static ChannelBuffercompositeBuffer(java.nio.ByteOrder endianness, java.util.List<ChannelBuffer> components, boolean gathering)static ChannelBuffercopiedBuffer(byte[] array)Creates a new big-endian buffer whose content is a copy of the specifiedarray.static ChannelBuffercopiedBuffer(byte[]... arrays)Creates a new big-endian buffer whose content is a merged copy of the specifiedarrays.static ChannelBuffercopiedBuffer(byte[] array, int offset, int length)Creates a new big-endian buffer whose content is a copy of the specifiedarray's sub-region.static ChannelBuffercopiedBuffer(char[] array, int offset, int length, java.nio.charset.Charset charset)Creates a new big-endian buffer whose content is a subregion of the specifiedarrayencoded in the specifiedcharset.static ChannelBuffercopiedBuffer(char[] array, java.nio.charset.Charset charset)Creates a new big-endian buffer whose content is the specifiedarrayencoded in the specifiedcharset.static ChannelBuffercopiedBuffer(java.lang.CharSequence string, int offset, int length, java.nio.charset.Charset charset)Creates a new big-endian buffer whose content is a subregion of the specifiedstringencoded in the specifiedcharset.static ChannelBuffercopiedBuffer(java.lang.CharSequence string, java.nio.charset.Charset charset)Creates a new big-endian buffer whose content is the specifiedstringencoded in the specifiedcharset.static ChannelBuffercopiedBuffer(java.nio.ByteBuffer buffer)Creates a new buffer whose content is a copy of the specifiedbuffer's current slice.static ChannelBuffercopiedBuffer(java.nio.ByteBuffer... buffers)Creates a new buffer whose content is a merged copy of the specifiedbuffers' slices.static ChannelBuffercopiedBuffer(java.nio.ByteOrder endianness, byte[] array)Creates a new buffer with the specifiedendiannesswhose content is a copy of the specifiedarray.static ChannelBuffercopiedBuffer(java.nio.ByteOrder endianness, byte[]... arrays)Creates a new buffer with the specifiedendiannesswhose content is a merged copy of the specifiedarrays.static ChannelBuffercopiedBuffer(java.nio.ByteOrder endianness, byte[] array, int offset, int length)Creates a new buffer with the specifiedendiannesswhose content is a copy of the specifiedarray's sub-region.static ChannelBuffercopiedBuffer(java.nio.ByteOrder endianness, char[] array, int offset, int length, java.nio.charset.Charset charset)Creates a new buffer with the specifiedendiannesswhose content is a subregion of the specifiedarrayencoded in the specifiedcharset.static ChannelBuffercopiedBuffer(java.nio.ByteOrder endianness, char[] array, java.nio.charset.Charset charset)Creates a new buffer with the specifiedendiannesswhose content is the specifiedarrayencoded in the specifiedcharset.static ChannelBuffercopiedBuffer(java.nio.ByteOrder endianness, java.lang.CharSequence string, int offset, int length, java.nio.charset.Charset charset)Creates a new buffer with the specifiedendiannesswhose content is a subregion of the specifiedstringencoded in the specifiedcharset.static ChannelBuffercopiedBuffer(java.nio.ByteOrder endianness, java.lang.CharSequence string, java.nio.charset.Charset charset)Creates a new buffer with the specifiedendiannesswhose content is the specifiedstringencoded in the specifiedcharset.private static ChannelBuffercopiedBuffer(java.nio.ByteOrder endianness, java.nio.CharBuffer buffer, java.nio.charset.Charset charset)static ChannelBuffercopiedBuffer(ChannelBuffer buffer)Creates a new buffer whose content is a copy of the specifiedbuffer's readable bytes.static ChannelBuffercopiedBuffer(ChannelBuffer... buffers)Creates a new buffer whose content is a merged copy of the specifiedbuffers' readable bytes.(package private) static java.lang.StringdecodeString(java.nio.ByteBuffer src, java.nio.charset.Charset charset)static ChannelBufferdirectBuffer(int capacity)Creates a new big-endian direct buffer with the specifiedcapacity.static ChannelBufferdirectBuffer(java.nio.ByteOrder endianness, int capacity)Creates a new direct buffer with the specifiedendiannessandcapacity.static ChannelBufferdynamicBuffer()Creates a new big-endian dynamic buffer whose estimated data length is256bytes.static ChannelBufferdynamicBuffer(int estimatedLength)Creates a new big-endian dynamic buffer with the specified estimated data length.static ChannelBufferdynamicBuffer(int estimatedLength, ChannelBufferFactory factory)Creates a new big-endian dynamic buffer with the specified estimated data length using the specified factory.static ChannelBufferdynamicBuffer(java.nio.ByteOrder endianness, int estimatedLength)Creates a new dynamic buffer with the specified endianness and the specified estimated data length.static ChannelBufferdynamicBuffer(java.nio.ByteOrder endianness, int estimatedLength, ChannelBufferFactory factory)Creates a new dynamic buffer with the specified endianness and the specified estimated data length using the specified factory.static ChannelBufferdynamicBuffer(ChannelBufferFactory factory)(package private) static java.nio.ByteBufferencodeString(java.nio.CharBuffer src, java.nio.charset.Charset charset)static booleanequals(ChannelBuffer bufferA, ChannelBuffer bufferB)Returnstrueif and only if the two specified buffers are identical to each other as described inChannelBuffer#equals(Object).private static intfirstIndexOf(ChannelBuffer buffer, int fromIndex, int toIndex, byte value)private static intfirstIndexOf(ChannelBuffer buffer, int fromIndex, int toIndex, ChannelBufferIndexFinder indexFinder)static inthashCode(ChannelBuffer buffer)Calculates the hash code of the specified buffer.static ChannelBufferhexDump(java.lang.String hexString)Create aChannelBufferfrom the given hex dumpstatic java.lang.StringhexDump(ChannelBuffer buffer)Returns a hex dump of the specified buffer's readable bytes.static java.lang.StringhexDump(ChannelBuffer buffer, int fromIndex, int length)Returns a hex dump of the specified buffer's sub-region.static intindexOf(ChannelBuffer buffer, int fromIndex, int toIndex, byte value)The default implementation ofChannelBuffer.indexOf(int, int, byte).static intindexOf(ChannelBuffer buffer, int fromIndex, int toIndex, ChannelBufferIndexFinder indexFinder)The default implementation ofChannelBuffer.indexOf(int, int, ChannelBufferIndexFinder).private static intlastIndexOf(ChannelBuffer buffer, int fromIndex, int toIndex, byte value)private static intlastIndexOf(ChannelBuffer buffer, int fromIndex, int toIndex, ChannelBufferIndexFinder indexFinder)static intswapInt(int value)Toggles the endianness of the specified 32-bit integer.static longswapLong(long value)Toggles the endianness of the specified 64-bit long integer.static intswapMedium(int value)Toggles the endianness of the specified 24-bit medium integer.static shortswapShort(short value)Toggles the endianness of the specified 16-bit short integer.static ChannelBufferunmodifiableBuffer(ChannelBuffer buffer)Creates a read-only buffer which disallows any modification operations on the specifiedbuffer.static ChannelBufferwrappedBuffer(boolean gathering, java.nio.ByteBuffer... buffers)Creates a new composite buffer which wraps the slices of the specified NIO buffers without copying them.static ChannelBufferwrappedBuffer(boolean gathering, ChannelBuffer... buffers)Creates a new composite buffer which wraps the readable bytes of the specified buffers without copying them.static ChannelBufferwrappedBuffer(byte[] array)Creates a new big-endian buffer which wraps the specifiedarray.static ChannelBufferwrappedBuffer(byte[]... arrays)Creates a new big-endian composite buffer which wraps the specified arrays without copying them.static ChannelBufferwrappedBuffer(byte[] array, int offset, int length)Creates a new big-endian buffer which wraps the sub-region of the specifiedarray.static ChannelBufferwrappedBuffer(java.nio.ByteBuffer buffer)Creates a new buffer which wraps the specified NIO buffer's current slice.static ChannelBufferwrappedBuffer(java.nio.ByteBuffer... buffers)Creates a new composite buffer which wraps the slices of the specified NIO buffers without copying them.static ChannelBufferwrappedBuffer(java.nio.ByteOrder endianness, byte[] array)Creates a new buffer which wraps the specifiedarraywith the specifiedendianness.static ChannelBufferwrappedBuffer(java.nio.ByteOrder endianness, byte[]... arrays)Creates a new composite buffer which wraps the specified arrays without copying them.static ChannelBufferwrappedBuffer(java.nio.ByteOrder endianness, byte[] array, int offset, int length)Creates a new buffer which wraps the sub-region of the specifiedarraywith the specifiedendianness.static ChannelBufferwrappedBuffer(ChannelBuffer buffer)Creates a new buffer which wraps the specified buffer's readable bytes.static ChannelBufferwrappedBuffer(ChannelBuffer... buffers)Creates a new composite buffer which wraps the readable bytes of the specified buffers without copying them.
-
-
-
Field Detail
-
BIG_ENDIAN
public static final java.nio.ByteOrder BIG_ENDIAN
Big endian byte order.
-
LITTLE_ENDIAN
public static final java.nio.ByteOrder LITTLE_ENDIAN
Little endian byte order.
-
EMPTY_BUFFER
public static final ChannelBuffer EMPTY_BUFFER
A buffer whose capacity is0.
-
HEXDUMP_TABLE
private static final char[] HEXDUMP_TABLE
-
-
Method Detail
-
buffer
public static ChannelBuffer buffer(int capacity)
Creates a new big-endian Java heap buffer with the specifiedcapacity. The new buffer'sreaderIndexandwriterIndexare0.
-
buffer
public static ChannelBuffer buffer(java.nio.ByteOrder endianness, int capacity)
Creates a new Java heap buffer with the specifiedendiannessandcapacity. The new buffer'sreaderIndexandwriterIndexare0.
-
directBuffer
public static ChannelBuffer directBuffer(int capacity)
Creates a new big-endian direct buffer with the specifiedcapacity. The new buffer'sreaderIndexandwriterIndexare0.
-
directBuffer
public static ChannelBuffer directBuffer(java.nio.ByteOrder endianness, int capacity)
Creates a new direct buffer with the specifiedendiannessandcapacity. The new buffer'sreaderIndexandwriterIndexare0.
-
dynamicBuffer
public static ChannelBuffer dynamicBuffer()
Creates a new big-endian dynamic buffer whose estimated data length is256bytes. The new buffer'sreaderIndexandwriterIndexare0.
-
dynamicBuffer
public static ChannelBuffer dynamicBuffer(ChannelBufferFactory factory)
-
dynamicBuffer
public static ChannelBuffer dynamicBuffer(int estimatedLength)
Creates a new big-endian dynamic buffer with the specified estimated data length. More accurate estimation yields less unexpected reallocation overhead. The new buffer'sreaderIndexandwriterIndexare0.
-
dynamicBuffer
public static ChannelBuffer dynamicBuffer(java.nio.ByteOrder endianness, int estimatedLength)
Creates a new dynamic buffer with the specified endianness and the specified estimated data length. More accurate estimation yields less unexpected reallocation overhead. The new buffer'sreaderIndexandwriterIndexare0.
-
dynamicBuffer
public static ChannelBuffer dynamicBuffer(int estimatedLength, ChannelBufferFactory factory)
Creates a new big-endian dynamic buffer with the specified estimated data length using the specified factory. More accurate estimation yields less unexpected reallocation overhead. The new buffer'sreaderIndexandwriterIndexare0.
-
dynamicBuffer
public static ChannelBuffer dynamicBuffer(java.nio.ByteOrder endianness, int estimatedLength, ChannelBufferFactory factory)
Creates a new dynamic buffer with the specified endianness and the specified estimated data length using the specified factory. More accurate estimation yields less unexpected reallocation overhead. The new buffer'sreaderIndexandwriterIndexare0.
-
wrappedBuffer
public static ChannelBuffer wrappedBuffer(byte[] array)
Creates a new big-endian buffer which wraps the specifiedarray. A modification on the specified array's content will be visible to the returned buffer.
-
wrappedBuffer
public static ChannelBuffer wrappedBuffer(java.nio.ByteOrder endianness, byte[] array)
Creates a new buffer which wraps the specifiedarraywith the specifiedendianness. A modification on the specified array's content will be visible to the returned buffer.
-
wrappedBuffer
public static ChannelBuffer wrappedBuffer(byte[] array, int offset, int length)
Creates a new big-endian buffer which wraps the sub-region of the specifiedarray. A modification on the specified array's content will be visible to the returned buffer.
-
wrappedBuffer
public static ChannelBuffer wrappedBuffer(java.nio.ByteOrder endianness, byte[] array, int offset, int length)
Creates a new buffer which wraps the sub-region of the specifiedarraywith the specifiedendianness. A modification on the specified array's content will be visible to the returned buffer.
-
wrappedBuffer
public static ChannelBuffer wrappedBuffer(java.nio.ByteBuffer buffer)
Creates a new buffer which wraps the specified NIO buffer's current slice. A modification on the specified buffer's content will be visible to the returned buffer.
-
wrappedBuffer
public static ChannelBuffer wrappedBuffer(ChannelBuffer buffer)
Creates a new buffer which wraps the specified buffer's readable bytes. A modification on the specified buffer's content will be visible to the returned buffer.
-
wrappedBuffer
public static ChannelBuffer wrappedBuffer(byte[]... arrays)
Creates a new big-endian composite buffer which wraps the specified arrays without copying them. A modification on the specified arrays' content will be visible to the returned buffer.
-
wrappedBuffer
public static ChannelBuffer wrappedBuffer(java.nio.ByteOrder endianness, byte[]... arrays)
Creates a new composite buffer which wraps the specified arrays without copying them. A modification on the specified arrays' content will be visible to the returned buffer.- Parameters:
endianness- the endianness of the new buffer
-
compositeBuffer
private static ChannelBuffer compositeBuffer(java.nio.ByteOrder endianness, java.util.List<ChannelBuffer> components, boolean gathering)
-
wrappedBuffer
public static ChannelBuffer wrappedBuffer(ChannelBuffer... buffers)
Creates a new composite buffer which wraps the readable bytes of the specified buffers without copying them. A modification on the content of the specified buffers will be visible to the returned buffer.- Throws:
java.lang.IllegalArgumentException- if the specified buffers' endianness are different from each other
-
wrappedBuffer
public static ChannelBuffer wrappedBuffer(boolean gathering, ChannelBuffer... buffers)
Creates a new composite buffer which wraps the readable bytes of the specified buffers without copying them. A modification on the content of the specified buffers will be visible to the returned buffer. If gathering istruethen gathering writes will be used when ever possible.- Throws:
java.lang.IllegalArgumentException- if the specified buffers' endianness are different from each other
-
wrappedBuffer
public static ChannelBuffer wrappedBuffer(java.nio.ByteBuffer... buffers)
Creates a new composite buffer which wraps the slices of the specified NIO buffers without copying them. A modification on the content of the specified buffers will be visible to the returned buffer.- Throws:
java.lang.IllegalArgumentException- if the specified buffers' endianness are different from each other
-
wrappedBuffer
public static ChannelBuffer wrappedBuffer(boolean gathering, java.nio.ByteBuffer... buffers)
Creates a new composite buffer which wraps the slices of the specified NIO buffers without copying them. A modification on the content of the specified buffers will be visible to the returned buffer. If gathering istruethen gathering writes will be used when ever possible.- Throws:
java.lang.IllegalArgumentException- if the specified buffers' endianness are different from each other
-
copiedBuffer
public static ChannelBuffer copiedBuffer(byte[] array)
Creates a new big-endian buffer whose content is a copy of the specifiedarray. The new buffer'sreaderIndexandwriterIndexare0andarray.lengthrespectively.
-
copiedBuffer
public static ChannelBuffer copiedBuffer(java.nio.ByteOrder endianness, byte[] array)
Creates a new buffer with the specifiedendiannesswhose content is a copy of the specifiedarray. The new buffer'sreaderIndexandwriterIndexare0andarray.lengthrespectively.
-
copiedBuffer
public static ChannelBuffer copiedBuffer(byte[] array, int offset, int length)
Creates a new big-endian buffer whose content is a copy of the specifiedarray's sub-region. The new buffer'sreaderIndexandwriterIndexare0and the specifiedlengthrespectively.
-
copiedBuffer
public static ChannelBuffer copiedBuffer(java.nio.ByteOrder endianness, byte[] array, int offset, int length)
Creates a new buffer with the specifiedendiannesswhose content is a copy of the specifiedarray's sub-region. The new buffer'sreaderIndexandwriterIndexare0and the specifiedlengthrespectively.
-
copiedBuffer
public static ChannelBuffer copiedBuffer(java.nio.ByteBuffer buffer)
Creates a new buffer whose content is a copy of the specifiedbuffer's current slice. The new buffer'sreaderIndexandwriterIndexare0andbuffer.remainingrespectively.
-
copiedBuffer
public static ChannelBuffer copiedBuffer(ChannelBuffer buffer)
Creates a new buffer whose content is a copy of the specifiedbuffer's readable bytes. The new buffer'sreaderIndexandwriterIndexare0andbuffer.readableBytesrespectively.
-
copiedBuffer
public static ChannelBuffer copiedBuffer(byte[]... arrays)
Creates a new big-endian buffer whose content is a merged copy of the specifiedarrays. The new buffer'sreaderIndexandwriterIndexare0and the sum of all arrays'lengthrespectively.
-
copiedBuffer
public static ChannelBuffer copiedBuffer(java.nio.ByteOrder endianness, byte[]... arrays)
Creates a new buffer with the specifiedendiannesswhose content is a merged copy of the specifiedarrays. The new buffer'sreaderIndexandwriterIndexare0and the sum of all arrays'lengthrespectively.
-
copiedBuffer
public static ChannelBuffer copiedBuffer(ChannelBuffer... buffers)
Creates a new buffer whose content is a merged copy of the specifiedbuffers' readable bytes. The new buffer'sreaderIndexandwriterIndexare0and the sum of all buffers'readableBytesrespectively.- Throws:
java.lang.IllegalArgumentException- if the specified buffers' endianness are different from each other
-
copiedBuffer
public static ChannelBuffer copiedBuffer(java.nio.ByteBuffer... buffers)
Creates a new buffer whose content is a merged copy of the specifiedbuffers' slices. The new buffer'sreaderIndexandwriterIndexare0and the sum of all buffers'remainingrespectively.- Throws:
java.lang.IllegalArgumentException- if the specified buffers' endianness are different from each other
-
copiedBuffer
public static ChannelBuffer copiedBuffer(java.lang.CharSequence string, java.nio.charset.Charset charset)
Creates a new big-endian buffer whose content is the specifiedstringencoded in the specifiedcharset. The new buffer'sreaderIndexandwriterIndexare0and the length of the encoded string respectively.
-
copiedBuffer
public static ChannelBuffer copiedBuffer(java.lang.CharSequence string, int offset, int length, java.nio.charset.Charset charset)
Creates a new big-endian buffer whose content is a subregion of the specifiedstringencoded in the specifiedcharset. The new buffer'sreaderIndexandwriterIndexare0and the length of the encoded string respectively.
-
copiedBuffer
public static ChannelBuffer copiedBuffer(java.nio.ByteOrder endianness, java.lang.CharSequence string, java.nio.charset.Charset charset)
Creates a new buffer with the specifiedendiannesswhose content is the specifiedstringencoded in the specifiedcharset. The new buffer'sreaderIndexandwriterIndexare0and the length of the encoded string respectively.
-
copiedBuffer
public static ChannelBuffer copiedBuffer(java.nio.ByteOrder endianness, java.lang.CharSequence string, int offset, int length, java.nio.charset.Charset charset)
Creates a new buffer with the specifiedendiannesswhose content is a subregion of the specifiedstringencoded in the specifiedcharset. The new buffer'sreaderIndexandwriterIndexare0and the length of the encoded string respectively.
-
copiedBuffer
public static ChannelBuffer copiedBuffer(char[] array, java.nio.charset.Charset charset)
Creates a new big-endian buffer whose content is the specifiedarrayencoded in the specifiedcharset. The new buffer'sreaderIndexandwriterIndexare0and the length of the encoded string respectively.
-
copiedBuffer
public static ChannelBuffer copiedBuffer(char[] array, int offset, int length, java.nio.charset.Charset charset)
Creates a new big-endian buffer whose content is a subregion of the specifiedarrayencoded in the specifiedcharset. The new buffer'sreaderIndexandwriterIndexare0and the length of the encoded string respectively.
-
copiedBuffer
public static ChannelBuffer copiedBuffer(java.nio.ByteOrder endianness, char[] array, java.nio.charset.Charset charset)
Creates a new buffer with the specifiedendiannesswhose content is the specifiedarrayencoded in the specifiedcharset. The new buffer'sreaderIndexandwriterIndexare0and the length of the encoded string respectively.
-
copiedBuffer
public static ChannelBuffer copiedBuffer(java.nio.ByteOrder endianness, char[] array, int offset, int length, java.nio.charset.Charset charset)
Creates a new buffer with the specifiedendiannesswhose content is a subregion of the specifiedarrayencoded in the specifiedcharset. The new buffer'sreaderIndexandwriterIndexare0and the length of the encoded string respectively.
-
copiedBuffer
private static ChannelBuffer copiedBuffer(java.nio.ByteOrder endianness, java.nio.CharBuffer buffer, java.nio.charset.Charset charset)
-
unmodifiableBuffer
public static ChannelBuffer unmodifiableBuffer(ChannelBuffer buffer)
Creates a read-only buffer which disallows any modification operations on the specifiedbuffer. The new buffer has the samereaderIndexandwriterIndexwith the specifiedbuffer.
-
hexDump
public static ChannelBuffer hexDump(java.lang.String hexString)
Create aChannelBufferfrom the given hex dump
-
hexDump
public static java.lang.String hexDump(ChannelBuffer buffer)
Returns a hex dump of the specified buffer's readable bytes.
-
hexDump
public static java.lang.String hexDump(ChannelBuffer buffer, int fromIndex, int length)
Returns a hex dump of the specified buffer's sub-region.
-
hashCode
public static int hashCode(ChannelBuffer buffer)
Calculates the hash code of the specified buffer. This method is useful when implementing a new buffer type.
-
equals
public static boolean equals(ChannelBuffer bufferA, ChannelBuffer bufferB)
Returnstrueif and only if the two specified buffers are identical to each other as described inChannelBuffer#equals(Object). This method is useful when implementing a new buffer type.
-
compare
public static int compare(ChannelBuffer bufferA, ChannelBuffer bufferB)
Compares the two specified buffers as described inChannelBuffer.compareTo(ChannelBuffer). This method is useful when implementing a new buffer type.
-
indexOf
public static int indexOf(ChannelBuffer buffer, int fromIndex, int toIndex, byte value)
The default implementation ofChannelBuffer.indexOf(int, int, byte). This method is useful when implementing a new buffer type.
-
indexOf
public static int indexOf(ChannelBuffer buffer, int fromIndex, int toIndex, ChannelBufferIndexFinder indexFinder)
The default implementation ofChannelBuffer.indexOf(int, int, ChannelBufferIndexFinder). This method is useful when implementing a new buffer type.
-
swapShort
public static short swapShort(short value)
Toggles the endianness of the specified 16-bit short integer.
-
swapMedium
public static int swapMedium(int value)
Toggles the endianness of the specified 24-bit medium integer.
-
swapInt
public static int swapInt(int value)
Toggles the endianness of the specified 32-bit integer.
-
swapLong
public static long swapLong(long value)
Toggles the endianness of the specified 64-bit long integer.
-
firstIndexOf
private static int firstIndexOf(ChannelBuffer buffer, int fromIndex, int toIndex, byte value)
-
lastIndexOf
private static int lastIndexOf(ChannelBuffer buffer, int fromIndex, int toIndex, byte value)
-
firstIndexOf
private static int firstIndexOf(ChannelBuffer buffer, int fromIndex, int toIndex, ChannelBufferIndexFinder indexFinder)
-
lastIndexOf
private static int lastIndexOf(ChannelBuffer buffer, int fromIndex, int toIndex, ChannelBufferIndexFinder indexFinder)
-
encodeString
static java.nio.ByteBuffer encodeString(java.nio.CharBuffer src, java.nio.charset.Charset charset)
-
decodeString
static java.lang.String decodeString(java.nio.ByteBuffer src, java.nio.charset.Charset charset)
-
-