ObjectMapper and
ValueSerializers 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.
Note
In Jackson 2.x this class was called SerializerProvider.
| Modifier and Type | Field and Description |
|---|---|
| protected final Class | _activeView
View used for currently active serialization, if any. |
| protected ContextAttributes | _attributes
Lazily-constructed holder for per-call attributes. |
| protected transient ClassIntrospector | _classIntrospector
Lazily constructed |
| 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 transient JsonGenerator | _generator
Token stream generator actively used; only set for per-call instances |
| protected final GeneratorSettings | _generatorConfig
Configuration to be used by streaming generator when it is constructed. |
| protected final ReadOnlyClassToSerializerMap | _knownSerializers
For fast lookups, we will have a local non-shared read-only map that contains serializers previously fetched. |
| protected final ValueSerializer | _nullValueSerializer
Serializer used to output a null value. |
| 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 final TokenStreamFactory | _streamFactory
Low-level |
| protected JacksonFeatureSet | _writeCapabilities
Capabilities of the output format. |
| protected static final ValueSerializer | DEFAULT_UNKNOWN_SERIALIZER
Placeholder serializer used when |
| Access | Constructor and Description |
|---|---|
| protected | SerializationContext(TokenStreamFactory streamFactory, SerializationConfig config, GeneratorSettings generatorConfig, SerializerFactory f, SerializerCache cache)
|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected void | _assignGenerator(JsonGenerator
Generator to use for writing output g)Method called to assign the generator to use for writing output; also updates configuration settings that depend on generator. |
| private ValueSerializer | _checkShapeShifting(JavaType type, BeanDescription.
|
| protected ValueSerializer | _createAndCachePropertySerializer(Class<?> rawType, JavaType fullType, BeanProperty prop)
Alternative to |
| protected ValueSerializer | _createAndCachePropertySerializer(JavaType type, BeanProperty prop)
Alternative to |
| protected ValueSerializer | _createAndCacheUntypedSerializer(Class<?> rawType, JavaType fullType)
Method that will try to construct a value serializer; and if one is successfully created, cache it for reuse. |
| protected ValueSerializer | |
| protected final DateFormat | |
| protected ValueSerializer | |
| protected DatabindException | |
| protected void | |
| public 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 tools. Convenience method for accessing serialization view in use (if any); equivalent to: getConfig().canOverrideAccessModifiers(); |
| protected ClassIntrospector | |
| public JavaType | constructSpecializedType(JavaType baseType, Class<?> subclass)
Implements abstract tools. Convenience method for constructing subtypes, retaining generic type parameter (if any). |
| public ArrayTreeNode | createArrayNode()
Implements tools. Method for construct Array nodes for Tree Model instances. |
| public ObjectTreeNode | createObjectNode()
Implements tools. Method for construct Object nodes for Tree Model instances. |
| public void | defaultSerializeDateKey(long timestamp, JsonGenerator g)
Method that will handle serialization of Dates used as |
| public void | defaultSerializeDateKey(Date date, JsonGenerator g)
Method that will handle serialization of Dates used as |
| public final void | defaultSerializeDateValue(long timestamp, JsonGenerator g)
Method that will handle serialization of Date(-like) values, using
|
| public final void | defaultSerializeDateValue(Date date, JsonGenerator g)
Method that will handle serialization of Date(-like) values, using
|
| public final void | defaultSerializeNullValue(JsonGenerator g)
Method to call when serializing a |
| public final void | defaultSerializeProperty(String propertyName, Object value, JsonGenerator g)
Convenience method that will serialize given property with specified
value, using the default serializer for runtime type of |
| public ValueSerializer | findContentValueSerializer(JavaType
Type of (secondary / content) values being serialized valueType, BeanProperty (optional) Property that refers to values via primary type (so type
DOES NOT necessarily match property)valueType)Method similar to |
| public ValueSerializer | findContentValueSerializer(Class<?> rawType, BeanProperty property)
|
| public ValueSerializer | findKeySerializer(JavaType keyType, BeanProperty property)
Method called to get the serializer to use for serializing non-null Map keys. |
| public ValueSerializer | |
| public ValueSerializer | findNullKeySerializer(JavaType serializationType, BeanProperty property)
Method called to find a serializer to use for null values for given declared type. |
| public ValueSerializer | 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 ValueSerializer | findPrimaryPropertySerializer(JavaType valueType, BeanProperty
Property that is being handled; will never be null, and its
type has to match property)valueType parameter.Method used for locating "primary" property value serializer (one directly handling value of the property). |
| public ValueSerializer | |
| public TypeSerializer | Returns: Type serializer to use for property values, if one is needed; null if not.Declared type to use as the base type for type information serializer baseType, AnnotatedMember accessor)Like |
| public PropertyName | findRootName(JavaType rootType)
Implements abstract tools.
|
| public PropertyName | findRootName(Class<?> rawRootType)
Implements abstract tools.
|
| public ValueSerializer | findRootValueSerializer(Class<?> rawType)
Method for finding (from cache) or creating (and caching) serializer for given type, without checking for polymorphic typing, and then contextualizing without actual property. |
| public ValueSerializer | findRootValueSerializer(JavaType valueType)
Method for finding (from cache) or creating (and caching) serializer for given type, without checking for polymorphic typing, and then contextualizing without actual property. |
| public ValueSerializer | findTypedValueSerializer(Class<?>
Type for purpose of locating a serializer; usually dynamic
runtime type, but can also be static declared type, depending on configuration rawType, boolean Whether resulting value serializer should be cached or not cache)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 ValueSerializer | 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 cache)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 baseType)
Method called to get the |
| public TypeSerializer | findTypeSerializer(JavaType baseType, AnnotatedClass classAnnotations)
Method called to get the |
| public ValueSerializer | |
| public ValueSerializer | findValueSerializer(JavaType valueType)
Method variant used when we do NOT want contextualization to happen; it will need
to be done at a later point (many serializers are not in operational state before
contextualization, call to |
| public final Class | getActiveView()
Implements abstract tools. Accessor for locating currently active view, if any; returns null if no view has been set. |
| public final AnnotationIntrospector | getAnnotationIntrospector()
Implements abstract tools. Convenience method for accessing serialization view in use (if any); equivalent to: getConfig().getAnnotationIntrospector(); |
| public Object | getAttribute(Object key)
Implements abstract tools. Method for accessing attributes available in this context. |
| public CharacterEscapes | |
| public final SerializationConfig | getConfig()
Implements abstract tools. Method for accessing configuration for the serialization processing. |
| public final DatatypeFeatures | getDatatypeFeatures()
Implements abstract tools.
|
| public ValueSerializer | |
| public final JsonFormat. | getDefaultPropertyFormat(Class<?> baseType)
Implements abstract tools.
|
| public final JsonInclude. | |
| public final FilterProvider | getFilterProvider()
Convenience method for accessing provider to find serialization filters used, equivalent to calling: getConfig().getFilterProvider(); |
| public int | getFormatWriteFeatures(int defaults)
Implements tools.
|
| public JsonGenerator | |
| public Locale | getLocale()
Implements abstract tools. Method for accessing default Locale to use: convenience method for getConfig().getLocale(); |
| public PrettyPrinter | getPrettyPrinter()
Implements tools. Accessor for getting |
| public SerializableString | getRootValueSeparator(SerializableString defaultSeparator)
Implements tools.
|
| public FormatSchema | |
| public int | getStreamWriteFeatures(int defaults)
Implements tools.
|
| public TimeZone | getTimeZone()
Implements abstract tools. Method for accessing default TimeZone to use: convenience method for getConfig().getTimeZone(); |
| public final TypeFactory | |
| public ValueSerializer | 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 ValueSerializer | handlePrimaryContextualization(ValueSerializer<?> 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 contextualization, calling
|
| public ValueSerializer | |
| public ValueSerializer | handleSecondaryContextualization(ValueSerializer<?> 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 contextualization, calling
|
| public boolean | hasPrettyPrinter()
Implements tools. Accessor similar to |
| 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 BeanDescription | introspectBeanDescription(JavaType type, AnnotatedClass ac)
Implements abstract tools.
|
| public DatabindException | invalidTypeIdException(JavaType baseType, String typeId, String extraDesc)
Implements abstract tools. Helper method for constructing exception to indicate that given type id could not be resolved to a valid subtype of specified base type. |
| public final boolean | isEnabled(MapperFeature feature)
Implements abstract tools. Convenience method for checking whether specified Mapper feature is enabled or not. |
| public final boolean | isEnabled(DatatypeFeature feature)
Implements abstract tools. Method for checking whether specified datatype feature is enabled or not. |
| public final boolean | isEnabled(SerializationFeature feature)
Convenience method for checking whether specified serialization feature is enabled or not. |
| public final boolean | Returns: True if input format has specified capability; false if notAccessor for checking whether input format has specified capability or not. |
| public boolean | isUnknownTypeSerializer(ValueSerializer<?> ser)
Helper method called to see if given serializer is considered to be
something returned by |
| public <T> T | reportBadDefinition(JavaType type, String msg)
Implements abstract tools. Helper method called to indicate a generic problem that stems from type
definition(s), not input data, or input/output state; typically this
means throwing a |
| 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)
Implements abstract tools. 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(Throwable t, String message, Object... msgArgs)
Helper method called to indicate problem; default behavior is to construct and
throw a |
| public void | reportMappingProblem(String message, Object... msgArgs)
Helper method called to indicate problem; default behavior is to construct and
throw a |
| public abstract ValueSerializer | 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 SerializationContext | setAttribute(Object key, Object value)
Implements abstract tools. Method for setting per-call value of given attribute. |
| public TokenStreamFactory | |
| public abstract < Actual node type; usually either basic T extends JsonNode> TJsonNode or
tools. | Returns: (non-null) Root node of the resulting content tree: in case ofnull value node for which JsonNode#isNull() returns true.Java value to convert fromValue)Method that will convert given Java value (usually bean) into its
equivalent Tree mode |
| public void | writeTree(JsonGenerator gen, TreeNode tree)
Implements tools.
|
| public void | writeValue(JsonGenerator gen, Object value)
Implements tools. Method that may be called to serialize given value, using specified token stream generator. |