Package org.codehaus.jackson.map.ser
Class BeanSerializer
java.lang.Object
org.codehaus.jackson.map.JsonSerializer<Object>
org.codehaus.jackson.map.ser.std.SerializerBase<Object>
org.codehaus.jackson.map.ser.std.BeanSerializerBase
org.codehaus.jackson.map.ser.BeanSerializer
- All Implemented Interfaces:
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 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_PROPSFields inherited from class org.codehaus.jackson.map.ser.std.SerializerBase
_handledType -
Constructor Summary
ConstructorsModifierConstructorDescriptionBeanSerializer(Class<?> rawType, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties, AnyGetterWriter anyGetterWriter, Object filterId) protectedCopy-constructor that is useful for sub-classes that just want to copy all super-class properties without modifications.protectedAlternate 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, Object filterId) -
Method Summary
Modifier and TypeMethodDescriptionstatic BeanSerializercreateDummy(Class<?> forType) Method for constructing dummy bean deserializer; one that never outputs any propertiesfinal voidserialize(Object bean, JsonGenerator jgen, SerializerProvider provider) Main serialization method that will delegate actual output to configuredBeanPropertyWriterinstances.toString()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, serializeWithTypeMethods inherited from class org.codehaus.jackson.map.ser.std.SerializerBase
createObjectNode, createSchemaNode, createSchemaNode, handledType, isDefaultSerializer, wrapAndThrow, wrapAndThrow, wrapAndThrow, wrapAndThrowMethods inherited from class org.codehaus.jackson.map.JsonSerializer
isUnwrappingSerializer
-
Constructor Details
-
BeanSerializer
public BeanSerializer(JavaType type, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties, AnyGetterWriter anyGetterWriter, Object filterId) - Parameters:
type- Nominal type of values handled by this serializerproperties- Property writers used for actual serialization
-
BeanSerializer
public BeanSerializer(Class<?> rawType, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties, AnyGetterWriter anyGetterWriter, Object filterId) -
BeanSerializer
Copy-constructor that is useful for sub-classes that just want to copy all super-class properties without modifications.- Since:
- 1.7
-
BeanSerializer
Alternate copy constructor that can be used to construct standardBeanSerializerpassing an instance of "compatible enough" source serializer.- Since:
- 1.9
-
-
Method Details
-
createDummy
Method for constructing dummy bean deserializer; one that never outputs any properties -
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<Object>
-
serialize
public final void serialize(Object bean, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException Main 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:
IOExceptionJsonGenerationException
-
toString
-