Package io.protostuff

Class GraphCodedInput

java.lang.Object
io.protostuff.FilterInput<CodedInput>
io.protostuff.GraphCodedInput
All Implemented Interfaces:
GraphInput, Input, Schema<Object>

public final class GraphCodedInput extends FilterInput<CodedInput> implements GraphInput, Schema<Object>
A CodedInput w/c can handle cyclic dependencies when deserializing objects with graph transformations.
  • Field Details

    • references

      private final ArrayList<Object> references
    • lastRef

      private int lastRef
    • lastSchema

      private Schema<Object> lastSchema
    • messageReference

      private boolean messageReference
  • Constructor Details

    • GraphCodedInput

      public GraphCodedInput(CodedInput input)
    • GraphCodedInput

      public GraphCodedInput(CodedInput input, int initialCapacity)
  • Method Details

    • updateLast

      public void updateLast(Object morphedMessage, Object lastMessage)
      Description copied from interface: GraphInput
      Updates the last reference (the tip/end of the index) kept if the lastMessage was indeed the last message.
      Specified by:
      updateLast in interface GraphInput
    • isCurrentMessageReference

      public boolean isCurrentMessageReference()
      Description copied from interface: GraphInput
      Returns true if the last message was read as a reference.
      Specified by:
      isCurrentMessageReference in interface GraphInput
    • readFieldNumber

      public <T> int readFieldNumber(Schema<T> schema) throws IOException
      Description copied from interface: Input
      Reads the field number of a message/object tied to the given schema.
      Specified by:
      readFieldNumber in interface Input
      Overrides:
      readFieldNumber in class FilterInput<CodedInput>
      Throws:
      IOException
    • mergeObject

      public <T> T mergeObject(T value, Schema<T> schema) throws IOException
      Description copied from interface: Input
      Merges an object(with schema) field value. The provided schema handles the deserialization for the object.
      Specified by:
      mergeObject in interface Input
      Overrides:
      mergeObject in class FilterInput<CodedInput>
      Throws:
      IOException
    • handleUnknownField

      public <T> void handleUnknownField(int fieldNumber, Schema<T> schema) throws IOException
      Description copied from interface: Input
      The underlying implementation should handle the unknown field.
      Specified by:
      handleUnknownField in interface Input
      Overrides:
      handleUnknownField in class FilterInput<CodedInput>
      Throws:
      IOException
    • getFieldName

      public String getFieldName(int number)
      Description copied from interface: Schema
      Gets 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:
      getFieldName in interface Schema<Object>
    • getFieldNumber

      public int getFieldNumber(String name)
      Description copied from interface: Schema
      Gets 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:
      getFieldNumber in interface Schema<Object>
    • isInitialized

      public boolean isInitialized(Object owner)
      Description copied from interface: Schema
      Returns true if there is no required field or if all the required fields are set.
      Specified by:
      isInitialized in interface Schema<Object>
    • messageFullName

      public String messageFullName()
      Description copied from interface: Schema
      Returns the full name of the message tied to this schema. Allows custom schemas to provide a custom name other than typeClass().getName();
      Specified by:
      messageFullName in interface Schema<Object>
    • messageName

      public String messageName()
      Description copied from interface: Schema
      Returns the simple name of the message tied to this schema. Allows custom schemas to provide a custom name other than typeClass().getSimpleName();
      Specified by:
      messageName in interface Schema<Object>
    • newMessage

      public Object newMessage()
      Description copied from interface: Schema
      Creates the message/object tied to this schema.
      Specified by:
      newMessage in interface Schema<Object>
    • typeClass

      public Class<? super Object> typeClass()
      Description copied from interface: Schema
      Gets the class of the message.
      Specified by:
      typeClass in interface Schema<Object>
    • mergeFrom

      public void mergeFrom(Input input, Object message) throws IOException
      Description copied from interface: Schema
      Deserializes a message/object from the input.
      Specified by:
      mergeFrom in interface Schema<Object>
      Throws:
      IOException
    • writeTo

      public void writeTo(Output output, Object message) throws IOException
      Description copied from interface: Schema
      Serializes a message/object to the output.
      Specified by:
      writeTo in interface Schema<Object>
      Throws:
      IOException