public final class ByteBufferInput extends java.lang.Object implements Input
IOUtil where it catches
ArrayIndexOutOfBoundsException when a message is truncated.| Modifier and Type | Field and Description |
|---|---|
boolean |
decodeNestedMessageAsGroup
If true, the nested messages are group-encoded
|
| Constructor and Description |
|---|
ByteBufferInput(java.nio.ByteBuffer buffer,
boolean protostuffMessage)
An input for a ByteBuffer
|
| Modifier and Type | Method and Description |
|---|---|
void |
checkLastTagWas(int value)
Verifies that the last call to readTag() returned the given tag value.
|
int |
currentLimit()
Returns the current limit (the end index).
|
int |
currentOffset()
Returns the current offset (the position).
|
int |
getLastTag()
Returns the last tag.
|
<T> void |
handleUnknownField(int fieldNumber,
Schema<T> schema) |
boolean |
isCurrentFieldPacked()
Return true if currently reading packed field
|
<T> T |
mergeObject(T value,
Schema<T> schema) |
boolean |
readBool()
Read a
bool field value from the internal buffer. |
byte[] |
readByteArray() |
java.nio.ByteBuffer |
readByteBuffer()
Reads a byte array/ByteBuffer value.
|
ByteString |
readBytes() |
double |
readDouble()
Read a
double field value from the internal buffer. |
int |
readEnum()
Read an enum field value from the internal buffer.
|
<T> int |
readFieldNumber(Schema<T> schema) |
int |
readFixed32()
Read a
fixed32 field value from the internal buffer. |
long |
readFixed64()
Read a
fixed64 field value from the internal buffer. |
float |
readFloat()
Read a
float field value from the internal buffer. |
int |
readInt32()
Read an
int32 field value from the internal buffer. |
long |
readInt64()
Read an
int64 field value from the internal buffer. |
int |
readRawLittleEndian32()
Read a 32-bit little-endian integer from the internal buffer.
|
long |
readRawLittleEndian64()
Read a 64-bit little-endian integer from the internal byte buffer.
|
int |
readRawVarint32()
Reads a var int 32 from the internal byte buffer.
|
long |
readRawVarint64()
Reads a var int 64 from the internal byte buffer.
|
int |
readSFixed32()
Read an
sfixed32 field value from the internal buffer. |
long |
readSFixed64()
Read an
sfixed64 field value from the internal buffer. |
int |
readSInt32()
Read an
sint32 field value from the internal buffer. |
long |
readSInt64()
Read an
sint64 field value from the internal buffer. |
java.lang.String |
readString() |
int |
readTag()
Attempt to read a field tag, returning zero if we have reached EOF.
|
int |
readUInt32()
Read a
uint32 field value from the internal buffer. |
long |
readUInt64()
Read a
uint64 field value from the internal buffer. |
ByteBufferInput |
reset(int offset,
int len)
Resets the offset and the limit of the internal buffer.
|
boolean |
skipField(int tag)
Reads and discards a single field, given its tag value.
|
void |
skipMessage()
Reads and discards an entire message.
|
void |
transferByteRangeTo(Output output,
boolean utf8String,
int fieldNumber,
boolean repeated) |
public final boolean decodeNestedMessageAsGroup
public ByteBufferInput(java.nio.ByteBuffer buffer,
boolean protostuffMessage)
buffer - the buffer to read from, it will be slicedprotostuffMessage - if we are parsing a protostuff (true) or protobuf (false) messagepublic ByteBufferInput reset(int offset, int len)
public int currentOffset()
public int currentLimit()
public boolean isCurrentFieldPacked()
public int getLastTag()
public int readTag()
throws java.io.IOException
java.io.IOExceptionpublic void checkLastTagWas(int value)
throws ProtobufException
ProtobufException - value does not match the last tag.public boolean skipField(int tag)
throws java.io.IOException
false if the tag is an endgroup tag, in which case nothing is skipped. Otherwise, returns
true.java.io.IOExceptionpublic void skipMessage()
throws java.io.IOException
java.io.IOExceptionpublic <T> void handleUnknownField(int fieldNumber,
Schema<T> schema)
throws java.io.IOException
handleUnknownField in interface Inputjava.io.IOExceptionpublic <T> int readFieldNumber(Schema<T> schema) throws java.io.IOException
readFieldNumber in interface Inputjava.io.IOExceptionpublic double readDouble()
throws java.io.IOException
double field value from the internal buffer.readDouble in interface Inputjava.io.IOExceptionpublic float readFloat()
throws java.io.IOException
float field value from the internal buffer.public long readUInt64()
throws java.io.IOException
uint64 field value from the internal buffer.readUInt64 in interface Inputjava.io.IOExceptionpublic long readInt64()
throws java.io.IOException
int64 field value from the internal buffer.public int readInt32()
throws java.io.IOException
int32 field value from the internal buffer.public long readFixed64()
throws java.io.IOException
fixed64 field value from the internal buffer.readFixed64 in interface Inputjava.io.IOExceptionpublic int readFixed32()
throws java.io.IOException
fixed32 field value from the internal buffer.readFixed32 in interface Inputjava.io.IOExceptionpublic boolean readBool()
throws java.io.IOException
bool field value from the internal buffer.public int readUInt32()
throws java.io.IOException
uint32 field value from the internal buffer.readUInt32 in interface Inputjava.io.IOExceptionpublic int readEnum()
throws java.io.IOException
public int readSFixed32()
throws java.io.IOException
sfixed32 field value from the internal buffer.readSFixed32 in interface Inputjava.io.IOExceptionpublic long readSFixed64()
throws java.io.IOException
sfixed64 field value from the internal buffer.readSFixed64 in interface Inputjava.io.IOExceptionpublic int readSInt32()
throws java.io.IOException
sint32 field value from the internal buffer.readSInt32 in interface Inputjava.io.IOExceptionpublic long readSInt64()
throws java.io.IOException
sint64 field value from the internal buffer.readSInt64 in interface Inputjava.io.IOExceptionpublic java.lang.String readString()
throws java.io.IOException
readString in interface Inputjava.io.IOExceptionpublic ByteString readBytes() throws java.io.IOException
public byte[] readByteArray()
throws java.io.IOException
readByteArray in interface Inputjava.io.IOExceptionpublic <T> T mergeObject(T value,
Schema<T> schema)
throws java.io.IOException
mergeObject in interface Inputjava.io.IOExceptionpublic int readRawVarint32()
throws java.io.IOException
java.io.IOExceptionpublic long readRawVarint64()
throws java.io.IOException
java.io.IOExceptionpublic int readRawLittleEndian32()
throws java.io.IOException
java.io.IOExceptionpublic long readRawLittleEndian64()
throws java.io.IOException
java.io.IOExceptionpublic void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber, boolean repeated) throws java.io.IOException
transferByteRangeTo in interface Inputjava.io.IOExceptionpublic java.nio.ByteBuffer readByteBuffer()
throws java.io.IOException
readByteBuffer in interface Inputjava.io.IOExceptionCopyright © 2009-2015. All Rights Reserved.