Package io.protostuff
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 class
static enum
A message factory for standardMap
implementations.static interface
Creates newMap
messages. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Pipe.Schema
<Map.Entry<K, V>> static final String
The field name of the Map.Entry.static final String
The field name of the key.static final String
The field name of the value;This is used byMapSchema.MessageFactories.accept(String)
method.final MapSchema.MessageFactory
Factory for creatingMap
messages.final Pipe.Schema
<Map<K, V>> The pipe schema of theMap
. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal String
getFieldName
(int number) Gets the field name associated with the number.final int
getFieldNumber
(String name) Gets the field number associated with the name.final boolean
isInitialized
(Map<K, V> map) Returns true if there is no required field or if all the required fields are set.final void
Deserializes a message/object from theinput
.final String
Returns the full name of the message tied to this schema.final String
Returns the simple name of the message tied to this schema.Creates the message/object tied to this schema.protected abstract void
putValueFrom
(Input input, MapSchema.MapWrapper<K, V> wrapper, K key) Puts the entry(key and value), obtained from the input, into theMapWrapper
.protected abstract K
readKeyFrom
(Input input, MapSchema.MapWrapper<K, V> wrapper) Reads the key from the input.protected abstract void
transferKey
(Pipe pipe, Input input, Output output, int number, boolean repeated) Transfers the key from the input to the output.protected abstract void
transferValue
(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 void
writeKeyTo
(Output output, int fieldNumber, K value, boolean repeated) Writes the key to the output.final void
Serializes a message/object to theoutput
.protected abstract void
writeValueTo
(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
The field name of the Map.Entry.- See Also:
-
FIELD_NAME_KEY
The field name of the key.- See Also:
-
FIELD_NAME_VALUE
The field name of the value;- See Also:
-
messageFactory
Factory for creatingMap
messages. -
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: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<K>
-
getFieldNumber
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<K>
-
isInitialized
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<K>
-
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<K>
-
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<K>
-
typeClass
Description copied from interface:Schema
Gets the class of the message. -
newMessage
Description copied from interface:Schema
Creates the message/object tied to this schema.- Specified by:
newMessage
in interfaceSchema<K>
-
mergeFrom
Description copied from interface:Schema
Deserializes a message/object from theinput
.- Specified by:
mergeFrom
in interfaceSchema<K>
- Throws:
IOException
-
writeTo
Description copied from interface:Schema
Serializes a message/object to theoutput
.- Specified by:
writeTo
in interfaceSchema<K>
- Throws:
IOException
-