org.codehaus.jackson.map.ser
Class MapSerializer

java.lang.Object
  extended by org.codehaus.jackson.map.JsonSerializer<T>
      extended by org.codehaus.jackson.map.ser.SerializerBase<Map<?,?>>
          extended by org.codehaus.jackson.map.ser.MapSerializer
All Implemented Interfaces:
SchemaAware
Direct Known Subclasses:
ContainerSerializers.MapSerializer

public class MapSerializer
extends SerializerBase<Map<?,?>>

Standard serializer implementation for serializing {link java.util.Map} types.

Note: about the only configurable setting currently is ability to filter out entries with specified names.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.codehaus.jackson.map.JsonSerializer
JsonSerializer.None
 
Field Summary
protected  HashSet<String> _ignoredEntries
          Set of entries to omit during serialization, if any
static MapSerializer instance
          Default instance that can be used for Map types that have no specific custom annotations.
 
Constructor Summary
protected MapSerializer()
           
protected MapSerializer(String[] ignoredEntries)
           
 
Method Summary
static MapSerializer construct(String[] ignoredEntries)
           
 JsonNode getSchema(SerializerProvider provider, Type typeHint)
          Get the representation of the schema to which this serializer will conform.
 void serialize(Map<?,?> value, JsonGenerator jgen, SerializerProvider provider)
          Method that can be called to ask implementation to serialize values of type this serializer handles.
protected  void serializeEntries(Map<?,?> value, JsonGenerator jgen, SerializerProvider provider)
          Helper method that will write all entries of given non-empty Map
protected  void serializeSomeEntries(Map<?,?> value, JsonGenerator jgen, SerializerProvider provider, HashSet<String> ignored)
          Helper method that will write all entries of the given non-empty map, except for specified set of ignorable entries, filtered based on entry key.
 
Methods inherited from class org.codehaus.jackson.map.ser.SerializerBase
createObjectNode, createSchemaNode, createSchemaNode, wrapAndThrow, wrapAndThrow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

public static final MapSerializer instance
Default instance that can be used for Map types that have no specific custom annotations.


_ignoredEntries

protected final HashSet<String> _ignoredEntries
Set of entries to omit during serialization, if any

Constructor Detail

MapSerializer

protected MapSerializer()

MapSerializer

protected MapSerializer(String[] ignoredEntries)
Method Detail

construct

public static MapSerializer construct(String[] ignoredEntries)
Parameters:
ignoredEntries - Array of entry names that are to be filtered on serialization; null if none

serialize

public void serialize(Map<?,?> value,
                      JsonGenerator jgen,
                      SerializerProvider provider)
               throws IOException,
                      JsonGenerationException
Description copied from class: JsonSerializer
Method that can be called to ask implementation to serialize values of type this serializer handles.

Specified by:
serialize in class SerializerBase<Map<?,?>>
Parameters:
value - Value to serialize; can not be null.
jgen - Generator used to output resulting Json content
provider - Provider that can be used to get serializers for serializing Objects value contains, if any.
Throws:
IOException
JsonGenerationException

getSchema

public JsonNode getSchema(SerializerProvider provider,
                          Type typeHint)
Description copied from interface: SchemaAware
Get the representation of the schema to which this serializer will conform.

Specified by:
getSchema in interface SchemaAware
Specified by:
getSchema in class SerializerBase<Map<?,?>>
Parameters:
provider - The serializer provider.
typeHint - A hint about the type.
Returns:
Json-schema for this serializer.

serializeEntries

protected final void serializeEntries(Map<?,?> value,
                                      JsonGenerator jgen,
                                      SerializerProvider provider)
                               throws IOException,
                                      JsonGenerationException
Helper method that will write all entries of given non-empty Map

Throws:
IOException
JsonGenerationException

serializeSomeEntries

protected final void serializeSomeEntries(Map<?,?> value,
                                          JsonGenerator jgen,
                                          SerializerProvider provider,
                                          HashSet<String> ignored)
                                   throws IOException,
                                          JsonGenerationException
Helper method that will write all entries of the given non-empty map, except for specified set of ignorable entries, filtered based on entry key.

Throws:
IOException
JsonGenerationException