Package io.protostuff
Class GraphCodedInput
- java.lang.Object
-
- io.protostuff.FilterInput<CodedInput>
-
- io.protostuff.GraphCodedInput
-
- All Implemented Interfaces:
GraphInput,Input,Schema<java.lang.Object>
public final class GraphCodedInput extends FilterInput<CodedInput> implements GraphInput, Schema<java.lang.Object>
A CodedInput w/c can handle cyclic dependencies when deserializing objects with graph transformations.
-
-
Field Summary
Fields Modifier and Type Field Description private intlastRefprivate Schema<java.lang.Object>lastSchemaprivate booleanmessageReferenceprivate java.util.ArrayList<java.lang.Object>references-
Fields inherited from class io.protostuff.FilterInput
input
-
-
Constructor Summary
Constructors Constructor Description GraphCodedInput(CodedInput input)GraphCodedInput(CodedInput input, int initialCapacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetFieldName(int number)Gets the field name associated with the number.intgetFieldNumber(java.lang.String name)Gets the field number associated with the name.<T> voidhandleUnknownField(int fieldNumber, Schema<T> schema)The underlying implementation should handle the unknown field.booleanisCurrentMessageReference()Returns true if the last message was read as a reference.booleanisInitialized(java.lang.Object owner)Returns true if there is no required field or if all the required fields are set.voidmergeFrom(Input input, java.lang.Object message)Deserializes a message/object from theinput.<T> TmergeObject(T value, Schema<T> schema)Merges an object(with schema) field value.java.lang.StringmessageFullName()Returns the full name of the message tied to this schema.java.lang.StringmessageName()Returns the simple name of the message tied to this schema.java.lang.ObjectnewMessage()Creates the message/object tied to this schema.<T> intreadFieldNumber(Schema<T> schema)Reads the field number of a message/object tied to the givenschema.java.lang.Class<? super java.lang.Object>typeClass()Gets the class of the message.voidupdateLast(java.lang.Object morphedMessage, java.lang.Object lastMessage)Updates the last reference (the tip/end of the index) kept if thelastMessagewas indeed the last message.voidwriteTo(Output output, java.lang.Object message)Serializes a message/object to theoutput.-
Methods inherited from class io.protostuff.FilterInput
readBool, readByteArray, readByteBuffer, readBytes, readBytes, readDouble, readEnum, readFixed32, readFixed64, readFloat, readInt32, readInt64, readSFixed32, readSFixed64, readSInt32, readSInt64, readString, readUInt32, readUInt64, transferByteRangeTo
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.protostuff.Input
readBool, readByteArray, readByteBuffer, readBytes, readBytes, readDouble, readEnum, readFixed32, readFixed64, readFloat, readInt32, readInt64, readSFixed32, readSFixed64, readSInt32, readSInt64, readString, readUInt32, readUInt64, transferByteRangeTo
-
-
-
-
Field Detail
-
references
private final java.util.ArrayList<java.lang.Object> references
-
lastRef
private int lastRef
-
lastSchema
private Schema<java.lang.Object> lastSchema
-
messageReference
private boolean messageReference
-
-
Constructor Detail
-
GraphCodedInput
public GraphCodedInput(CodedInput input)
-
GraphCodedInput
public GraphCodedInput(CodedInput input, int initialCapacity)
-
-
Method Detail
-
updateLast
public void updateLast(java.lang.Object morphedMessage, java.lang.Object lastMessage)Description copied from interface:GraphInputUpdates the last reference (the tip/end of the index) kept if thelastMessagewas indeed the last message.- Specified by:
updateLastin interfaceGraphInput
-
isCurrentMessageReference
public boolean isCurrentMessageReference()
Description copied from interface:GraphInputReturns true if the last message was read as a reference.- Specified by:
isCurrentMessageReferencein interfaceGraphInput
-
readFieldNumber
public <T> int readFieldNumber(Schema<T> schema) throws java.io.IOException
Description copied from interface:InputReads the field number of a message/object tied to the givenschema.- Specified by:
readFieldNumberin interfaceInput- Overrides:
readFieldNumberin classFilterInput<CodedInput>- Throws:
java.io.IOException
-
mergeObject
public <T> T mergeObject(T value, Schema<T> schema) throws java.io.IOExceptionDescription copied from interface:InputMerges an object(with schema) field value. The providedschemahandles the deserialization for the object.- Specified by:
mergeObjectin interfaceInput- Overrides:
mergeObjectin classFilterInput<CodedInput>- Throws:
java.io.IOException
-
handleUnknownField
public <T> void handleUnknownField(int fieldNumber, Schema<T> schema) throws java.io.IOExceptionDescription copied from interface:InputThe underlying implementation should handle the unknown field.- Specified by:
handleUnknownFieldin interfaceInput- Overrides:
handleUnknownFieldin classFilterInput<CodedInput>- Throws:
java.io.IOException
-
getFieldName
public java.lang.String getFieldName(int number)
Description copied from interface:SchemaGets the field name associated with the number. This is particularly useful when serializing to different formats (Eg. JSON). When using numeric field names:return String.valueOf(number);
- Specified by:
getFieldNamein interfaceSchema<java.lang.Object>
-
getFieldNumber
public int getFieldNumber(java.lang.String name)
Description copied from interface:SchemaGets the field number associated with the name. This is particularly useful when serializing to different formats (Eg. JSON). When using numeric field names:return Integer.parseInt(name);
- Specified by:
getFieldNumberin interfaceSchema<java.lang.Object>
-
isInitialized
public boolean isInitialized(java.lang.Object owner)
Description copied from interface:SchemaReturns true if there is no required field or if all the required fields are set.- Specified by:
isInitializedin interfaceSchema<java.lang.Object>
-
messageFullName
public java.lang.String messageFullName()
Description copied from interface:SchemaReturns the full name of the message tied to this schema. Allows custom schemas to provide a custom name other than typeClass().getName();- Specified by:
messageFullNamein interfaceSchema<java.lang.Object>
-
messageName
public java.lang.String messageName()
Description copied from interface:SchemaReturns the simple name of the message tied to this schema. Allows custom schemas to provide a custom name other than typeClass().getSimpleName();- Specified by:
messageNamein interfaceSchema<java.lang.Object>
-
newMessage
public java.lang.Object newMessage()
Description copied from interface:SchemaCreates the message/object tied to this schema.- Specified by:
newMessagein interfaceSchema<java.lang.Object>
-
typeClass
public java.lang.Class<? super java.lang.Object> typeClass()
Description copied from interface:SchemaGets the class of the message.
-
mergeFrom
public void mergeFrom(Input input, java.lang.Object message) throws java.io.IOException
Description copied from interface:SchemaDeserializes a message/object from theinput.
-
-