Package org.codehaus.jackson.map.ser
Class BeanSerializer
- java.lang.Object
-
- org.codehaus.jackson.map.JsonSerializer<T>
-
- org.codehaus.jackson.map.ser.std.SerializerBase<java.lang.Object>
-
- org.codehaus.jackson.map.ser.std.BeanSerializerBase
-
- org.codehaus.jackson.map.ser.BeanSerializer
-
- All Implemented Interfaces:
ResolvableSerializer,SchemaAware
public class BeanSerializer extends BeanSerializerBase
Serializer class that can serialize arbitrary bean objectsImplementation note: we will post-process resulting serializer, to figure out actual serializers for final types. This must be done from
BeanSerializerBase.resolve(org.codehaus.jackson.map.SerializerProvider)method, and NOT from constructor; otherwise we could end up with an infinite loop.Since 1.7 instances are immutable; this is achieved by using a separate builder during construction process.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.codehaus.jackson.map.JsonSerializer
JsonSerializer.None
-
-
Field Summary
-
Fields inherited from class org.codehaus.jackson.map.ser.std.BeanSerializerBase
_anyGetterWriter, _filteredProps, _propertyFilterId, _props, NO_PROPS
-
Fields inherited from class org.codehaus.jackson.map.ser.std.SerializerBase
_handledType
-
-
Constructor Summary
Constructors Modifier Constructor Description BeanSerializer(java.lang.Class<?> rawType, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties, AnyGetterWriter anyGetterWriter, java.lang.Object filterId)protectedBeanSerializer(BeanSerializer src)Copy-constructor that is useful for sub-classes that just want to copy all super-class properties without modifications.protectedBeanSerializer(BeanSerializerBase src)Alternate copy constructor that can be used to construct standardBeanSerializerpassing an instance of "compatible enough" source serializer.BeanSerializer(JavaType type, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties, AnyGetterWriter anyGetterWriter, java.lang.Object filterId)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BeanSerializercreateDummy(java.lang.Class<?> forType)Method for constructing dummy bean deserializer; one that never outputs any propertiesvoidserialize(java.lang.Object bean, JsonGenerator jgen, SerializerProvider provider)Main serialization method that will delegate actual output to configuredBeanPropertyWriterinstances.java.lang.StringtoString()JsonSerializer<java.lang.Object>unwrappingSerializer()Method that will return serializer instance that produces "unwrapped" serialization, if applicable for type being serialized (which is the case for some serializers that produce JSON Objects as output).-
Methods inherited from class org.codehaus.jackson.map.ser.std.BeanSerializerBase
findFilter, getSchema, resolve, serializeFields, serializeFieldsFiltered, serializeWithType
-
Methods inherited from class org.codehaus.jackson.map.ser.std.SerializerBase
createObjectNode, createSchemaNode, createSchemaNode, handledType, isDefaultSerializer, wrapAndThrow, wrapAndThrow, wrapAndThrow, wrapAndThrow
-
Methods inherited from class org.codehaus.jackson.map.JsonSerializer
isUnwrappingSerializer
-
-
-
-
Constructor Detail
-
BeanSerializer
public BeanSerializer(JavaType type, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties, AnyGetterWriter anyGetterWriter, java.lang.Object filterId)
- Parameters:
type- Nominal type of values handled by this serializerproperties- Property writers used for actual serialization
-
BeanSerializer
public BeanSerializer(java.lang.Class<?> rawType, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties, AnyGetterWriter anyGetterWriter, java.lang.Object filterId)
-
BeanSerializer
protected BeanSerializer(BeanSerializer src)
Copy-constructor that is useful for sub-classes that just want to copy all super-class properties without modifications.- Since:
- 1.7
-
BeanSerializer
protected BeanSerializer(BeanSerializerBase src)
Alternate copy constructor that can be used to construct standardBeanSerializerpassing an instance of "compatible enough" source serializer.- Since:
- 1.9
-
-
Method Detail
-
createDummy
public static BeanSerializer createDummy(java.lang.Class<?> forType)
Method for constructing dummy bean deserializer; one that never outputs any properties
-
unwrappingSerializer
public JsonSerializer<java.lang.Object> unwrappingSerializer()
Description copied from class:JsonSerializerMethod that will return serializer instance that produces "unwrapped" serialization, if applicable for type being serialized (which is the case for some serializers that produce JSON Objects as output). If no unwrapped serializer can be constructed, will simply return serializer as-is.Default implementation just returns serializer as-is, indicating that no unwrapped variant exists
- Overrides:
unwrappingSerializerin classJsonSerializer<java.lang.Object>
-
serialize
public final void serialize(java.lang.Object bean, JsonGenerator jgen, SerializerProvider provider) throws java.io.IOException, JsonGenerationExceptionMain serialization method that will delegate actual output to configuredBeanPropertyWriterinstances.- Specified by:
serializein classBeanSerializerBase- 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:
java.io.IOExceptionJsonGenerationException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-