Package io.protostuff

Class 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 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: 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
      • mergeObject

        public <T> T mergeObject​(T value,
                                 Schema<T> schema)
                          throws java.io.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:
        java.io.IOException
      • handleUnknownField

        public <T> void handleUnknownField​(int fieldNumber,
                                           Schema<T> schema)
                                    throws java.io.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:
        java.io.IOException
      • getFieldName

        public java.lang.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<java.lang.Object>
      • getFieldNumber

        public int getFieldNumber​(java.lang.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<java.lang.Object>
      • isInitialized

        public boolean isInitialized​(java.lang.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<java.lang.Object>
      • messageFullName

        public java.lang.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<java.lang.Object>
      • messageName

        public java.lang.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<java.lang.Object>
      • newMessage

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

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

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

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