Top Description Inners Constructors Methods
tools.jackson.databind.ser.jdk

public Class NumberSerializers

extends Object
Class Inheritance
Imports
java.math.BigDecimal, java.util.Map, com.fasterxml.jackson.annotation.JsonFormat, tools.jackson.core.*, tools.jackson.core.io.NumberOutput, tools.jackson.core.type.WritableTypeId, tools.jackson.databind.*, tools.jackson.databind.annotation.JacksonStdImpl, tools.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper, tools.jackson.databind.jsontype.TypeSerializer, tools.jackson.databind.ser.std.StdScalarSerializer, .ToStringSerializer

Container class for serializers used for handling standard JDK-provided primitive number types and their wrapper counterparts (like java.lang.Integer).

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
NumberSerializers.Base<T>

Base class for actual primitive/wrapper value serializers.

public static class
NumberSerializers.DoubleSerializer

This is the special serializer for regular java.lang.Doubles (and primitive doubles)

Since this is one of "native" types, no type information is ever included on serialization (unlike for most scalar types as of 1.5)

public static class
public static class
NumberSerializers.IntegerSerializer

This is the special serializer for regular java.lang.Integers (and primitive ints)

Since this is one of "natural" types, no type information is ever included on serialization (unlike for most scalar types, except for double).

public static class
NumberSerializers.IntLikeSerializer

Similar to IntegerSerializer, but will not cast to Integer: instead, cast is to java.lang.Number, and conversion is by calling java.lang.Number#intValue.

public static class
public static class

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static void
addAll(Map<String, ValueSerializer<?>> allDeserializers)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NumberSerializersback to summary
protected NumberSerializers()

Method Detail

addAllback to summary
public static void addAll(Map<String, ValueSerializer<?>> allDeserializers)
tools.jackson.databind.ser.jdk back to summary

public abstract Class NumberSerializers.Base<T>

extends StdScalarSerializer<T>
Class Inheritance
Known Direct Subclasses
tools.jackson.databind.ser.jdk.NumberSerializers.ShortSerializer, tools.jackson.databind.ser.jdk.NumberSerializers.IntegerSerializer, tools.jackson.databind.ser.jdk.NumberSerializers.IntLikeSerializer, tools.jackson.databind.ser.jdk.NumberSerializers.LongSerializer, tools.jackson.databind.ser.jdk.NumberSerializers.FloatSerializer, tools.jackson.databind.ser.jdk.NumberSerializers.DoubleSerializer

Base class for actual primitive/wrapper value serializers.

Note

while you can extend this class yourself it is not designed as an extension point, and as such is not part of public API. This means that the compatibility across minor versions is only guaranteed on minor-to-minor basis, and class methods may be changed and/or removed via deprecation mechanism. Intent is, however, to allow for gradual upgrading so that methods to remove are marked deprecated for at least one minor version.

Field Summary

Modifier and TypeField and Description
protected final boolean
protected final JsonParser.NumberType
protected final String

Constructor Summary

AccessConstructor and Description
protected
Base(Class<?> cls, JsonParser.NumberType numberType, String schemaType)

Method Summary

Modifier and TypeMethod and Description
public void
public ValueSerializer<?>
createContextual(SerializationContext prov, BeanProperty property)

Overrides tools.jackson.databind.ValueSerializer.createContextual.

Method called to see if a different (or differently configured) serializer is needed to serialize values of specified property (or, for root values, in which case `null` is passed).

Inherited from tools.jackson.databind.ser.std.StdScalarSerializer:
serializeWithType

Field Detail

_isIntback to summary
protected final boolean _isInt
_numberTypeback to summary
protected final JsonParser.NumberType _numberType
_schemaTypeback to summary
protected final String _schemaType

Constructor Detail

Baseback to summary
protected Base(Class<?> cls, JsonParser.NumberType numberType, String schemaType)

Method Detail

acceptJsonFormatVisitorback to summary
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)

Overrides tools.jackson.databind.ser.std.StdScalarSerializer.acceptJsonFormatVisitor.

Implements tools.jackson.databind.jsonFormatVisitors.JsonFormatVisitable.acceptJsonFormatVisitor.

Doc from tools.jackson.databind.ser.std.StdSerializer.acceptJsonFormatVisitor.

Default implementation specifies no format. This behavior is usually overriden by custom serializers.

Annotations
@Override
createContextualback to summary
public ValueSerializer<?> createContextual(SerializationContext prov, BeanProperty property)

Overrides tools.jackson.databind.ValueSerializer.createContextual.

Doc from tools.jackson.databind.ValueSerializer.createContextual.

Method called to see if a different (or differently configured) serializer is needed to serialize values of specified property (or, for root values, in which case `null` is passed). Note that instance that this method is called on is typically shared one and as a result method should NOT modify this instance but rather construct and return a new instance. This instance should only be returned as-is, in case it is already suitable for use.

Note that method is only called once per POJO property, and for the first usage as root value serializer; it is not called for every serialization, as doing that would have significant performance impact; most serializers cache contextual instances for future use.

Annotations
@Override
tools.jackson.databind.ser.jdk back to summary

public Class NumberSerializers.DoubleSerializer

extends NumberSerializers.Base<Object>
Class Inheritance
Annotations
@JacksonStdImpl

This is the special serializer for regular java.lang.Doubles (and primitive doubles)

Since this is one of "native" types, no type information is ever included on serialization (unlike for most scalar types as of 1.5)

Field Summary

Inherited from tools.jackson.databind.ser.jdk.NumberSerializers.Base:
_isInt_numberType_schemaType

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
serialize(Object value, JsonGenerator gen, SerializationContext provider)

Implements abstract tools.jackson.databind.ser.std.StdSerializer.serialize.

Method that can be called to ask implementation to serialize values of type this serializer handles.

public void
serializeWithType(Object value, JsonGenerator g, SerializationContext ctxt, TypeSerializer typeSer)

Overrides tools.jackson.databind.ser.std.StdScalarSerializer.serializeWithType.

Default implementation will write type prefix, call regular serialization method (since assumption is that value itself does not need JSON Array or Object start/end markers), and then write type suffix.

Inherited from tools.jackson.databind.ser.jdk.NumberSerializers.Base:
acceptJsonFormatVisitorcreateContextual

Constructor Detail

DoubleSerializerback to summary
public DoubleSerializer(Class<?> cls)

Method Detail

serializeback to summary
public void serialize(Object value, JsonGenerator gen, SerializationContext provider) throws JacksonException

Implements abstract tools.jackson.databind.ser.std.StdSerializer.serialize.

Doc from tools.jackson.databind.ValueSerializer.serialize.

Method that can be called to ask implementation to serialize values of type this serializer handles.

Annotations
@Override
serializeWithTypeback to summary
public void serializeWithType(Object value, JsonGenerator g, SerializationContext ctxt, TypeSerializer typeSer) throws JacksonException

Overrides tools.jackson.databind.ser.std.StdScalarSerializer.serializeWithType.

Doc from tools.jackson.databind.ser.std.StdScalarSerializer.serializeWithType.

Default implementation will write type prefix, call regular serialization method (since assumption is that value itself does not need JSON Array or Object start/end markers), and then write type suffix. This should work for most cases; some sub-classes may want to change this behavior.

Annotations
@Override
tools.jackson.databind.ser.jdk back to summary

public Class NumberSerializers.FloatSerializer

extends NumberSerializers.Base<Object>
Class Inheritance
Annotations
@JacksonStdImpl

Field Summary

Modifier and TypeField and Description
pack-priv static final NumberSerializers.FloatSerializer
Inherited from tools.jackson.databind.ser.jdk.NumberSerializers.Base:
_isInt_numberType_schemaType

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
serialize(Object value, JsonGenerator gen, SerializationContext provider)

Implements abstract tools.jackson.databind.ser.std.StdSerializer.serialize.

Method that can be called to ask implementation to serialize values of type this serializer handles.

Inherited from tools.jackson.databind.ser.jdk.NumberSerializers.Base:
acceptJsonFormatVisitorcreateContextual

Field Detail

instanceback to summary
pack-priv static final NumberSerializers.FloatSerializer instance

Constructor Detail

FloatSerializerback to summary
public FloatSerializer()

Method Detail

serializeback to summary
public void serialize(Object value, JsonGenerator gen, SerializationContext provider) throws JacksonException

Implements abstract tools.jackson.databind.ser.std.StdSerializer.serialize.

Doc from tools.jackson.databind.ValueSerializer.serialize.

Method that can be called to ask implementation to serialize values of type this serializer handles.

Annotations
@Override
tools.jackson.databind.ser.jdk back to summary

public Class NumberSerializers.IntegerSerializer

extends NumberSerializers.Base<Object>
Class Inheritance
Annotations
@JacksonStdImpl

This is the special serializer for regular java.lang.Integers (and primitive ints)

Since this is one of "natural" types, no type information is ever included on serialization (unlike for most scalar types, except for double).

Field Summary

Inherited from tools.jackson.databind.ser.jdk.NumberSerializers.Base:
_isInt_numberType_schemaType

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
serialize(Object value, JsonGenerator gen, SerializationContext provider)

Implements abstract tools.jackson.databind.ser.std.StdSerializer.serialize.

Method that can be called to ask implementation to serialize values of type this serializer handles.

public void
serializeWithType(Object value, JsonGenerator gen, SerializationContext provider, TypeSerializer typeSer)

Overrides tools.jackson.databind.ser.std.StdScalarSerializer.serializeWithType.

Default implementation will write type prefix, call regular serialization method (since assumption is that value itself does not need JSON Array or Object start/end markers), and then write type suffix.

Inherited from tools.jackson.databind.ser.jdk.NumberSerializers.Base:
acceptJsonFormatVisitorcreateContextual

Constructor Detail

IntegerSerializerback to summary
public IntegerSerializer(Class<?> type)

Method Detail

serializeback to summary
public void serialize(Object value, JsonGenerator gen, SerializationContext provider) throws JacksonException

Implements abstract tools.jackson.databind.ser.std.StdSerializer.serialize.

Doc from tools.jackson.databind.ValueSerializer.serialize.

Method that can be called to ask implementation to serialize values of type this serializer handles.

Annotations
@Override
serializeWithTypeback to summary
public void serializeWithType(Object value, JsonGenerator gen, SerializationContext provider, TypeSerializer typeSer) throws JacksonException

Overrides tools.jackson.databind.ser.std.StdScalarSerializer.serializeWithType.

Doc from tools.jackson.databind.ser.std.StdScalarSerializer.serializeWithType.

Default implementation will write type prefix, call regular serialization method (since assumption is that value itself does not need JSON Array or Object start/end markers), and then write type suffix. This should work for most cases; some sub-classes may want to change this behavior.

Annotations
@Override
tools.jackson.databind.ser.jdk back to summary

public Class NumberSerializers.IntLikeSerializer

extends NumberSerializers.Base<Object>
Class Inheritance
Annotations
@JacksonStdImpl

Similar to IntegerSerializer, but will not cast to Integer: instead, cast is to java.lang.Number, and conversion is by calling java.lang.Number#intValue.

Field Summary

Modifier and TypeField and Description
pack-priv static final NumberSerializers.IntLikeSerializer
Inherited from tools.jackson.databind.ser.jdk.NumberSerializers.Base:
_isInt_numberType_schemaType

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
serialize(Object value, JsonGenerator gen, SerializationContext provider)

Implements abstract tools.jackson.databind.ser.std.StdSerializer.serialize.

Method that can be called to ask implementation to serialize values of type this serializer handles.

Inherited from tools.jackson.databind.ser.jdk.NumberSerializers.Base:
acceptJsonFormatVisitorcreateContextual

Field Detail

instanceback to summary
pack-priv static final NumberSerializers.IntLikeSerializer instance

Constructor Detail

IntLikeSerializerback to summary
public IntLikeSerializer()

Method Detail

serializeback to summary
public void serialize(Object value, JsonGenerator gen, SerializationContext provider) throws JacksonException

Implements abstract tools.jackson.databind.ser.std.StdSerializer.serialize.

Doc from tools.jackson.databind.ValueSerializer.serialize.

Method that can be called to ask implementation to serialize values of type this serializer handles.

Annotations
@Override
tools.jackson.databind.ser.jdk back to summary

public Class NumberSerializers.LongSerializer

extends NumberSerializers.Base<Object>
Class Inheritance
Annotations
@JacksonStdImpl

Field Summary

Inherited from tools.jackson.databind.ser.jdk.NumberSerializers.Base:
_isInt_numberType_schemaType

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
serialize(Object value, JsonGenerator gen, SerializationContext provider)

Implements abstract tools.jackson.databind.ser.std.StdSerializer.serialize.

Method that can be called to ask implementation to serialize values of type this serializer handles.

Inherited from tools.jackson.databind.ser.jdk.NumberSerializers.Base:
acceptJsonFormatVisitorcreateContextual

Constructor Detail

LongSerializerback to summary
public LongSerializer(Class<?> cls)

Method Detail

serializeback to summary
public void serialize(Object value, JsonGenerator gen, SerializationContext provider) throws JacksonException

Implements abstract tools.jackson.databind.ser.std.StdSerializer.serialize.

Doc from tools.jackson.databind.ValueSerializer.serialize.

Method that can be called to ask implementation to serialize values of type this serializer handles.

Annotations
@Override
tools.jackson.databind.ser.jdk back to summary

public Class NumberSerializers.ShortSerializer

extends NumberSerializers.Base<Object>
Class Inheritance
Annotations
@JacksonStdImpl

Field Summary

Modifier and TypeField and Description
pack-priv static final NumberSerializers.ShortSerializer
Inherited from tools.jackson.databind.ser.jdk.NumberSerializers.Base:
_isInt_numberType_schemaType

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
serialize(Object value, JsonGenerator gen, SerializationContext provider)

Implements abstract tools.jackson.databind.ser.std.StdSerializer.serialize.

Method that can be called to ask implementation to serialize values of type this serializer handles.

Inherited from tools.jackson.databind.ser.jdk.NumberSerializers.Base:
acceptJsonFormatVisitorcreateContextual

Field Detail

instanceback to summary
pack-priv static final NumberSerializers.ShortSerializer instance

Constructor Detail

ShortSerializerback to summary
public ShortSerializer()

Method Detail

serializeback to summary
public void serialize(Object value, JsonGenerator gen, SerializationContext provider) throws JacksonException

Implements abstract tools.jackson.databind.ser.std.StdSerializer.serialize.

Doc from tools.jackson.databind.ValueSerializer.serialize.

Method that can be called to ask implementation to serialize values of type this serializer handles.

Annotations
@Override