public final class Buffer extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Buffer.Writer<T> |
| Constructor and Description |
|---|
Buffer(int size) |
| Modifier and Type | Method and Description |
|---|---|
static int |
asciiSizeInBytes(long v)
Binary search for character width which favors matching lower numbers.
|
byte[] |
toByteArray() |
static int |
varintSizeInBytes(int value)
A base 128 varint encodes 7 bits at a time, this checks how many bytes are needed to
represent the value.
|
static int |
varintSizeInBytes(long v)
Like
varintSizeInBytes(int), except for uint64. |
Buffer |
write(byte[] v) |
Buffer |
writeAscii(long v) |
Buffer |
writeAscii(String v) |
Buffer |
writeByte(int v) |
Buffer |
writeUtf8(String string)
This transcodes a UTF-16 Java String to UTF-8 bytes.
|
public Buffer writeByte(int v)
public Buffer write(byte[] v)
public Buffer writeUtf8(String string)
This looks most similar to io.netty.buffer.ByteBufUtil.writeUtf8(AbstractByteBuf, int, CharSequence, int)
v4.1, modified including features to address ASCII runs of text.
public static int asciiSizeInBytes(long v)
Adapted from okio.Buffer
public Buffer writeAscii(long v)
public static int varintSizeInBytes(int value)
See https://developers.google.com/protocol-buffers/docs/encoding#varints
This logic is the same as com.squareup.wire.ProtoWriter.varint32Size v2.3.0
which benchmarked faster than loop variants of the frequently copy/pasted VarInt.varIntSize
public static int varintSizeInBytes(long v)
varintSizeInBytes(int), except for uint64.public byte[] toByteArray()
Copyright © 2015–2018 OpenZipkin. All rights reserved.