public final class ProtobufOutput extends WriteSession implements Output
OutputStream).WriteSession.FlushHandler| Modifier and Type | Field and Description |
|---|---|
static int |
LITTLE_ENDIAN_32_SIZE |
static int |
LITTLE_ENDIAN_64_SIZE |
flushHandler, head, nextBufferSize, out, sink, size, tail| Constructor and Description |
|---|
ProtobufOutput(LinkedBuffer buffer) |
ProtobufOutput(LinkedBuffer buffer,
int nextBufferSize) |
| Modifier and Type | Method and Description |
|---|---|
ProtobufOutput |
clear()
Resets this output for re-use.
|
static int |
computeRawVarint32Size(int value)
Compute the number of bytes that would be needed to encode a varint.
|
static int |
computeRawVarint64Size(long value)
Compute the number of bytes that would be needed to encode a varint.
|
static int |
encodeZigZag32(int n)
Encode a ZigZag-encoded 32-bit value.
|
static long |
encodeZigZag64(long n)
Encode a ZigZag-encoded 64-bit value.
|
static byte[] |
getRawVarInt32Bytes(int value)
Returns the byte array computed from the var int 32 size
|
static byte[] |
getTagAndRawLittleEndian32Bytes(int tag,
int value)
Returns a byte array encoded with the tag and little endian 32
|
static byte[] |
getTagAndRawLittleEndian64Bytes(int tag,
long value)
Returns a byte array encoded with the tag and little endian 64
|
static byte[] |
getTagAndRawVarInt32Bytes(int tag,
int value)
Returns a byte array encoded with the tag and var int 32
|
static byte[] |
getTagAndRawVarInt64Bytes(int tag,
long value)
Returns a byte array encoded with the tag and var int 64
|
void |
writeBool(int fieldNumber,
boolean value,
boolean repeated) |
void |
writeByteArray(int fieldNumber,
byte[] bytes,
boolean repeated) |
void |
writeByteRange(boolean utf8String,
int fieldNumber,
byte[] value,
int offset,
int length,
boolean repeated) |
void |
writeBytes(int fieldNumber,
ByteBuffer value,
boolean repeated)
Writes a ByteBuffer field.
|
void |
writeBytes(int fieldNumber,
ByteString value,
boolean repeated) |
void |
writeDouble(int fieldNumber,
double value,
boolean repeated) |
void |
writeEnum(int fieldNumber,
int number,
boolean repeated) |
void |
writeFixed32(int fieldNumber,
int value,
boolean repeated) |
void |
writeFixed64(int fieldNumber,
long value,
boolean repeated) |
void |
writeFloat(int fieldNumber,
float value,
boolean repeated) |
void |
writeInt32(int fieldNumber,
int value,
boolean repeated) |
void |
writeInt64(int fieldNumber,
long value,
boolean repeated) |
<T> void |
writeObject(int fieldNumber,
T value,
Schema<T> schema,
boolean repeated) |
static int |
writeRawLittleEndian32(int value,
byte[] buffer,
int offset)
Writes the encoded little endian 32 and returns the bytes written
|
static int |
writeRawLittleEndian64(long value,
byte[] buffer,
int offset)
Writes the encoded little endian 64 and returns the bytes written
|
static void |
writeRawVarInt32(int value,
byte[] buf,
int offset)
Encode and write a varint to the byte array
|
static LinkedBuffer |
writeRawVarInt32(int value,
WriteSession session,
LinkedBuffer lb)
Returns the buffer encoded with the variable int 32.
|
static void |
writeRawVarInt32Bytes(DataOutput out,
int value)
Encode and write a varint to the
DataOutput |
static void |
writeRawVarInt32Bytes(OutputStream out,
int value)
Encode and write a varint to the
OutputStream |
void |
writeSFixed32(int fieldNumber,
int value,
boolean repeated) |
void |
writeSFixed64(int fieldNumber,
long value,
boolean repeated) |
void |
writeSInt32(int fieldNumber,
int value,
boolean repeated) |
void |
writeSInt64(int fieldNumber,
long value,
boolean repeated) |
void |
writeString(int fieldNumber,
String value,
boolean repeated) |
static LinkedBuffer |
writeTagAndByteArray(int tag,
byte[] value,
int offset,
int valueLen,
WriteSession session,
LinkedBuffer lb)
Returns the buffer encoded with the tag and byte array
|
static LinkedBuffer |
writeTagAndLinkedBuffer(int tag,
LinkedBuffer buffer,
WriteSession session,
LinkedBuffer lb)
Returns the buffer encoded with the tag and LinkedBuffer (zero-copy)
|
static LinkedBuffer |
writeTagAndRawLittleEndian32(int tag,
int value,
WriteSession session,
LinkedBuffer lb)
Returns the buffer encoded with the tag and little endian 32
|
static LinkedBuffer |
writeTagAndRawLittleEndian64(int tag,
long value,
WriteSession session,
LinkedBuffer lb)
Returns the buffer encoded with the tag and little endian 64
|
static LinkedBuffer |
writeTagAndRawVarInt32(int tag,
int value,
WriteSession session,
LinkedBuffer lb)
Returns the buffer encoded with the tag and var int 32
|
static LinkedBuffer |
writeTagAndRawVarInt64(int tag,
long value,
WriteSession session,
LinkedBuffer lb)
Returns the buffer encoded with the tag and var int 64
|
void |
writeUInt32(int fieldNumber,
int value,
boolean repeated) |
void |
writeUInt64(int fieldNumber,
long value,
boolean repeated) |
flush, flush, flush, getSize, reset, toByteArraypublic static final int LITTLE_ENDIAN_32_SIZE
public static final int LITTLE_ENDIAN_64_SIZE
public ProtobufOutput(LinkedBuffer buffer)
public ProtobufOutput(LinkedBuffer buffer, int nextBufferSize)
public ProtobufOutput clear()
clear in class WriteSessionpublic void writeInt32(int fieldNumber,
int value,
boolean repeated)
throws IOException
writeInt32 in interface OutputIOExceptionpublic void writeUInt32(int fieldNumber,
int value,
boolean repeated)
throws IOException
writeUInt32 in interface OutputIOExceptionpublic void writeSInt32(int fieldNumber,
int value,
boolean repeated)
throws IOException
writeSInt32 in interface OutputIOExceptionpublic void writeFixed32(int fieldNumber,
int value,
boolean repeated)
throws IOException
writeFixed32 in interface OutputIOExceptionpublic void writeSFixed32(int fieldNumber,
int value,
boolean repeated)
throws IOException
writeSFixed32 in interface OutputIOExceptionpublic void writeInt64(int fieldNumber,
long value,
boolean repeated)
throws IOException
writeInt64 in interface OutputIOExceptionpublic void writeUInt64(int fieldNumber,
long value,
boolean repeated)
throws IOException
writeUInt64 in interface OutputIOExceptionpublic void writeSInt64(int fieldNumber,
long value,
boolean repeated)
throws IOException
writeSInt64 in interface OutputIOExceptionpublic void writeFixed64(int fieldNumber,
long value,
boolean repeated)
throws IOException
writeFixed64 in interface OutputIOExceptionpublic void writeSFixed64(int fieldNumber,
long value,
boolean repeated)
throws IOException
writeSFixed64 in interface OutputIOExceptionpublic void writeFloat(int fieldNumber,
float value,
boolean repeated)
throws IOException
writeFloat in interface OutputIOExceptionpublic void writeDouble(int fieldNumber,
double value,
boolean repeated)
throws IOException
writeDouble in interface OutputIOExceptionpublic void writeBool(int fieldNumber,
boolean value,
boolean repeated)
throws IOException
writeBool in interface OutputIOExceptionpublic void writeEnum(int fieldNumber,
int number,
boolean repeated)
throws IOException
writeEnum in interface OutputIOExceptionpublic void writeString(int fieldNumber,
String value,
boolean repeated)
throws IOException
writeString in interface OutputIOExceptionpublic void writeBytes(int fieldNumber,
ByteString value,
boolean repeated)
throws IOException
writeBytes in interface OutputIOExceptionpublic void writeByteArray(int fieldNumber,
byte[] bytes,
boolean repeated)
throws IOException
writeByteArray in interface OutputIOExceptionpublic void writeByteRange(boolean utf8String,
int fieldNumber,
byte[] value,
int offset,
int length,
boolean repeated)
throws IOException
writeByteRange in interface OutputIOExceptionpublic <T> void writeObject(int fieldNumber,
T value,
Schema<T> schema,
boolean repeated)
throws IOException
writeObject in interface OutputIOExceptionpublic static LinkedBuffer writeRawVarInt32(int value, WriteSession session, LinkedBuffer lb)
public static LinkedBuffer writeTagAndLinkedBuffer(int tag, LinkedBuffer buffer, WriteSession session, LinkedBuffer lb)
public static LinkedBuffer writeTagAndByteArray(int tag, byte[] value, int offset, int valueLen, WriteSession session, LinkedBuffer lb)
public static LinkedBuffer writeTagAndRawVarInt32(int tag, int value, WriteSession session, LinkedBuffer lb)
public static LinkedBuffer writeTagAndRawVarInt64(int tag, long value, WriteSession session, LinkedBuffer lb)
public static LinkedBuffer writeTagAndRawLittleEndian32(int tag, int value, WriteSession session, LinkedBuffer lb)
public static LinkedBuffer writeTagAndRawLittleEndian64(int tag, long value, WriteSession session, LinkedBuffer lb)
public static void writeRawVarInt32(int value,
byte[] buf,
int offset)
throws IOException
IOExceptionpublic static void writeRawVarInt32Bytes(OutputStream out, int value) throws IOException
OutputStreamIOExceptionpublic static void writeRawVarInt32Bytes(DataOutput out, int value) throws IOException
DataOutputIOExceptionpublic static byte[] getTagAndRawVarInt32Bytes(int tag,
int value)
public static byte[] getTagAndRawVarInt64Bytes(int tag,
long value)
public static byte[] getTagAndRawLittleEndian32Bytes(int tag,
int value)
public static byte[] getTagAndRawLittleEndian64Bytes(int tag,
long value)
public static int writeRawLittleEndian32(int value,
byte[] buffer,
int offset)
public static int writeRawLittleEndian64(long value,
byte[] buffer,
int offset)
public static byte[] getRawVarInt32Bytes(int value)
public static int computeRawVarint32Size(int value)
value is treated as unsigned, so it
won't be sign-extended if negative.public static int computeRawVarint64Size(long value)
public static int encodeZigZag32(int n)
n - A signed 32-bit integer.public static long encodeZigZag64(long n)
n - A signed 64-bit integer.public void writeBytes(int fieldNumber,
ByteBuffer value,
boolean repeated)
throws IOException
writeBytes in interface OutputIOExceptionCopyright © 2009–2015. All rights reserved.