Class ByteBufUtil
- java.lang.Object
-
- net.lax1dude.eaglercraft.v1_8.netty.ByteBufUtil
-
public final class ByteBufUtil extends java.lang.ObjectA collection of utility methods that is related with handlingByteBuf, such as the generation of hex dump and swapping an integer's byte order.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intcompare(ByteBuf bufferA, ByteBuf bufferB)Compares the two specified buffers as described inByteBuf.compareTo(ByteBuf).static bytedecodeHexByte(java.lang.CharSequence s, int pos)Decode a 2-digit hex byte from within a string.static ByteBufencodeString(java.nio.CharBuffer src, java.nio.charset.Charset charset)Encode the givenCharBufferusing the givenCharsetinto a newByteBufwhich is allocated via theByteBufAllocator.static booleanequals(ByteBuf bufferA, ByteBuf bufferB)Returnstrueif and only if the two specified buffers are identical to each other as described inChannelBuffer#equals(Object).static inthashCode(ByteBuf buffer)Calculates the hash code of the specified buffer.static intindexOf(ByteBuf buffer, int fromIndex, int toIndex, byte value)The default implementation ofByteBuf.indexOf(int, int, byte).static booleanisText(ByteBuf buf, int index, int length, java.nio.charset.Charset charset)Returnstrueif the specifiedByteBufstarting atindexwithlengthis valid text using the givenCharset, otherwise returnfalse.static booleanisText(ByteBuf buf, java.nio.charset.Charset charset)static ByteBufreadBytes(ByteBuf buffer, int length)Read the given amount of bytes into a newByteBufthat is allocated from theByteBufAllocator.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 ByteBufwriteUtf8(java.lang.CharSequence seq)static intwriteUtf8(ByteBuf buf, java.lang.CharSequence seq)
-
-
-
Method Detail
-
decodeHexByte
public static byte decodeHexByte(java.lang.CharSequence s, int pos)Decode a 2-digit hex byte from within a string.
-
hashCode
public static int hashCode(ByteBuf buffer)
Calculates the hash code of the specified buffer. This method is useful when implementing a new buffer type.
-
equals
public static boolean equals(ByteBuf bufferA, ByteBuf 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(ByteBuf bufferA, ByteBuf bufferB)
Compares the two specified buffers as described inByteBuf.compareTo(ByteBuf). This method is useful when implementing a new buffer type.
-
indexOf
public static int indexOf(ByteBuf buffer, int fromIndex, int toIndex, byte value)
The default implementation ofByteBuf.indexOf(int, int, byte). 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.
-
readBytes
public static ByteBuf readBytes(ByteBuf buffer, int length)
Read the given amount of bytes into a newByteBufthat is allocated from theByteBufAllocator.
-
writeUtf8
public static ByteBuf writeUtf8(java.lang.CharSequence seq)
-
writeUtf8
public static int writeUtf8(ByteBuf buf, java.lang.CharSequence seq)
-
encodeString
public static ByteBuf encodeString(java.nio.CharBuffer src, java.nio.charset.Charset charset)
Encode the givenCharBufferusing the givenCharsetinto a newByteBufwhich is allocated via theByteBufAllocator.
-
isText
public static boolean isText(ByteBuf buf, java.nio.charset.Charset charset)
- Parameters:
buf- The givenByteBuf.charset- The specifiedCharset.
-
isText
public static boolean isText(ByteBuf buf, int index, int length, java.nio.charset.Charset charset)
Returnstrueif the specifiedByteBufstarting atindexwithlengthis valid text using the givenCharset, otherwise returnfalse.- Parameters:
buf- The givenByteBuf.index- The start index of the specified buffer.length- The length of the specified buffer.charset- The specifiedCharset.- Throws:
java.lang.IndexOutOfBoundsException- ifindex+lengthis greater thanbuf.readableBytes
-
-