org.codehaus.jackson.map.ser
Class SerializerBase<T>
java.lang.Object
org.codehaus.jackson.map.JsonSerializer<T>
org.codehaus.jackson.map.ser.SerializerBase<T>
- All Implemented Interfaces:
- SchemaAware
- Direct Known Subclasses:
- ArraySerializers.BooleanArraySerializer, ArraySerializers.ByteArraySerializer, ArraySerializers.CharArraySerializer, ArraySerializers.DoubleArraySerializer, ArraySerializers.FloatArraySerializer, ArraySerializers.IntArraySerializer, ArraySerializers.LongArraySerializer, ArraySerializers.ObjectArraySerializer, ArraySerializers.ShortArraySerializer, ArraySerializers.StringArraySerializer, BasicSerializerFactory.BooleanSerializer, BasicSerializerFactory.CalendarSerializer, BasicSerializerFactory.ClassSerializer, BasicSerializerFactory.DoubleSerializer, BasicSerializerFactory.FloatSerializer, BasicSerializerFactory.IntegerSerializer, BasicSerializerFactory.IntLikeSerializer, BasicSerializerFactory.LongSerializer, BasicSerializerFactory.NullSerializer, BasicSerializerFactory.NumberSerializer, BasicSerializerFactory.SerializableSerializer, BasicSerializerFactory.SqlDateSerializer, BasicSerializerFactory.SqlTimeSerializer, BasicSerializerFactory.StringSerializer, BasicSerializerFactory.UtilDateSerializer, BeanSerializer, ContainerSerializers.CollectionSerializer, ContainerSerializers.EnumMapSerializer, ContainerSerializers.EnumSetSerializer, ContainerSerializers.IndexedListSerializer, ContainerSerializers.IterableSerializer, ContainerSerializers.IteratorSerializer, DataHandlerJsonSerializer, DOMSerializer, EnumSerializer, JdkSerializers.FileSerializer, JodaSerializers.DateTimeSerializer, MapSerializer, StdKeySerializer, ToStringSerializer
public abstract class SerializerBase<T>
- extends JsonSerializer<T>
- implements SchemaAware
Base class used by all standard serializers. Provides some convenience
methods for implementing SchemaAware
Method Summary |
protected ObjectNode |
createObjectNode()
|
protected ObjectNode |
createSchemaNode(String type)
|
protected ObjectNode |
createSchemaNode(String type,
boolean isOptional)
|
abstract JsonNode |
getSchema(SerializerProvider provider,
Type typeHint)
Get the representation of the schema to which this serializer will conform. |
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(Throwable t,
Object bean,
int index)
|
void |
wrapAndThrow(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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SerializerBase
public SerializerBase()
serialize
public abstract void serialize(T value,
JsonGenerator jgen,
SerializerProvider provider)
throws IOException,
JsonGenerationException
- Description copied from class:
JsonSerializer
- Method that can be called to ask implementation to serialize
values of type this serializer handles.
- Specified by:
serialize
in class JsonSerializer<T>
- Parameters:
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.
- Throws:
IOException
JsonGenerationException
getSchema
public abstract JsonNode getSchema(SerializerProvider provider,
Type typeHint)
throws JsonMappingException
- Description copied from interface:
SchemaAware
- Get the representation of the schema to which this serializer will conform.
- Specified by:
getSchema
in interface SchemaAware
- Parameters:
provider
- The serializer provider.typeHint
- A hint about the type.
- Returns:
- Json-schema for this serializer.
- Throws:
JsonMappingException
createObjectNode
protected ObjectNode createObjectNode()
createSchemaNode
protected ObjectNode createSchemaNode(String type)
createSchemaNode
protected ObjectNode createSchemaNode(String type,
boolean isOptional)
wrapAndThrow
public void wrapAndThrow(Throwable t,
Object bean,
String fieldName)
throws IOException
- 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.
Rules for wrapping and unwrapping are bit complicated; essentially:
- Errors are to be passed as is (if uncovered via unwrapping)
- "Plain" IOExceptions (ones that are not of type
JsonMappingException
are to be passed as is
- Throws:
IOException
wrapAndThrow
public void wrapAndThrow(Throwable t,
Object bean,
int index)
throws IOException
- Throws:
IOException