Class MapSchema<K,V>
java.lang.Object
io.protostuff.MapSchema<K,V>
- Direct Known Subclasses:
MessageMapSchema, StringMapSchema
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic enumA message factory for standardMapimplementations.static interfaceCreates newMapmessages. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Pipe.Schema<Map.Entry<K, V>> static final StringThe field name of the Map.Entry.static final StringThe field name of the key.static final StringThe field name of the value;This is used byMapSchema.MessageFactories.accept(String)method.final MapSchema.MessageFactoryFactory for creatingMapmessages.final Pipe.Schema<Map<K, V>> The pipe schema of theMap. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal StringgetFieldName(int number) Gets the field name associated with the number.final intgetFieldNumber(String name) Gets the field number associated with the name.final booleanisInitialized(Map<K, V> map) Returns true if there is no required field or if all the required fields are set.final voidDeserializes a message/object from theinput.final StringReturns the full name of the message tied to this schema.final StringReturns the simple name of the message tied to this schema.Creates the message/object tied to this schema.protected abstract voidputValueFrom(Input input, MapSchema.MapWrapper<K, V> wrapper, K key) Puts the entry(key and value), obtained from the input, into theMapWrapper.protected abstract KreadKeyFrom(Input input, MapSchema.MapWrapper<K, V> wrapper) Reads the key from the input.protected abstract voidtransferKey(Pipe pipe, Input input, Output output, int number, boolean repeated) Transfers the key from the input to the output.protected abstract voidtransferValue(Pipe pipe, Input input, Output output, int number, boolean repeated) Transfers the value from the input to the output.Gets the class of the message.protected abstract voidwriteKeyTo(Output output, int fieldNumber, K value, boolean repeated) Writes the key to the output.final voidSerializes a message/object to theoutput.protected abstract voidwriteValueTo(Output output, int fieldNumber, V value, boolean repeated) Writes the value to the output.
-
Field Details
-
MESSAGE_FACTORIES_NAMES
This is used byMapSchema.MessageFactories.accept(String)method. Rather than iterating enums in runtime which can be an expensive way to do, caching all the enums as static property will be a good way. -
FIELD_NAME_ENTRY
-
FIELD_NAME_KEY
-
FIELD_NAME_VALUE
-
messageFactory
Factory for creatingMapmessages. -
pipeSchema
The pipe schema of theMap. -
entrySchema
-
entryPipeSchema
-
-
Constructor Details
-
MapSchema
public MapSchema() -
MapSchema
-
-
Method Details
-
readKeyFrom
Reads the key from the input.The extra wrapper arg is internally used as an object placeholder during polymorhic deserialization.
- Throws:
IOException
-
putValueFrom
protected abstract void putValueFrom(Input input, MapSchema.MapWrapper<K, V> wrapper, K key) throws IOExceptionPuts the entry(key and value), obtained from the input, into theMapWrapper.- Throws:
IOException
-
writeKeyTo
protected abstract void writeKeyTo(Output output, int fieldNumber, K value, boolean repeated) throws IOException Writes the key to the output.- Throws:
IOException
-
writeValueTo
protected abstract void writeValueTo(Output output, int fieldNumber, V value, boolean repeated) throws IOException Writes the value to the output.- Throws:
IOException
-
transferKey
protected abstract void transferKey(Pipe pipe, Input input, Output output, int number, boolean repeated) throws IOException Transfers the key from the input to the output.- Throws:
IOException
-
transferValue
protected abstract void transferValue(Pipe pipe, Input input, Output output, int number, boolean repeated) throws IOException Transfers the value from the input to the output.- Throws:
IOException
-
getFieldName
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<K>
-
getFieldNumber
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<K>
-
isInitialized
-
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<K>
-
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<K>
-
typeClass
-
newMessage
-
mergeFrom
-
writeTo
-