ByteBufStrings { public static ByteBuf wrapLong(long value) { ByteBuf buf = ByteBufPool.allocate(20); int digits = encodeLong(buf.array, 0, value); buf.moveTail(digits); return buf; }  static void encodeAscii(byte[] array, int pos, String string); static byte[] encodeAscii(String string); static void putAscii(ByteBuf buf, String string); static ByteBuf wrapAscii(String string); static String decodeAscii(byte[] array, int pos, int len, char[] tmpBuffer); static String decodeAscii(byte[] array, int pos, int len); static String asAscii(ByteBuf buf); static String decodeAscii(byte[] array); static void toLowerCaseAscii(byte[] bytes, int pos, int len); static void toLowerCaseAscii(byte[] bytes); static void toLowerCaseAscii(ByteBuf buf); static void toUpperCaseAscii(byte[] bytes, int pos, int len); static void toUpperCaseAscii(byte[] bytes); static void toUpperCaseAscii(ByteBuf buf); static boolean equalsLowerCaseAscii(byte[] lowerCasePattern, byte[] array, int offset, int size); static boolean equalsUpperCaseAscii(byte[] upperCasePattern, byte[] array, int offset, int size); static int hashCode(byte[] array, int offset, int size); static int hashCode(byte[] array); static int hashCode(ByteBuf buf); static int hashCodeLowerCaseAscii(byte[] array, int offset, int size); static int hashCodeLowerCaseAscii(byte[] array); static int hashCodeLowerCaseAscii(ByteBuf buf); static int hashCodeUpperCaseAscii(byte[] array, int offset, int size); static int hashCodeUpperCaseAscii(byte[] array); static int hashCodeUpperCaseAscii(ByteBuf buf); static int encodeUtf8(byte[] array, int pos, String string); static int encodeUtf8(byte[] array, int pos, char c); static void putUtf8(ByteBuf buf, String string); static void putUtf8(ByteBuf buf, char c); static ByteBuf wrapUtf8(String string); static int decodeUtf8(byte[] array, int pos, int len, char[] buffer, int to); static String decodeUtf8(byte[] array, int pos, int len, char[] tmpBuffer); static String decodeUtf8(byte[] array, int pos, int len); static String decodeUtf8(ByteBuf buf, char[] tmpBuffer); static String decodeUtf8(ByteBuf buf); static String decodeUtf8(byte[] array); static String asUtf8(ByteBuf buf); static int encodeInt(byte[] array, int pos, int value); static int encodePositiveInt(byte[] array, int pos, int value); static int encodeLong(byte[] array, int pos, long value); static int encodePositiveLong(byte[] array, int pos, long value); static void putInt(ByteBuf buf, int value); static void putPositiveInt(ByteBuf buf, int value); static void putLong(ByteBuf buf, long value); static void putPositiveLong(ByteBuf buf, long value); static ByteBuf wrapInt(int value); static ByteBuf wrapLong(long value); static int decodeInt(byte[] array, int pos, int len); static long decodeLong(byte[] array, int pos, int len); static int decodePositiveInt(byte[] array, int pos, int len); static long decodePositiveLong(byte[] array, int pos, int len); static final ParseException READ_PAST_LIMIT; static final ParseException READ_PAST_ARRAY_LENGTH; static final byte CR; static final byte LF; static final byte SP; static final byte HT; }
@Test public void testWrapLong() throws ParseException { ByteBuf byteBuf = ByteBufStrings.wrapLong(Long.MAX_VALUE); assertEquals(String.valueOf(Long.MAX_VALUE), ByteBufStrings.decodeUtf8(byteBuf)); byteBuf = ByteBufStrings.wrapLong(Long.MIN_VALUE); assertEquals(String.valueOf(Long.MIN_VALUE), ByteBufStrings.decodeUtf8(byteBuf)); long value = RANDOM.nextLong(); byteBuf = ByteBufStrings.wrapLong(value); assertEquals(String.valueOf(value), ByteBufStrings.decodeUtf8(byteBuf)); }