@Override public ByteBuf setInt(int index, int value) { buf.setInt(index, ByteBufUtil.swapInt(value)); return this; }
/** * Writes the 2-byte chunk length to the output buffer. * * @param out The buffer to write to * @param chunkLength The length to write */ private static void writeChunkLength(ByteBuf out, int chunkLength) { out.writeMedium(ByteBufUtil.swapMedium(chunkLength)); }
private static short shortBE(ByteBuffer buffer, int offset) { return buffer.order() == ByteOrder.BIG_ENDIAN ? buffer.getShort(offset) : ByteBufUtil.swapShort(buffer.getShort(offset)); }
return NOT_ENOUGH_INPUT; length = ByteBufUtil.swapShort(in.readShort()); break; case 62: return NOT_ENOUGH_INPUT; length = ByteBufUtil.swapMedium(in.readUnsignedMedium()); break; case 63: return NOT_ENOUGH_INPUT; length = ByteBufUtil.swapInt(in.readInt()); break; default:
return NOT_ENOUGH_INPUT; length = ByteBufUtil.swapMedium(in.readUnsignedMedium()); break; case 63: length = ByteBufUtil.swapInt(in.readInt()); break; default:
res = bufferAIsBigEndian ? compareUintBigEndian(bufferA, bufferB, aIndex, bIndex, uintCountIncrement) : compareUintLittleEndian(bufferA, bufferB, aIndex, bIndex, uintCountIncrement); } else { res = bufferAIsBigEndian ? compareUintBigEndianA(bufferA, bufferB, aIndex, bIndex, uintCountIncrement) : compareUintBigEndianB(bufferA, bufferB, aIndex, bIndex, uintCountIncrement);
/** * Helper method to encode a String into UTF8 via fast-path methods. * * @param source the source document. * @return the encoded byte buffer. */ public static ByteBuf encodeStringAsUtf8(String source) { ByteBuf target = Unpooled.buffer(source.length()); ByteBufUtil.writeUtf8(target, source); return target; }
/** * Appends the prettified multi-line hexadecimal dump of the specified {@link ByteBuf} to the specified * {@link StringBuilder} that is easy to read by humans, starting at the given {@code offset} using * the given {@code length}. */ public static void appendPrettyHexDump(StringBuilder dump, ByteBuf buf, int offset, int length) { HexUtil.appendPrettyHexDump(dump, buf, offset, length); }
@Override public int compareTo(ByteBuf that) { return ByteBufUtil.compare(this, that); }
return NOT_ENOUGH_INPUT; length = ByteBufUtil.swapShort(in.readShort()); break; case 62: return NOT_ENOUGH_INPUT; length = ByteBufUtil.swapMedium(in.readUnsignedMedium()); break; case 63: return NOT_ENOUGH_INPUT; length = ByteBufUtil.swapInt(in.readInt()); break; default:
final int chunkLength = ByteBufUtil.swapMedium(in.getUnsignedMedium(idx + 1)); int checksum = ByteBufUtil.swapInt(in.readInt()); validateChecksum(checksum, in, in.readerIndex(), chunkLength - 4); } else { int checksum = ByteBufUtil.swapInt(in.readInt()); ByteBuf uncompressed = ctx.alloc().buffer(0); if (validateChecksums) {
res = bufferAIsBigEndian ? compareUintBigEndian(bufferA, bufferB, aIndex, bIndex, uintCountIncrement) : compareUintLittleEndian(bufferA, bufferB, aIndex, bIndex, uintCountIncrement); } else { res = bufferAIsBigEndian ? compareUintBigEndianA(bufferA, bufferB, aIndex, bIndex, uintCountIncrement) : compareUintBigEndianB(bufferA, bufferB, aIndex, bIndex, uintCountIncrement);
/** * Encode a {@link CharSequence} in <a href="http://en.wikipedia.org/wiki/UTF-8">UTF-8</a> and write * it to a {@link ByteBuf} allocated with {@code alloc}. * @param alloc The allocator used to allocate a new {@link ByteBuf}. * @param seq The characters to write into a buffer. * @return The {@link ByteBuf} which contains the <a href="http://en.wikipedia.org/wiki/UTF-8">UTF-8</a> encoded * result. */ public static ByteBuf writeUtf8(ByteBufAllocator alloc, CharSequence seq) { // UTF-8 uses max. 3 bytes per char, so calculate the worst case. ByteBuf buf = alloc.buffer(seq.length() * MAX_BYTES_PER_CHAR_UTF8); writeUtf8(buf, seq); return buf; }
/** * Appends the prettified multi-line hexadecimal dump of the specified {@link ByteBuf} to the specified * {@link StringBuilder} that is easy to read by humans, starting at the given {@code offset} using * the given {@code length}. */ public static void appendPrettyHexDump(StringBuilder dump, ByteBuf buf, int offset, int length) { HexUtil.appendPrettyHexDump(dump, buf, offset, length); }
@Override public int compareTo(ByteBuf buffer) { return ByteBufUtil.compare(this, buffer); }
@Override public ByteBuf writeInt(int value) { buf.writeInt(ByteBufUtil.swapInt(value)); return this; }
private static short shortBE(ByteBuffer buffer, int offset) { return buffer.order() == ByteOrder.BIG_ENDIAN ? buffer.getShort(offset) : ByteBufUtil.swapShort(buffer.getShort(offset)); }
@Override public ByteBuf setMedium(int index, int value) { buf.setMedium(index, ByteBufUtil.swapMedium(value)); return this; }
final int chunkLength = ByteBufUtil.swapMedium(in.getUnsignedMedium(idx + 1)); int checksum = ByteBufUtil.swapInt(in.readInt()); validateChecksum(checksum, in, in.readerIndex(), chunkLength - 4); } else { int checksum = ByteBufUtil.swapInt(in.readInt()); ByteBuf uncompressed = ctx.alloc().buffer(0); if (validateChecksums) {
/** * Encode a {@link CharSequence} in <a href="http://en.wikipedia.org/wiki/UTF-8">UTF-8</a> and write * it to a {@link ByteBuf} allocated with {@code alloc}. * @param alloc The allocator used to allocate a new {@link ByteBuf}. * @param seq The characters to write into a buffer. * @return The {@link ByteBuf} which contains the <a href="http://en.wikipedia.org/wiki/UTF-8">UTF-8</a> encoded * result. */ public static ByteBuf writeUtf8(ByteBufAllocator alloc, CharSequence seq) { // UTF-8 uses max. 3 bytes per char, so calculate the worst case. ByteBuf buf = alloc.buffer(seq.length() * MAX_BYTES_PER_CHAR_UTF8); writeUtf8(buf, seq); return buf; }