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 timetamp, 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 abstract long |
_timestamp(T value) |
void |
acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor,
JavaType typeHint)
Default implementation specifies no format.
|
JsonSerializer<?> |
createContextual(SerializerProvider prov,
BeanProperty property)
Method called to see if a different (or differently configured) serializer
is needed to serialize values of specified property.
|
JsonNode |
getSchema(SerializerProvider provider,
Type typeHint)
Default implementation simply claims type is "string"; usually
overriden by custom serializers.
|
boolean |
isEmpty(T value)
Method called to check whether given serializable value is
considered "empty" value (for purposes of suppressing serialization
of empty values).
|
abstract void |
serialize(T value,
JsonGenerator jgen,
SerializerProvider provider)
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, findConvertingContentSerializer, getSchema, handledType, isDefaultSerializer, wrapAndThrow, wrapAndThrow
getDelegatee, isUnwrappingSerializer, replaceDelegatee, unwrappingSerializer, usesObjectId
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 prov, BeanProperty property) throws JsonMappingException
ContextualSerializer
createContextual
in interface ContextualSerializer
prov
- 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
public boolean isEmpty(T value)
JsonSerializer
Default implementation will consider only null values to be empty.
isEmpty
in class JsonSerializer<T>
protected abstract long _timestamp(T value)
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
StdSerializer
getSchema
in interface SchemaAware
getSchema
in class StdScalarSerializer<T>
provider
- 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 jgen, SerializerProvider provider) throws IOException, JsonGenerationException
JsonSerializer
serialize
in class StdSerializer<T>
value
- Value to serialize; can not be null.jgen
- Generator used to output resulting Json contentprovider
- Provider that can be used to get serializers for
serializing Objects value contains, if any.IOException
JsonGenerationException
Copyright © 2012-2013 FasterXML. All Rights Reserved.