org.codehaus.jackson.map.ser
Class BeanSerializer

java.lang.Object
  extended by org.codehaus.jackson.map.JsonSerializer<java.lang.Object>
      extended by org.codehaus.jackson.map.ser.BeanSerializer
All Implemented Interfaces:
ResolvableSerializer

public class BeanSerializer
extends JsonSerializer<java.lang.Object>
implements ResolvableSerializer

Serializer class that can serialize arbitrary bean objects.

Implementation note: we will post-process resulting serializer, to figure out actual serializers for final types. This must be done from resolve(org.codehaus.jackson.map.SerializerProvider) method, and NOT from constructor; otherwise we could end up with an infinite loop.


Field Summary
protected  java.lang.String _className
           
protected  BeanPropertyWriter[] _props
           
 
Constructor Summary
BeanSerializer(java.lang.Class<?> type, BeanPropertyWriter[] props)
           
BeanSerializer(java.lang.Class<?> type, java.util.Collection<BeanPropertyWriter> props)
           
 
Method Summary
 void resolve(SerializerProvider provider)
          Method called after SerializerProvider has registered the serializer, but before it has returned it to the caller.
 void serialize(java.lang.Object bean, JsonGenerator jgen, SerializerProvider provider)
          Method that can be called to ask implementation to serialize values of type this serializer handles.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_className

protected final java.lang.String _className

_props

protected final BeanPropertyWriter[] _props
Constructor Detail

BeanSerializer

public BeanSerializer(java.lang.Class<?> type,
                      BeanPropertyWriter[] props)

BeanSerializer

public BeanSerializer(java.lang.Class<?> type,
                      java.util.Collection<BeanPropertyWriter> props)
Method Detail

serialize

public void serialize(java.lang.Object bean,
                      JsonGenerator jgen,
                      SerializerProvider provider)
               throws java.io.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 JsonSerializer<java.lang.Object>
Parameters:
bean - 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:
java.io.IOException
JsonGenerationException

resolve

public void resolve(SerializerProvider provider)
             throws JsonMappingException
Description copied from interface: ResolvableSerializer
Method called after SerializerProvider has registered the serializer, but before it has returned it to the caller. Called object can then resolve its dependencies to other types, including self-references (direct or indirect).

Specified by:
resolve in interface ResolvableSerializer
Parameters:
provider - Provider that has constructed serializer this method is called on.
Throws:
JsonMappingException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object