public abstract class BeanSerializerBase extends SerializerBase<Object> implements ResolvableSerializer, SchemaAware
JsonSerializer.None| 限定符和类型 | 字段和说明 |
|---|---|
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| 限定符 | 构造器和说明 |
|---|---|
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) |
| 限定符和类型 | 方法和说明 |
|---|---|
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 在类中 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 在类中 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
protected 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 在接口中 SchemaAwaregetSchema 在类中 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 在接口中 ResolvableSerializerprovider - Provider that has constructed serializer this method
is called on.JsonMappingException