com.mongodb.util
Class BSONObjectSerializer

java.lang.Object
  extended by 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

Nested Class Summary
static interface BSONObjectSerializer.ObjectSerializer
           
 
Constructor Summary
BSONObjectSerializer()
           
 
Method Summary
 void addObjectSerializer(Class c, BSONObjectSerializer.ObjectSerializer o)
          Assign a ObjectSerializer to perform a type specific serialization scheme
 void serialize(Object obj, StringBuilder buf)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BSONObjectSerializer

public BSONObjectSerializer()
Method Detail

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.ClassMap
serializer - performs the serialization mapping specific to the @param key type

serialize

public void serialize(Object obj,
                      StringBuilder buf)
Parameters:
obj - the object to be serialized
buf - StringBuilder containing the JSON representation of the object