public abstract class BeanSerializerBase extends SerializerBase<Object> implements ResolvableSerializer, SchemaAware
JsonSerializer.None| Modifier and Type | Field and Description |
|---|---|
protected AnyGetterWriter |
_anyGetterWriter
Handler for
JsonAnyGetter
annotated properties |
protected BeanPropertyWriter[] |
_filteredProps
Optional filters used to suppress output of properties that
are only to be included in certain views
|
protected Object |
_propertyFilterId
Id of the bean property filter to use, if any; null if none.
|
protected BeanPropertyWriter[] |
_props
Writers used for outputting actual property values
|
protected static BeanPropertyWriter[] |
NO_PROPS |
_handledType| Modifier | Constructor and Description |
|---|---|
protected |
BeanSerializerBase(BeanSerializerBase src)
Copy-constructor that is useful for sub-classes that just want to
copy all super-class properties without modifications.
|
|
BeanSerializerBase(Class<?> rawType,
BeanPropertyWriter[] properties,
BeanPropertyWriter[] filteredProperties,
AnyGetterWriter anyGetterWriter,
Object filterId) |
protected |
BeanSerializerBase(JavaType type,
BeanPropertyWriter[] properties,
BeanPropertyWriter[] filteredProperties,
AnyGetterWriter anyGetterWriter,
Object filterId) |
| Modifier and Type | Method and Description |
|---|---|
protected BeanPropertyFilter |
findFilter(SerializerProvider provider)
Helper method used to locate filter that is needed, based on filter id
this serializer was constructed with.
|
JsonNode |
getSchema(SerializerProvider provider,
Type typeHint)
Note: since Jackson 1.9, default implementation claims type is "string"
|
void |
resolve(SerializerProvider provider)
Method called after
SerializerProvider has registered
the serializer, but before it has returned it to the caller. |
abstract void |
serialize(Object bean,
JsonGenerator jgen,
SerializerProvider provider)
Method that can be called to ask implementation to serialize
values of type this serializer handles.
|
protected void |
serializeFields(Object bean,
JsonGenerator jgen,
SerializerProvider provider) |
protected void |
serializeFieldsFiltered(Object bean,
JsonGenerator jgen,
SerializerProvider provider)
Alternative serialization method that gets called when there is a
BeanPropertyFilter that needs to be called to determine
which properties are to be serialized (and possibly how) |
void |
serializeWithType(Object bean,
JsonGenerator jgen,
SerializerProvider provider,
TypeSerializer typeSer)
Method that can be called to ask implementation to serialize
values of type this serializer handles, using specified type serializer
for embedding necessary type information.
|
createObjectNode, createSchemaNode, createSchemaNode, handledType, isDefaultSerializer, wrapAndThrow, wrapAndThrow, wrapAndThrow, wrapAndThrowisUnwrappingSerializer, unwrappingSerializerprotected static final BeanPropertyWriter[] NO_PROPS
protected final BeanPropertyWriter[] _props
protected final BeanPropertyWriter[] _filteredProps
protected final AnyGetterWriter _anyGetterWriter
JsonAnyGetter
annotated propertiesprotected final Object _propertyFilterId
protected BeanSerializerBase(JavaType type, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties, AnyGetterWriter anyGetterWriter, Object filterId)
type - Nominal type of values handled by this serializerproperties - Property writers used for actual serializationpublic BeanSerializerBase(Class<?> rawType, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties, AnyGetterWriter anyGetterWriter, Object filterId)
protected BeanSerializerBase(BeanSerializerBase src)
public abstract void serialize(Object bean, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException
JsonSerializerserialize in class SerializerBase<Object>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.IOExceptionJsonGenerationExceptionpublic void serializeWithType(Object bean, JsonGenerator jgen, SerializerProvider provider, TypeSerializer typeSer) throws IOException, JsonGenerationException
JsonSerializer
Default implementation will ignore serialization of type information,
and just calls JsonSerializer.serialize(T, org.codehaus.jackson.JsonGenerator, org.codehaus.jackson.map.SerializerProvider): serializers that can embed
type information should override this to implement actual handling.
Most common such handling is done by something like:
// note: method to call depends on whether this type is serialized as JSON scalar, object or Array! typeSer.writeTypePrefixForScalar(value, jgen); serialize(value, jgen, provider); typeSer.writeTypeSuffixForScalar(value, jgen);
serializeWithType in class JsonSerializer<Object>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.typeSer - Type serializer to use for including type informationIOExceptionJsonGenerationExceptionprotected void serializeFields(Object bean, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException
IOExceptionJsonGenerationExceptionprotected void serializeFieldsFiltered(Object bean, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException
BeanPropertyFilter that needs to be called to determine
which properties are to be serialized (and possibly how)IOExceptionJsonGenerationExceptionprotected BeanPropertyFilter findFilter(SerializerProvider provider) throws JsonMappingException
JsonMappingExceptionpublic JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException
SerializerBasegetSchema in interface SchemaAwaregetSchema in class SerializerBase<Object>provider - The serializer provider.typeHint - A hint about the type.JsonMappingExceptionpublic void resolve(SerializerProvider provider) throws JsonMappingException
ResolvableSerializerSerializerProvider 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).resolve in interface ResolvableSerializerprovider - Provider that has constructed serializer this method
is called on.JsonMappingException