Package io.protostuff.runtime
Class ObjectSchema
- java.lang.Object
-
- io.protostuff.runtime.PolymorphicSchema
-
- io.protostuff.runtime.ObjectSchema
-
- All Implemented Interfaces:
Schema<java.lang.Object>
public abstract class ObjectSchema extends PolymorphicSchema
A schema for dynamic types (fields where the type isObject
).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
ObjectSchema.ArrayWrapper
An array wrapper internally used for adding objects.-
Nested classes/interfaces inherited from class io.protostuff.runtime.PolymorphicSchema
PolymorphicSchema.Factory, PolymorphicSchema.Handler
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static int
ID_ARRAY_DIMENSION
(package private) static int
ID_ARRAY_LEN
(package private) static int
ID_ENUM_VALUE
protected Pipe.Schema<java.lang.Object>
pipeSchema
-
Fields inherited from class io.protostuff.runtime.PolymorphicSchema
strategy
-
-
Constructor Summary
Constructors Constructor Description ObjectSchema(IdStrategy strategy)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static java.lang.Class<?>
getArrayClass(Input input, Schema<?> schema, java.lang.Class<?> componentType)
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.Pipe.Schema<java.lang.Object>
getPipeSchema()
The pipe schema associated with this schema.private static boolean
isComponentPojo(java.lang.Class<?> componentType)
void
mergeFrom(Input input, java.lang.Object owner)
Deserializes a message/object from theinput
.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.(package private) static java.lang.String
name(int number)
(package private) static ObjectSchema.ArrayWrapper
newArrayWrapper(Input input, Schema<?> schema, boolean mapped, IdStrategy strategy)
(package private) static int
number(java.lang.String name)
(package private) static java.lang.Object
readObjectFrom(Input input, Schema<?> schema, java.lang.Object owner, IdStrategy strategy)
(package private) static void
transferArray(Pipe pipe, Input input, Output output, int number, Pipe.Schema<?> pipeSchema, boolean mapped, IdStrategy strategy)
(package private) static void
transferClass(Pipe pipe, Input input, Output output, int number, Pipe.Schema<?> pipeSchema, boolean mapped, boolean array, IdStrategy strategy)
(package private) static void
transferObject(Pipe.Schema<java.lang.Object> pipeSchema, Pipe pipe, Input input, Output output, IdStrategy strategy)
private static void
writeArrayTo(Output output, java.lang.Object value, Schema<?> currentSchema, IdStrategy strategy, java.lang.Class<java.lang.Object> clazz)
private static void
writeComponentTo(Output output, java.lang.Object value, Schema<?> currentSchema, IdStrategy strategy, java.lang.Class<?> componentType, int dimensions)
(package private) static void
writeObjectTo(Output output, java.lang.Object value, Schema<?> currentSchema, IdStrategy strategy)
void
writeTo(Output output, java.lang.Object value)
Serializes a message/object to theoutput
.-
Methods inherited from class io.protostuff.runtime.PolymorphicSchema
isInitialized, newMessage, setValue, typeClass
-
-
-
-
Field Detail
-
ID_ENUM_VALUE
static final int ID_ENUM_VALUE
- See Also:
- Constant Field Values
-
ID_ARRAY_LEN
static final int ID_ARRAY_LEN
- See Also:
- Constant Field Values
-
ID_ARRAY_DIMENSION
static final int ID_ARRAY_DIMENSION
- See Also:
- Constant Field Values
-
pipeSchema
protected final Pipe.Schema<java.lang.Object> pipeSchema
-
-
Constructor Detail
-
ObjectSchema
public ObjectSchema(IdStrategy strategy)
-
-
Method Detail
-
name
static java.lang.String name(int number)
-
number
static int number(java.lang.String name)
-
getPipeSchema
public Pipe.Schema<java.lang.Object> getPipeSchema()
Description copied from class:PolymorphicSchema
The pipe schema associated with this schema.- Specified by:
getPipeSchema
in classPolymorphicSchema
-
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);
-
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);
-
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();
-
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();
-
mergeFrom
public void mergeFrom(Input input, java.lang.Object owner) throws java.io.IOException
Description copied from interface:Schema
Deserializes a message/object from theinput
.- Throws:
java.io.IOException
-
writeTo
public void writeTo(Output output, java.lang.Object value) throws java.io.IOException
Description copied from interface:Schema
Serializes a message/object to theoutput
.- Throws:
java.io.IOException
-
newArrayWrapper
static ObjectSchema.ArrayWrapper newArrayWrapper(Input input, Schema<?> schema, boolean mapped, IdStrategy strategy) throws java.io.IOException
- Throws:
java.io.IOException
-
transferArray
static void transferArray(Pipe pipe, Input input, Output output, int number, Pipe.Schema<?> pipeSchema, boolean mapped, IdStrategy strategy) throws java.io.IOException
- Throws:
java.io.IOException
-
transferClass
static void transferClass(Pipe pipe, Input input, Output output, int number, Pipe.Schema<?> pipeSchema, boolean mapped, boolean array, IdStrategy strategy) throws java.io.IOException
- Throws:
java.io.IOException
-
getArrayClass
static java.lang.Class<?> getArrayClass(Input input, Schema<?> schema, java.lang.Class<?> componentType) throws java.io.IOException
- Throws:
java.io.IOException
-
readObjectFrom
static java.lang.Object readObjectFrom(Input input, Schema<?> schema, java.lang.Object owner, IdStrategy strategy) throws java.io.IOException
- Throws:
java.io.IOException
-
writeObjectTo
static void writeObjectTo(Output output, java.lang.Object value, Schema<?> currentSchema, IdStrategy strategy) throws java.io.IOException
- Throws:
java.io.IOException
-
isComponentPojo
private static boolean isComponentPojo(java.lang.Class<?> componentType)
-
writeComponentTo
private static void writeComponentTo(Output output, java.lang.Object value, Schema<?> currentSchema, IdStrategy strategy, java.lang.Class<?> componentType, int dimensions) throws java.io.IOException
- Throws:
java.io.IOException
-
writeArrayTo
private static void writeArrayTo(Output output, java.lang.Object value, Schema<?> currentSchema, IdStrategy strategy, java.lang.Class<java.lang.Object> clazz) throws java.io.IOException
- Throws:
java.io.IOException
-
transferObject
static void transferObject(Pipe.Schema<java.lang.Object> pipeSchema, Pipe pipe, Input input, Output output, IdStrategy strategy) throws java.io.IOException
- Throws:
java.io.IOException
-
-