ObjectMapper and
JsonSerializers to obtain serializers capable of serializing
instances of specific types; as well as the default implementation
of the functionality.
Provider handles caching aspects of serializer handling; all construction
details are delegated to SerializerFactory instance.
Object life-cycle is such that an initial instance ("blueprint") is created
and referenced by ObjectMapper and ObjectWriter instances;
but for actual usage, a configured instance is created by using
a create method in sub-class
com..
Only this instance can be used for actual serialization calls; blueprint
object is only to be used for creating instances.
| Modifier and Type | Field and Description |
|---|---|
| protected transient ContextAttributes | _attributes
Lazily-constructed holder for per-call attributes. |
| protected final SerializationConfig | _config
Serialization configuration to use for serialization processing. |
| protected DateFormat | _dateFormat
Lazily acquired and instantiated formatter object: initialized first time it is needed, reused afterwards. |
| protected JsonSerializer | _keySerializer
Serializer used to output non-null keys of Maps (which will get output as JSON Objects), if not null; if null, us the standard default key serializer. |
| protected final ReadOnlyClassToSerializerMap | _knownSerializers
For fast lookups, we will have a local non-shared read-only map that contains serializers previously fetched. |
| protected JsonSerializer | _nullKeySerializer
Serializer used to (try to) output a null key, due to an entry of
|
| protected JsonSerializer | _nullValueSerializer
Serializer used to output a null value. |
| protected final Class | _serializationView
View used for currently active serialization, if any. |
| protected final SerializerCache | _serializerCache
Cache for doing type-to-value-serializer lookups. |
| protected final SerializerFactory | _serializerFactory
Factory used for constructing actual serializer instances. |
| protected final boolean | _stdNullValueSerializer
Flag set to indicate that we are using vanilla null value serialization |
| protected JsonSerializer | _unknownTypeSerializer
Serializer that gets called for values of types for which no serializers can be constructed. |
| protected static final boolean | CACHE_UNKNOWN_MAPPINGS
Setting for determining whether mappings for "unknown classes" should be cached for faster resolution. |
| public static final JsonSerializer | |
| protected static final JsonSerializer | DEFAULT_UNKNOWN_SERIALIZER
Placeholder serializer used when |
| Access | Constructor and Description |
|---|---|
| public | SerializerProvider()
Constructor for creating master (or "blue-print") provider object, which is only used as the template for constructing per-binding instances. |
| protected | SerializerProvider(SerializerProvider
Blueprint object used as the baseline for this instance src, SerializationConfig config, SerializerFactory f)"Copy-constructor", used by sub-classes when creating actual non-blueprint instances to use. |
| protected | SerializerProvider(SerializerProvider src)
Copy-constructor used when making a copy of a blueprint instance. |
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected JsonSerializer | _createAndCacheUntypedSerializer(Class<?> rawType)
Method that will try to construct a value serializer; and if one is successfully created, cache it for reuse. |
| protected JsonSerializer | |
| protected JsonSerializer | |
| protected final DateFormat | |
| protected JsonSerializer | Returns: Serializer if one can be found, null if not.Method that will try to find a serializer, either from cache or by constructing one; but will not return an "unknown" serializer if this cannot be done but rather returns null. |
| protected JsonSerializer | _handleContextualResolvable(JsonSerializer<?> ser, BeanProperty property)
Helper method called to resolve and contextualize given serializer, if and as necessary. |
| protected JsonSerializer | |
| protected void | |
| public TokenBuffer | bufferForValueConversion(ObjectCodec oc)
Specialized factory method used when we are converting values and do not typically have or use "real" parsers or generators. |
| public final TokenBuffer | bufferForValueConversion()
Specialized factory method used when we are converting values and do not typically have or use "real" parsers or generators. |
| public final boolean | canOverrideAccessModifiers()
Implements abstract com. getConfig().canOverrideAccessModifiers(); |
| public JavaType | constructSpecializedType(JavaType baseType, Class<?> subclass)
Implements abstract com. |
| public void | defaultSerializeDateKey(long timestamp, JsonGenerator gen)
Method that will handle serialization of Dates used as |
| public void | defaultSerializeDateKey(Date date, JsonGenerator gen)
Method that will handle serialization of Dates used as |
| public final void | defaultSerializeDateValue(long timestamp, JsonGenerator gen)
Method that will handle serialization of Date(-like) values, using
|
| public final void | defaultSerializeDateValue(Date date, JsonGenerator gen)
Method that will handle serialization of Date(-like) values, using
|
| public final void | defaultSerializeField(String fieldName, Object value, JsonGenerator gen)
Convenience method that will serialize given field with specified value. |
| public final void | |
| public final void | defaultSerializeValue(Object value, JsonGenerator gen)
Convenience method that will serialize given value (which can be null) using standard serializer locating functionality. |
| public JsonSerializer | findContentValueSerializer(JavaType
Type of values to serialize valueType, BeanProperty Property that indirectly refers to value being serialized (optional,
may be property)null for root level serializers)Alternative to |
| public JsonSerializer | findContentValueSerializer(Class<?> valueType, BeanProperty property)
|
| public JsonSerializer | findKeySerializer(JavaType keyType, BeanProperty property)
Method called to get the serializer to use for serializing non-null Map keys. |
| public JsonSerializer | |
| public JsonSerializer | Returns: JsonSerializer that handles the serialization of null keys, usually by throwing an exception or using an empty String, but other behaviors are also possible.Method called to find a serializer to serializes Map keys that are nulls, as JSON does not allow any non-String value as a key, including null. |
| public JsonSerializer | findNullValueSerializer(BeanProperty property)
Method called to get the serializer to use for serializing null values for specified property. |
| public abstract WritableObjectId | findObjectId(Object forPojo, ObjectIdGenerator<?> generatorType)
Method called to find the Object Id for given POJO, if one has been generated. |
| public JsonSerializer | findPrimaryPropertySerializer(JavaType
Type of values to serialize valueType, BeanProperty Property that is being handled; will never be null, and its
type has to match property)valueType parameter.Similar to |
| public JsonSerializer | findPrimaryPropertySerializer(Class<?> valueType, BeanProperty property)
|
| public JsonSerializer | findTypedValueSerializer(Class<?>
Type for purpose of locating a serializer; usually dynamic
runtime type, but can also be static declared type, depending on configuration valueType, boolean Whether resulting value serializer should be cached or not; this is just
a hint cache, BeanProperty When creating secondary serializers, property for which
serializer is needed: annotations of the property (or bean that contains it)
may be checked to create contextual serializers. property)Method called to locate regular serializer, matching type serializer, and if both found, wrap them in a serializer that calls both in correct sequence. |
| public JsonSerializer | findTypedValueSerializer(JavaType
Declared type of value being serialized (which may not
be actual runtime type); used for finding both value serializer and
type serializer to use for adding polymorphic type (if any) valueType, boolean Whether resulting value serializer should be cached or not; this is just
a hint cache, BeanProperty When creating secondary serializers, property for which
serializer is needed: annotations of the property (or bean that contains it)
may be checked to create contextual serializers. property)Method called to locate regular serializer, matching type serializer, and if both found, wrap them in a serializer that calls both in correct sequence. |
| public TypeSerializer | findTypeSerializer(JavaType javaType)
Method called to get the |
| public JsonSerializer | findValueSerializer(Class<?> valueType, BeanProperty property)
Method called to get hold of a serializer for a value of given type; or if no such serializer can be found, a default handler (which may do a best-effort generic serialization or just simply throw an exception when invoked). |
| public JsonSerializer | findValueSerializer(JavaType valueType, BeanProperty
When creating secondary serializers, property for which
serializer is needed: annotations of the property (or bean that contains it)
may be checked to create contextual serializers. property)Similar to |
| public JsonSerializer | findValueSerializer(Class<?> valueType)
Method variant used when we do NOT want contextualization to happen; it will need to be handled at a later point, but caller wants to be able to do that as needed; sometimes to avoid infinite loops |
| public JsonSerializer | findValueSerializer(JavaType valueType)
Method variant used when we do NOT want contextualization to happen; it will need to be handled at a later point, but caller wants to be able to do that as needed; sometimes to avoid infinite loops |
| public final Class | getActiveView()
Implements abstract com. |
| public final AnnotationIntrospector | getAnnotationIntrospector()
Implements abstract com. getConfig().getAnnotationIntrospector(); |
| public Object | getAttribute(Object
Key of the attribute to get key)Implements abstract com. |
| public final SerializationConfig | getConfig()
Implements abstract com. |
| public final DatatypeFeatures | getDatatypeFeatures()
Implements abstract com. |
| public JsonSerializer | |
| public JsonSerializer | |
| public final JsonFormat. | getDefaultPropertyFormat(Class<?> baseType)
Implements abstract com. |
| public final JsonInclude. | |
| public final FilterProvider | getFilterProvider()
Convenience method for accessing provider to find serialization filters used, equivalent to calling: getConfig().getFilterProvider(); |
| public JsonGenerator | getGenerator()
Note current implementation simply returns `null` as generator is not yet assigned to this provider. |
| public Locale | getLocale()
Implements abstract com. getConfig().getLocale(); |
| public TimeZone | getTimeZone()
Implements abstract com. getConfig().getTimeZone(); |
| public final TypeFactory | |
| public JsonSerializer | getUnknownTypeSerializer(Class<?>
Type for which no serializer is found unknownType)Method called to get the serializer to use if provider
cannot determine an actual type-specific serializer
to use; typically when none of |
| public JsonSerializer | handlePrimaryContextualization(JsonSerializer<?> ser, BeanProperty
Property for which the given primary serializer is used; never null. property)Method called for primary property serializers (ones
directly created to serialize values of a POJO property),
to handle details of resolving
|
| public JsonSerializer | handleSecondaryContextualization(JsonSerializer<?> ser, BeanProperty
Property for which serializer is used, if any; null
when deserializing root values property)Method called for secondary property serializers (ones
NOT directly created to serialize values of a POJO property
but instead created as a dependant serializer -- such as value serializers
for structured types, or serializers for root values)
to handle details of resolving
|
| public final boolean | hasSerializationFeatures(int featureMask)
"Bulk" access method for checking that all features specified by mask are enabled. |
| public abstract Object | includeFilterInstance(BeanPropertyDefinition
(optional) If filter is created for a property, that property;
`null` if filter created via defaulting, global or per-type. forProperty, Class<?> filterClass)Method that can be called to construct and configure |
| public abstract boolean | includeFilterSuppressNulls(Object filter)
Follow-up method that may be called after calling |
| public JsonMappingException | invalidTypeIdException(JavaType baseType, String typeId, String extraDesc)
Implements abstract com. |
| public final boolean | isEnabled(MapperFeature feature)
Implements abstract com. |
| public final boolean | isEnabled(DatatypeFeature feature)
Implements abstract com. |
| public final boolean | isEnabled(SerializationFeature feature)
Convenience method for checking whether specified serialization feature is enabled or not. |
| public boolean | isUnknownTypeSerializer(JsonSerializer<?> ser)
Helper method called to see if given serializer is considered to be
something returned by |
| public JsonMappingException | mappingException(String message, Object... msgArgs)
Deprecated
Since 2.9
Factory method for constructing a JsonMappingException;
usually only indirectly used by calling
reportMappingProblem(String, Object..
|
| protected JsonMappingException | mappingException(Throwable t, String message, Object... msgArgs)
Deprecated
Since 2.9
Factory method for constructing a JsonMappingException;
usually only indirectly used by calling
reportMappingProblem(Throwable, String, Object.
|
| public <T> T | reportBadDefinition(JavaType type, String msg)
Implements abstract com. com..
|
| public <T> T | |
| public <T> T | |
| public <T> T | reportBadPropertyDefinition(BeanDescription bean, BeanPropertyDefinition prop, String message, Object... msgArgs)
Helper method called to indicate problem in POJO (serialization) definitions or settings regarding specific property (of a type), unrelated to actual JSON content to map. |
| public <T> T | reportBadTypeDefinition(BeanDescription bean, String msg, Object... msgArgs)
Helper method called to indicate problem in POJO (serialization) definitions or settings regarding specific Java type, unrelated to actual JSON content to map. |
| public void | reportMappingProblem(String message, Object... args)
Helper method called to indicate problem; default behavior is to construct and
throw a |
| public void | reportMappingProblem(Throwable t, String message, Object... msgArgs)
Helper method called to indicate problem; default behavior is to construct and
throw a |
| public abstract JsonSerializer | serializerInstance(Annotated
Annotated entity that contained definition annotated, Object Serializer definition: either an instance or class serDef)Method that can be called to construct and configure serializer instance,
either given a |
| public SerializerProvider | setAttribute(Object
Key of the attribute to set key, Object Value to set attribute to value)Implements abstract com. |
| public void | setDefaultKeySerializer(JsonSerializer<Object> ks)
Method that can be used to specify serializer to use for serializing all non-null JSON property names, unless more specific key serializer is found (i.e. if not custom key serializer has been registered for Java type). |
| public void | setNullKeySerializer(JsonSerializer<Object> nks)
Method that can be used to specify serializer that will be used to write JSON property names matching null keys for Java Maps (which will otherwise throw an exception if try write such property name) |
| public void | setNullValueSerializer(JsonSerializer<Object> nvs)
Method that can be used to specify serializer that will be used to write JSON values matching Java null values instead of default one (which simply writes JSON null). |