Class SerializerBase<T>
java.lang.Object
org.codehaus.jackson.map.JsonSerializer<T>
org.codehaus.jackson.map.ser.std.SerializerBase<T>
- All Implemented Interfaces:
SchemaAware
- Direct Known Subclasses:
BeanSerializerBase, ContainerSerializerBase, CoreXMLSerializers.XMLGregorianCalendarSerializer, DataHandlerJsonSerializer, DomElementJsonSerializer, DOMSerializer, FailingSerializer, JodaSerializers.JodaSerializer, JsonValueSerializer, NullSerializer, RawSerializer, ScalarSerializerBase, ScalarSerializerBase, SerializableWithTypeSerializer, SerializerBase, StaticListSerializerBase, StdArraySerializers.ByteArraySerializer, StdArraySerializers.CharArraySerializer, StdJdkSerializers.AtomicReferenceSerializer, StdKeySerializer, StdKeySerializers.CalendarKeySerializer, StdKeySerializers.DateKeySerializer, StdKeySerializers.StringKeySerializer, TokenBufferSerializer, ToStringSerializer, UnknownSerializer, XmlAdapterJsonSerializer
Base class used by all standard serializers. Provides some convenience
methods for implementing
SchemaAware- Since:
- 1.9 (renamed from 'org.codehaus.jackson.map.ser.SerializerBase')
-
Nested Class Summary
Nested classes/interfaces inherited from class JsonSerializer
JsonSerializer.None -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSerializerBase(Class<?> t, boolean dummy) Alternate constructor that is (alas!) needed to work around kinks of generic type handlingprotectedSerializerBase(Class<T> t) protectedSerializerBase(JavaType type) -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectNodeprotected ObjectNodecreateSchemaNode(String type) protected ObjectNodecreateSchemaNode(String type, boolean isOptional) getSchema(SerializerProvider provider, Type typeHint) Note: since Jackson 1.9, default implementation claims type is "string"Method for accessing type of Objects this serializer can handle.protected booleanisDefaultSerializer(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 voidserialize(T value, JsonGenerator jgen, SerializerProvider provider) Method that can be called to ask implementation to serialize values of type this serializer handles.voidwrapAndThrow(Throwable t, Object bean, int index) Deprecated.voidwrapAndThrow(Throwable t, Object bean, String fieldName) Deprecated.Use version that takesSerializerProviderinstead.voidwrapAndThrow(SerializerProvider provider, Throwable t, Object bean, int index) voidwrapAndThrow(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 ofIOException, or an unchecked exception.Methods inherited from class JsonSerializer
isUnwrappingSerializer, serializeWithType, unwrappingSerializer
-
Field Details
-
_handledType
-
-
Constructor Details
-
SerializerBase
-
SerializerBase
- Since:
- 1.7
-
SerializerBase
Alternate constructor that is (alas!) needed to work around kinks of generic type handling
-
-
Method Details
-
handledType
Description copied from class:JsonSerializerMethod for accessing type of Objects this serializer can handle. Note that this information is not guaranteed to be exact -- it may be a more generic (super-type) -- but it should not be incorrect (return a non-related type).Default implementation will return null, which essentially means same as returning
Object.classwould; that is, that nothing is known about handled type.- Overrides:
handledTypein classJsonSerializer<T>
-
serialize
public abstract void serialize(T value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException Description copied from class:JsonSerializerMethod that can be called to ask implementation to serialize values of type this serializer handles.- Specified by:
serializein classJsonSerializer<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:
IOExceptionJsonGenerationException
-
getSchema
Note: since Jackson 1.9, default implementation claims type is "string"- Specified by:
getSchemain interfaceSchemaAware- Parameters:
provider- The serializer provider.typeHint- A hint about the type.- Returns:
- Json-schema for this serializer.
- Throws:
JsonMappingException
-
createObjectNode
-
createSchemaNode
-
createSchemaNode
-
isDefaultSerializer
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. Determination is done usingJacksonStdImplannotation on serializer class.- Since:
- 1.7
-
wrapAndThrow
public void wrapAndThrow(SerializerProvider provider, 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 ofIOException, 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
JsonMappingExceptionare to be passed as is
- Throws:
IOException
-
wrapAndThrow
public void wrapAndThrow(SerializerProvider provider, Throwable t, Object bean, int index) throws IOException - Throws:
IOException
-
wrapAndThrow
Deprecated.Use version that takesSerializerProviderinstead.- Throws:
IOException
-
wrapAndThrow
Deprecated.Use version that takesSerializerProviderinstead.- Throws:
IOException
-
SerializerProviderinstead.