public abstract class SerializerBase<T> extends JsonSerializer<T> implements SchemaAware
SchemaAware
JsonSerializer.None
Modifier and Type | Field and Description |
---|---|
protected Class<T> |
_handledType |
Modifier | Constructor and Description |
---|---|
protected |
SerializerBase(Class<?> t,
boolean dummy)
Alternate constructor that is (alas!) needed to work
around kinks of generic type handling
|
protected |
SerializerBase(Class<T> t) |
protected |
SerializerBase(JavaType type) |
Modifier and Type | Method and Description |
---|---|
protected ObjectNode |
createObjectNode() |
protected ObjectNode |
createSchemaNode(String type) |
protected ObjectNode |
createSchemaNode(String type,
boolean isOptional) |
JsonNode |
getSchema(SerializerProvider provider,
Type typeHint)
Note: since Jackson 1.9, default implementation claims type is "string"
|
Class<T> |
handledType()
Method for accessing type of Objects this serializer can handle.
|
protected boolean |
isDefaultSerializer(JsonSerializer<?> 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 void |
serialize(T value,
JsonGenerator jgen,
SerializerProvider provider)
Method that can be called to ask implementation to serialize
values of type this serializer handles.
|
void |
wrapAndThrow(SerializerProvider provider,
Throwable t,
Object bean,
int index) |
void |
wrapAndThrow(SerializerProvider provider,
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 of
IOException , or an unchecked exception. |
void |
wrapAndThrow(Throwable t,
Object bean,
int index)
Deprecated.
Use version that takes
SerializerProvider instead. |
void |
wrapAndThrow(Throwable t,
Object bean,
String fieldName)
Deprecated.
Use version that takes
SerializerProvider instead. |
isUnwrappingSerializer, serializeWithType, unwrappingSerializer
protected SerializerBase(JavaType type)
protected SerializerBase(Class<?> t, boolean dummy)
public final Class<T> handledType()
JsonSerializer
Default implementation will return null, which essentially means
same as returning Object.class
would; that is, that
nothing is known about handled type.
handledType
in class JsonSerializer<T>
public abstract void serialize(T value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException
JsonSerializer
serialize
in class JsonSerializer<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
public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException
getSchema
in interface SchemaAware
provider
- The serializer provider.typeHint
- A hint about the type.JsonMappingException
protected ObjectNode createObjectNode()
protected ObjectNode createSchemaNode(String type)
protected ObjectNode createSchemaNode(String type, boolean isOptional)
protected boolean isDefaultSerializer(JsonSerializer<?> serializer)
JacksonStdImpl
annotation on serializer class.public void wrapAndThrow(SerializerProvider provider, Throwable t, Object bean, String fieldName) throws IOException
IOException
, or an unchecked exception.
Rules for wrapping and unwrapping are bit complicated; essentially:
JsonMappingException
are to be passed as is
IOException
public void wrapAndThrow(SerializerProvider provider, Throwable t, Object bean, int index) throws IOException
IOException
@Deprecated public void wrapAndThrow(Throwable t, Object bean, String fieldName) throws IOException
SerializerProvider
instead.IOException
@Deprecated public void wrapAndThrow(Throwable t, Object bean, int index) throws IOException
SerializerProvider
instead.IOException