com.mongodb.util
Class BSONObjectSerializer
java.lang.Object
com.mongodb.util.BSONObjectSerializer
public class BSONObjectSerializer
- extends Object
BSONObjectSerializer
- Author:
- breinero
objects of type BSONObjectSerializer are constructed to perform
instance specific object to JSON serialization schemes.
This class is not thread safe
- See Also:
BSONSerializerFactory
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BSONObjectSerializer
public BSONObjectSerializer()
addObjectSerializer
public void addObjectSerializer(Class c,
BSONObjectSerializer.ObjectSerializer o)
- Assign a ObjectSerializer to perform a type specific serialization scheme
- Parameters:
key
- this object's type serves as a key in the serialization map.
BSONObjectSerializer 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 type
serialize
public void serialize(Object obj,
StringBuilder buf)
- Parameters:
obj
- the object to be serializedbuf
- StringBuilder containing the JSON representation of the object