java.lang.Object
tools.jackson.databind.ValueSerializer<T>
tools.jackson.databind.ser.std.StdSerializer<T>
- All Implemented Interfaces:
JsonFormatVisitable
- Direct Known Subclasses:
BeanSerializerBase,ByteArraySerializer,DOMSerializer,DoubleStreamSerializer,DurationSerializer,FailingSerializer,InstantSerializerBase,IntStreamSerializer,JacksonSerializableSerializer,Jdk8StreamSerializer,JDKArraySerializers.CharArraySerializer,JDKKeySerializers.Default,JDKKeySerializers.Dynamic,JDKKeySerializers.EnumKeySerializer,JDKKeySerializers.StringKeySerializer,JDKStringLikeSerializer,LocalDateSerializer,LocalDateTimeSerializer,LocalTimeSerializer,LongStreamSerializer,MapEntryAsPOJOSerializer,MonthDaySerializer,MonthSerializer,NullSerializer,OffsetTimeSerializer,QNameSerializer,RawSerializer,StaticListSerializerBase,StdContainerSerializer,StdDelegatingSerializer,StdDynamicSerializer,StdScalarSerializer,ToEmptyObjectSerializer,TokenBufferSerializer,ToStringSerializerBase,UnsupportedTypeSerializer,XMLGregorianCalendarSerializer,YearMonthSerializer,YearSerializer
Base class used by all standard serializers, and can also
be used for custom serializers (in fact, this is the recommended
base class to use).
-
Nested Class Summary
Nested classes/interfaces inherited from class tools.jackson.databind.ValueSerializer
ValueSerializer.None -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Class<?>Nominal type supported, usually declared type of property for which serializer is used. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStdSerializer(Class<?> t) protectedStdSerializer(Class<?> t, boolean dummy) Deprecated.protectedStdSerializer(JavaType type) protectedStdSerializer(StdSerializer<?> src) -
Method Summary
Modifier and TypeMethodDescriptionprotected static final boolean_neitherNull(Object a, Object b) protected static final boolean_nonEmpty(Collection<?> c) protected JacksonExceptionvoidacceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) Default implementation specifies no format.protected voidacceptJsonFormatVisitorForBinary(JsonFormatVisitorWrapper visitor, JavaType typeHint) Helper method for handling Binary values: typically serialized as Base64-encoded data (in textual formats) or native binary (binary formats).protected ObjectNodecreateSchemaNode(String type) protected ObjectNodecreateSchemaNode(String type, boolean isOptional) protected ValueSerializer<?>findAnnotatedContentSerializer(SerializationContext serializers, BeanProperty property) Convenience method for finding out possibly configured content value serializer.protected ValueSerializer<?>findContextualConvertingSerializer(SerializationContext provider, BeanProperty prop, ValueSerializer<?> existingSerializer) Helper method that can be used to see if specified property has annotation indicating that a converter is to be used for contained values (contents of structured types; array/List/Map values)protected BooleanfindFormatFeature(SerializationContext provider, BeanProperty prop, Class<?> typeForDefaults, JsonFormat.Feature feat) Convenience method that usesfindFormatOverrides(tools.jackson.databind.SerializationContext, tools.jackson.databind.BeanProperty, java.lang.Class<?>)to find possible defaults and/of overrides, and then callsJsonFormat.Value.getFeature(...)to find whether that feature has been specifically marked as enabled or disabled.protected JsonFormat.ValuefindFormatOverrides(SerializationContext provider, BeanProperty prop, Class<?> typeForDefaults) Helper method that may be used to find if this deserializer has specificJsonFormatsettings, either via property, or through type-specific defaulting.protected JsonInclude.ValuefindIncludeOverrides(SerializationContext provider, BeanProperty prop, Class<?> typeForDefaults) protected PropertyFilterfindPropertyFilter(SerializationContext provider, Object filterId, Object valueToFilter) Helper method used to locate filter that is needed, based on filter id this serializer was constructed with.Class<?>Method for accessing type of Objects this serializer can handle.protected booleanisDefaultSerializer(ValueSerializer<?> serializer) Method that can be called to determine if given serializer is the default serializer Jackson uses; as opposed to a custom serializer installed by a module or calling application.abstract voidserialize(T value, JsonGenerator gen, SerializationContext provider) Method that can be called to ask implementation to serialize values of type this serializer handles.protected voidvisitArrayFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint, JsonFormatTypes itemType) protected voidvisitArrayFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint, ValueSerializer<?> itemSerializer, JavaType itemType) protected voidvisitFloatFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint, JsonParser.NumberType numberType) Helper method that calls necessary visit method(s) to indicate that the underlying JSON type is a floating-point JSON number.protected voidvisitIntFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint, JsonParser.NumberType numberType) Helper method that calls necessary visit method(s) to indicate that the underlying JSON type is JSON Integer number.protected voidvisitIntFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint, JsonParser.NumberType numberType, JsonValueFormat format) Helper method that calls necessary visit method(s) to indicate that the underlying JSON type is JSON Integer number, but that there is also a further format restriction involved.protected voidvisitStringFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint) Helper method that calls necessary visit method(s) to indicate that the underlying JSON type is JSON String.protected voidvisitStringFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint, JsonValueFormat format) Helper method that calls necessary visit method(s) to indicate that the underlying JSON type is JSON String, but that there is a more refined logical typevoidwrapAndThrow(SerializationContext ctxt, Throwable t, Object bean, int index) voidwrapAndThrow(SerializationContext ctxt, Throwable t, Object bean, String fieldName) Method that will modify caught exception (passed in as argument) as necessary to include reference information, and to ensure it is a subtype ofJacksonException, or an unchecked exception.Methods inherited from class tools.jackson.databind.ValueSerializer
createContextual, getDelegatee, isEmpty, isUnwrappingSerializer, properties, replaceDelegatee, resolve, serializeWithType, unwrappingSerializer, usesObjectId, withFilterId, withFormatOverrides, withIgnoredProperties
-
Field Details
-
_handledType
Nominal type supported, usually declared type of property for which serializer is used.
-
-
Constructor Details
-
StdSerializer
-
StdSerializer
-
StdSerializer
Deprecated.Alternate constructor that is (alas!) needed to work around kinks of generic type handling -
StdSerializer
-
-
Method Details
-
handledType
Description copied from class:ValueSerializerMethod for accessing type of Objects this serializer can handle. Note that this information is not guaranteed to be exact -- it may be a more generic (super-type) -- but it should not be incorrect (return a non-related type).NOTE: starting with 3.0, left
abstract.- Overrides:
handledTypein classValueSerializer<T>
-
serialize
public abstract void serialize(T value, JsonGenerator gen, SerializationContext provider) throws JacksonException Description copied from class:ValueSerializerMethod that can be called to ask implementation to serialize values of type this serializer handles.- Specified by:
serializein classValueSerializer<T>- Parameters:
value- Value to serialize; can not be null.gen- Generator used to output resulting Json contentprovider- Context that can be used to get serializers for serializing Objects value contains, if any.- Throws:
JacksonException
-
acceptJsonFormatVisitor
Default implementation specifies no format. This behavior is usually overriden by custom serializers.- Specified by:
acceptJsonFormatVisitorin interfaceJsonFormatVisitable- Overrides:
acceptJsonFormatVisitorin classValueSerializer<T>typeHint- Type of element (entity like property) being visited
-
acceptJsonFormatVisitorForBinary
protected void acceptJsonFormatVisitorForBinary(JsonFormatVisitorWrapper visitor, JavaType typeHint) Helper method for handling Binary values: typically serialized as Base64-encoded data (in textual formats) or native binary (binary formats). -
createSchemaNode
-
createSchemaNode
-
visitStringFormat
Helper method that calls necessary visit method(s) to indicate that the underlying JSON type is JSON String. -
visitStringFormat
protected void visitStringFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint, JsonValueFormat format) Helper method that calls necessary visit method(s) to indicate that the underlying JSON type is JSON String, but that there is a more refined logical type -
visitIntFormat
protected void visitIntFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint, JsonParser.NumberType numberType) Helper method that calls necessary visit method(s) to indicate that the underlying JSON type is JSON Integer number. -
visitIntFormat
protected void visitIntFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint, JsonParser.NumberType numberType, JsonValueFormat format) Helper method that calls necessary visit method(s) to indicate that the underlying JSON type is JSON Integer number, but that there is also a further format restriction involved. -
visitFloatFormat
protected void visitFloatFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint, JsonParser.NumberType numberType) Helper method that calls necessary visit method(s) to indicate that the underlying JSON type is a floating-point JSON number. -
visitArrayFormat
protected void visitArrayFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint, ValueSerializer<?> itemSerializer, JavaType itemType) -
visitArrayFormat
protected void visitArrayFormat(JsonFormatVisitorWrapper visitor, JavaType typeHint, JsonFormatTypes itemType) -
wrapAndThrow
public void wrapAndThrow(SerializationContext ctxt, Throwable t, Object bean, String fieldName) throws JacksonException Method that will modify caught exception (passed in as argument) as necessary to include reference information, and to ensure it is a subtype ofJacksonException, or an unchecked exception.Rules for wrapping and unwrapping are bit complicated; essentially:
- Errors are to be passed as is (if uncovered via unwrapping)
- Wrapped
IOExceptions are unpeeled
- Throws:
JacksonException
-
wrapAndThrow
public void wrapAndThrow(SerializationContext ctxt, Throwable t, Object bean, int index) throws JacksonException - Throws:
JacksonException
-
findContextualConvertingSerializer
protected ValueSerializer<?> findContextualConvertingSerializer(SerializationContext provider, BeanProperty prop, ValueSerializer<?> existingSerializer) Helper method that can be used to see if specified property has annotation indicating that a converter is to be used for contained values (contents of structured types; array/List/Map values)- Parameters:
existingSerializer- (optional) configured content serializer if one already exists.
-
findPropertyFilter
protected PropertyFilter findPropertyFilter(SerializationContext provider, Object filterId, Object valueToFilter) Helper method used to locate filter that is needed, based on filter id this serializer was constructed with. -
findFormatOverrides
protected JsonFormat.Value findFormatOverrides(SerializationContext provider, BeanProperty prop, Class<?> typeForDefaults) Helper method that may be used to find if this deserializer has specificJsonFormatsettings, either via property, or through type-specific defaulting.- Parameters:
typeForDefaults- Type (erased) used for finding default format settings, if any
-
findFormatFeature
protected Boolean findFormatFeature(SerializationContext provider, BeanProperty prop, Class<?> typeForDefaults, JsonFormat.Feature feat) Convenience method that usesfindFormatOverrides(tools.jackson.databind.SerializationContext, tools.jackson.databind.BeanProperty, java.lang.Class<?>)to find possible defaults and/of overrides, and then callsJsonFormat.Value.getFeature(...)to find whether that feature has been specifically marked as enabled or disabled.- Parameters:
typeForDefaults- Type (erased) used for finding default format settings, if any
-
findIncludeOverrides
protected JsonInclude.Value findIncludeOverrides(SerializationContext provider, BeanProperty prop, Class<?> typeForDefaults) -
findAnnotatedContentSerializer
protected ValueSerializer<?> findAnnotatedContentSerializer(SerializationContext serializers, BeanProperty property) Convenience method for finding out possibly configured content value serializer. -
isDefaultSerializer
Method that can be called to determine if given serializer is the default serializer Jackson uses; as opposed to a custom serializer installed by a module or calling application. Determination is done usingJacksonStdImplannotation on serializer class. -
_neitherNull
-
_nonEmpty
-
_wrapIOFailure
-