Class JsonInput
java.lang.Object
io.protostuff.JsonInput
- All Implemented Interfaces:
Input
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate intprivate booleanfinal booleanIf true, the field number will be used on json keys.final com.fasterxml.jackson.core.JsonParserThe wrapped json parser. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintGets the last field number read.<T> voidhandleUnknownField(int fieldNumber, Schema<T> schema) The underlying implementation should handle the unknown field.booleanReturns true if the last read field was a repeated field.booleanReturns whether the incoming messages' field names are numeric.<T> TmergeObject(T value, Schema<T> schema) Merges an object(with schema) field value.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.private <T> intreadFieldNumber(Schema<T> schema, com.fasterxml.jackson.core.JsonParser parser) 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.reset()Resets this input.private voidskipField(com.fasterxml.jackson.core.JsonParser parser) Skip through the entire object/array field and all nested objects/arrays inside itvoidtransferByteRangeTo(Output output, boolean utf8String, int fieldNumber, boolean repeated) Transfer the byte range to the output.
-
Field Details
-
parser
public final com.fasterxml.jackson.core.JsonParser parserThe wrapped json parser. -
numeric
public final boolean numericIf true, the field number will be used on json keys. -
lastRepeated
private boolean lastRepeated -
lastName
-
lastNumber
private int lastNumber
-
-
Constructor Details
-
JsonInput
public JsonInput(com.fasterxml.jackson.core.JsonParser parser) -
JsonInput
public JsonInput(com.fasterxml.jackson.core.JsonParser parser, boolean numeric)
-
-
Method Details
-
isNumeric
public boolean isNumeric()Returns whether the incoming messages' field names are numeric. -
getLastNumber
public int getLastNumber()Gets the last field number read. -
isLastRepeated
public boolean isLastRepeated()Returns true if the last read field was a repeated field. -
reset
Resets this input. -
handleUnknownField
Description copied from interface:InputThe underlying implementation should handle the unknown field.- Specified by:
handleUnknownFieldin interfaceInput- 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
-
readFieldNumber
private <T> int readFieldNumber(Schema<T> schema, com.fasterxml.jackson.core.JsonParser parser) throws IOException - Throws:
IOException
-
readBool
Description copied from interface:InputReads a boolean field value.- Specified by:
readBoolin interfaceInput- Throws:
IOException
-
readByteArray
Description copied from interface:InputReads a byte array field value.- Specified by:
readByteArrayin 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
-
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
-
readFloat
Description copied from interface:InputReads a float field value.- Specified by:
readFloatin 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
-
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
-
readString
Description copied from interface:InputReads aStringfield value.- Specified by:
readStringin 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
-
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
-
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
-
skipField
Skip through the entire object/array field and all nested objects/arrays inside it- Throws:
IOException
-