Class KvpInput
java.lang.Object
io.protostuff.KvpInput
- All Implemented Interfaces:
Input
An input for deserializing kvp-encoded messages. A kvp encoding is a binary encoding w/c contains a key-value
sequence. On the wire, a serialized field (key-value) would look like: [key-len][key][value-len][value]
The keys and values are length-delimited (uint16 little endian).
Note that this encoding does not support nested messages. This encoding is mostly useful for headers w/c contain information about the content it carries (see http://projects.unbit.it/uwsgi/wiki/uwsgiProtocol).
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final byte[](package private) static final int(package private) final InputStream(package private) int(package private) static final int(package private) final boolean(package private) int -
Constructor Summary
ConstructorsConstructorDescriptionKvpInput(InputStream in, boolean numeric) KvpInput(InputStream in, byte[] buffer, boolean numeric) KvpInput(InputStream in, byte[] buffer, int offset, int limit, boolean numeric) -
Method Summary
Modifier and TypeMethodDescriptionprivate byte[]fill(byte[] data, int dataOffset, int len) <T> voidhandleUnknownField(int fieldNumber, Schema<T> schema) The underlying implementation should handle the unknown field.<T> TmergeObject(T value, Schema<T> schema) Merges an object(with schema) field value.private booleanreadable(int minimum) Returns true if there areminimumbytes available for reading.booleanreadBool()Reads a boolean field value.byte[]Reads a byte array field value.Reads a byte array/ByteBuffer value.Reads aByteStringfield value.voidreadBytes(ByteBuffer bb) Reads a field value into aByteBuffer.doubleReads a double field value.intreadEnum()Reads an enum(its number) field value.<T> intreadFieldNumber(Schema<T> schema) Reads the field number of a message/object tied to the givenschema.intReads a fixed int(4 bytes) field value.longReads a fixed long(8 bytes) field value.floatReads a float field value.intReads a variable int field value.longReads a variable long field value.intReads a signed+fixed int(4 bytes) field value.longReads a signed+fixed long(8 bytes) field value.intReads a signed int field value.longReads a signed long field value.Reads aStringfield value.intReads an unsigned int field value.longReads an unsigned long field value.voidtransferByteRangeTo(Output output, boolean utf8String, int fieldNumber, boolean repeated) Transfer the byte range to the output.
-
Field Details
-
DEFAULT_BUFFER_SIZE
static final int DEFAULT_BUFFER_SIZE -
MAX_VALUE_SIZE
static final int MAX_VALUE_SIZE -
in
-
buffer
final byte[] buffer -
numeric
final boolean numeric -
offset
int offset -
limit
int limit
-
-
Constructor Details
-
KvpInput
-
KvpInput
-
KvpInput
-
-
Method Details
-
readable
Returns true if there areminimumbytes available for reading.The caller is responsible that the arg
minimumis not larger than the buffer size.- Throws:
IOException
-
fill
- Throws:
IOException
-
readFieldNumber
Description copied from interface:InputReads the field number of a message/object tied to the givenschema.- Specified by:
readFieldNumberin interfaceInput- Throws:
IOException
-
handleUnknownField
Description copied from interface:InputThe underlying implementation should handle the unknown field.- Specified by:
handleUnknownFieldin interfaceInput- Throws:
IOException
-
mergeObject
Description copied from interface:InputMerges an object(with schema) field value. The providedschemahandles the deserialization for the object.- Specified by:
mergeObjectin interfaceInput- Throws:
IOException
-
readBool
Description copied from interface:InputReads a boolean field value.- Specified by:
readBoolin interfaceInput- Throws:
IOException
-
readBytes
Description copied from interface:InputReads aByteStringfield value.- Specified by:
readBytesin interfaceInput- Throws:
IOException
-
readBytes
Description copied from interface:InputReads a field value into aByteBuffer.- Specified by:
readBytesin interfaceInput- Throws:
IOException
-
readDouble
Description copied from interface:InputReads a double field value.- Specified by:
readDoublein interfaceInput- Throws:
IOException
-
readFloat
Description copied from interface:InputReads a float field value.- Specified by:
readFloatin interfaceInput- Throws:
IOException
-
readUInt32
Description copied from interface:InputReads an unsigned int field value.- Specified by:
readUInt32in interfaceInput- Throws:
IOException
-
readUInt64
Description copied from interface:InputReads an unsigned long field value.- Specified by:
readUInt64in interfaceInput- Throws:
IOException
-
readInt32
Description copied from interface:InputReads a variable int field value.- Specified by:
readInt32in interfaceInput- Throws:
IOException
-
readInt64
Description copied from interface:InputReads a variable long field value.- Specified by:
readInt64in interfaceInput- Throws:
IOException
-
readEnum
Description copied from interface:InputReads an enum(its number) field value.- Specified by:
readEnumin interfaceInput- Throws:
IOException
-
readFixed32
Description copied from interface:InputReads a fixed int(4 bytes) field value.- Specified by:
readFixed32in interfaceInput- Throws:
IOException
-
readFixed64
Description copied from interface:InputReads a fixed long(8 bytes) field value.- Specified by:
readFixed64in interfaceInput- Throws:
IOException
-
readSFixed32
Description copied from interface:InputReads a signed+fixed int(4 bytes) field value.- Specified by:
readSFixed32in interfaceInput- Throws:
IOException
-
readSFixed64
Description copied from interface:InputReads a signed+fixed long(8 bytes) field value.- Specified by:
readSFixed64in interfaceInput- Throws:
IOException
-
readSInt32
Description copied from interface:InputReads a signed int field value.- Specified by:
readSInt32in interfaceInput- Throws:
IOException
-
readSInt64
Description copied from interface:InputReads a signed long field value.- Specified by:
readSInt64in interfaceInput- Throws:
IOException
-
readByteArray
Description copied from interface:InputReads a byte array field value.- Specified by:
readByteArrayin interfaceInput- Throws:
IOException
-
readString
Description copied from interface:InputReads aStringfield value.- Specified by:
readStringin interfaceInput- Throws:
IOException
-
transferByteRangeTo
public void transferByteRangeTo(Output output, boolean utf8String, int fieldNumber, boolean repeated) throws IOException Description copied from interface:InputTransfer the byte range to the output. Capable of zero-copy transfer depending on the type of input.- Specified by:
transferByteRangeToin interfaceInput- Throws:
IOException
-
readByteBuffer
Reads a byte array/ByteBuffer value.- Specified by:
readByteBufferin interfaceInput- Throws:
IOException
-