Package io.protostuff
Class GraphByteArrayInput
- java.lang.Object
-
- io.protostuff.FilterInput<ByteArrayInput>
-
- io.protostuff.GraphByteArrayInput
-
- All Implemented Interfaces:
GraphInput
,Input
,Schema<java.lang.Object>
public final class GraphByteArrayInput extends FilterInput<ByteArrayInput> implements GraphInput, Schema<java.lang.Object>
A ByteArrayInput w/c can handle cyclic dependencies when deserializing objects with graph transformations.
-
-
Field Summary
Fields Modifier and Type Field Description private int
lastRef
private Schema<java.lang.Object>
lastSchema
private boolean
messageReference
private java.util.ArrayList<java.lang.Object>
references
-
Fields inherited from class io.protostuff.FilterInput
input
-
-
Constructor Summary
Constructors Constructor Description GraphByteArrayInput(ByteArrayInput input)
GraphByteArrayInput(ByteArrayInput input, int initialCapacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getFieldName(int number)
Gets the field name associated with the number.int
getFieldNumber(java.lang.String name)
Gets the field number associated with the name.<T> void
handleUnknownField(int fieldNumber, Schema<T> schema)
The underlying implementation should handle the unknown field.boolean
isCurrentMessageReference()
Returns true if the last message was read as a reference.boolean
isInitialized(java.lang.Object owner)
Returns true if there is no required field or if all the required fields are set.void
mergeFrom(Input input, java.lang.Object message)
Deserializes a message/object from theinput
.<T> T
mergeObject(T value, Schema<T> schema)
Merges an object(with schema) field value.java.lang.String
messageFullName()
Returns the full name of the message tied to this schema.java.lang.String
messageName()
Returns the simple name of the message tied to this schema.java.lang.Object
newMessage()
Creates the message/object tied to this schema.<T> int
readFieldNumber(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.void
updateLast(java.lang.Object morphedMessage, java.lang.Object lastMessage)
Updates the last reference (the tip/end of the index) kept if thelastMessage
was indeed the last message.void
writeTo(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
-
GraphByteArrayInput
public GraphByteArrayInput(ByteArrayInput input)
-
GraphByteArrayInput
public GraphByteArrayInput(ByteArrayInput 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 thelastMessage
was indeed the last message.- Specified by:
updateLast
in interfaceGraphInput
-
isCurrentMessageReference
public boolean isCurrentMessageReference()
Description copied from interface:GraphInput
Returns true if the last message was read as a reference.- Specified by:
isCurrentMessageReference
in interfaceGraphInput
-
readFieldNumber
public <T> int readFieldNumber(Schema<T> schema) throws java.io.IOException
Description copied from interface:Input
Reads the field number of a message/object tied to the givenschema
.- Specified by:
readFieldNumber
in interfaceInput
- Overrides:
readFieldNumber
in classFilterInput<ByteArrayInput>
- Throws:
java.io.IOException
-
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 providedschema
handles the deserialization for the object.- Specified by:
mergeObject
in interfaceInput
- Overrides:
mergeObject
in classFilterInput<ByteArrayInput>
- 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 interfaceInput
- Overrides:
handleUnknownField
in classFilterInput<ByteArrayInput>
- 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 interfaceSchema<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 interfaceSchema<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 interfaceSchema<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 interfaceSchema<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 interfaceSchema<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 interfaceSchema<java.lang.Object>
-
typeClass
public java.lang.Class<? super java.lang.Object> typeClass()
Description copied from interface:Schema
Gets the class of the message.
-
mergeFrom
public void mergeFrom(Input input, java.lang.Object message) throws java.io.IOException
Description copied from interface:Schema
Deserializes a message/object from theinput
.
-
-