org.codehaus.jackson.map.ser
Class BeanSerializer
java.lang.Object
org.codehaus.jackson.map.JsonSerializer<T>
org.codehaus.jackson.map.ser.SerializerBase<Object>
org.codehaus.jackson.map.ser.BeanSerializer
- All Implemented Interfaces:
- ResolvableSerializer, SchemaAware
public class BeanSerializer
- extends SerializerBase<Object>
- implements ResolvableSerializer, SchemaAware
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.
_className
protected final String _className
_props
protected final BeanPropertyWriter[] _props
BeanSerializer
public BeanSerializer(Class<?> type,
BeanPropertyWriter[] props)
BeanSerializer
public BeanSerializer(Class<?> type,
Collection<BeanPropertyWriter> props)
serialize
public void serialize(Object bean,
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<Object>
- Parameters:
bean - Value to serialize; can not be null.jgen - Generator used to output resulting Json contentprovider - 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)
throws JsonMappingException
- 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<Object>
- Parameters:
provider - The serializer provider.typeHint - A hint about the type.
- Returns:
- Json-schema for this serializer.
- Throws:
JsonMappingException
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 String toString()
- Overrides:
toString in class Object