public abstract class DateTimeSerializerBase<T> extends StdScalarSerializer<T> implements ContextualSerializer
JsonSerializer.None
Modifier and Type | Field and Description |
---|---|
protected DateFormat |
_customFormat
Specific format to use, if not default format: non null value
also indicates that serialization is to be done as JSON String,
not numeric timestamp, unless
_useTimestamp is true. |
protected Boolean |
_useTimestamp
Flag that indicates that serialization must be done as the
Java timestamp, regardless of other settings.
|
_handledType
Modifier | Constructor and Description |
---|---|
protected |
DateTimeSerializerBase(Class<T> type,
Boolean useTimestamp,
DateFormat customFormat) |
Modifier and Type | Method and Description |
---|---|
protected void |
_acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor,
JavaType typeHint,
boolean asNumber) |
protected boolean |
_asTimestamp(SerializerProvider serializers) |
protected abstract long |
_timestamp(T value) |
void |
acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor,
JavaType typeHint)
Default implementation specifies no format.
|
JsonSerializer<?> |
createContextual(SerializerProvider serializers,
BeanProperty property)
Method called to see if a different (or differently configured) serializer
is needed to serialize values of specified property.
|
JsonNode |
getSchema(SerializerProvider serializers,
Type typeHint)
Default implementation simply claims type is "string"; usually
overriden by custom serializers.
|
boolean |
isEmpty(SerializerProvider serializers,
T value)
Method called to check whether given serializable value is
considered "empty" value (for purposes of suppressing serialization
of empty values).
|
boolean |
isEmpty(T value)
Deprecated.
|
abstract void |
serialize(T value,
JsonGenerator gen,
SerializerProvider serializers)
Method that can be called to ask implementation to serialize
values of type this serializer handles.
|
abstract DateTimeSerializerBase<T> |
withFormat(Boolean timestamp,
DateFormat customFormat) |
serializeWithType
createObjectNode, createSchemaNode, createSchemaNode, findAnnotatedContentSerializer, findConvertingContentSerializer, findFormatFeature, findFormatOverrides, findIncludeOverrides, findPropertyFilter, getSchema, handledType, isDefaultSerializer, visitArrayFormat, visitArrayFormat, visitFloatFormat, visitIntFormat, visitIntFormat, visitStringFormat, visitStringFormat, wrapAndThrow, wrapAndThrow
getDelegatee, isUnwrappingSerializer, properties, replaceDelegatee, unwrappingSerializer, usesObjectId, withFilterId
protected final Boolean _useTimestamp
protected final DateFormat _customFormat
_useTimestamp
is true.protected DateTimeSerializerBase(Class<T> type, Boolean useTimestamp, DateFormat customFormat)
public abstract DateTimeSerializerBase<T> withFormat(Boolean timestamp, DateFormat customFormat)
public JsonSerializer<?> createContextual(SerializerProvider serializers, BeanProperty property) throws JsonMappingException
ContextualSerializer
createContextual
in interface ContextualSerializer
serializers
- Serializer provider to use for accessing config, other serializersproperty
- Method or field that represents the property
(and is used to access value to serialize).
Should be available; but there may be cases where caller can not provide it and
null is passed instead (in which case impls usually pass 'this' serializer as is)JsonMappingException
@Deprecated public boolean isEmpty(T value)
JsonSerializer
Default implementation will consider only null values to be empty.
isEmpty
in class JsonSerializer<T>
public boolean isEmpty(SerializerProvider serializers, T value)
JsonSerializer
Default implementation will consider only null values to be empty.
NOTE: replaces JsonSerializer.isEmpty(Object)
, which was deprecated in 2.5
isEmpty
in class JsonSerializer<T>
protected abstract long _timestamp(T value)
public JsonNode getSchema(SerializerProvider serializers, Type typeHint)
StdSerializer
getSchema
in interface SchemaAware
getSchema
in class StdScalarSerializer<T>
serializers
- The serializer provider.typeHint
- A hint about the type.public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException
StdSerializer
acceptJsonFormatVisitor
in interface JsonFormatVisitable
acceptJsonFormatVisitor
in class StdScalarSerializer<T>
typeHint
- Type of element (entity like property) being visitedJsonMappingException
public abstract void serialize(T value, JsonGenerator gen, SerializerProvider serializers) throws IOException
JsonSerializer
serialize
in class StdSerializer<T>
value
- Value to serialize; can not be null.gen
- Generator used to output resulting Json contentserializers
- Provider that can be used to get serializers for
serializing Objects value contains, if any.IOException
protected boolean _asTimestamp(SerializerProvider serializers)
protected void _acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint, boolean asNumber) throws JsonMappingException
JsonMappingException
Copyright © 2008–2016 FasterXML. All rights reserved.