public class ClassMapBasedObjectSerializer extends AbstractObjectSerializer
This class is not thread safe
| Constructor and Description |
|---|
ClassMapBasedObjectSerializer() |
| Modifier and Type | Method and Description |
|---|---|
void |
addObjectSerializer(java.lang.Class<?> c,
ObjectSerializer serializer)
Assign a ObjectSerializer to perform a type specific serialization scheme
|
void |
serialize(java.lang.Object obj,
java.lang.StringBuilder buf)
Serializes
obj into buf. |
serializepublic void addObjectSerializer(java.lang.Class<?> c,
ObjectSerializer serializer)
c - this object's type serves as a key in the serialization map.
ClassMapBasedObjectSerializer uses org.bson.util.ClassMap and not only checks if 'c' is a key in the Map,
but also walks the up superclass and interface graph of 'c' to find matches.
This means that it is only necessary assign ObjectSerializers to base classes. @see org.bson.util.ClassMapserializer - performs the serialization mapping specific to the @param key typepublic void serialize(java.lang.Object obj,
java.lang.StringBuilder buf)
ObjectSerializerobj into buf.obj - the object to be serializedbuf - StringBuilder containing the JSON representation of the object