|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.jackson.map.SerializationConfig
public class SerializationConfig
Object that contains baseline configuration for serialization
process. An instance is owned by ObjectMapper
, which makes
a copy that is passed during serialization process to
SerializerProvider
and SerializerFactory
.
Note: although configuration settings can be changed at any time (for factories and instances), they are not guaranteed to have effect if called after constructing relevant mapper or serializer instance. This because some objects may be configured, constructed and cached first time they are needed.
Nested Class Summary | |
---|---|
static class |
SerializationConfig.Feature
Enumeration that defines togglable features that guide the serialization feature. |
Field Summary | |
---|---|
protected AnnotationIntrospector |
_annotationIntrospector
Introspector used for accessing annotation value based configuration. |
protected ClassIntrospector<? extends BeanDescription> |
_classIntrospector
Introspector used to figure out Bean properties needed for bean serialization and deserialization. |
protected DateFormat |
_dateFormat
Textual date format to use for serialization (if enabled by SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS being set to false). |
protected int |
_featureFlags
|
protected HashMap<ClassKey,Class<?>> |
_mixInAnnotations
Mapping that defines how to apply mix-in annotations: key is the type to received additional annotations, and value is the type that has annotations to "mix in". |
protected boolean |
_mixInAnnotationsShared
Flag used to detect when a copy if mix-in annotations is needed: set when current copy is shared, cleared when a fresh copy is maed |
protected JsonSerialize.Inclusion |
_serializationInclusion
Which Bean/Map properties are to be included in serialization? Default settings is to include all regardless of value; can be changed to only include non-null properties, or properties with non-default values. |
protected Class<?> |
_serializationView
View to use for filtering out properties to serialize. |
protected TypeResolverBuilder<?> |
_typer
Type information handler used for "untyped" values (ones declared to have type Object.class ) |
protected VisibilityChecker<?> |
_visibilityChecker
Object used for determining whether specific property elements (method, constructors, fields) can be auto-detected based on their visibility (access modifiers). |
protected static int |
DEFAULT_FEATURE_FLAGS
Bitfield (set of flags) of all Features that are enabled by default. |
Constructor Summary | |
---|---|
|
SerializationConfig(ClassIntrospector<? extends BeanDescription> intr,
AnnotationIntrospector annIntr,
VisibilityChecker<?> vc)
|
protected |
SerializationConfig(SerializationConfig src,
HashMap<ClassKey,Class<?>> mixins,
TypeResolverBuilder<?> typer,
VisibilityChecker<?> vc)
|
Method Summary | ||
---|---|---|
void |
addMixInAnnotations(Class<?> target,
Class<?> mixinSource)
Method to use for adding mix-in annotations to use for augmenting specified class or interface. |
|
SerializationConfig |
createUnshared(TypeResolverBuilder<?> typer,
VisibilityChecker<?> vc)
Method that is called to create a non-shared copy of the configuration to be used for a serialization operation. |
|
void |
disable(SerializationConfig.Feature f)
Method for disabling specified feature. |
|
void |
enable(SerializationConfig.Feature f)
Method for enabling specified feature. |
|
Class<?> |
findMixInClassFor(Class<?> cls)
Method that will check if there are "mix-in" classes (with mix-in annotations) for given class |
|
void |
fromAnnotations(Class<?> cls)
Method that checks class annotations that the argument Object has, and modifies settings of this configuration object accordingly, similar to how those annotations would affect actual value classes annotated with them, but with global scope. |
|
AnnotationIntrospector |
getAnnotationIntrospector()
Method for getting AnnotationIntrospector configured
to introspect annotation values used for configuration. |
|
DateFormat |
getDateFormat()
|
|
TypeResolverBuilder<?> |
getDefaultTyper(JavaType baseType)
Method called to locate a type info handler for types that do not have one explicitly declared via annotations (or other configuration). |
|
VisibilityChecker<?> |
getDefaultVisibilityChecker()
Accessor for object used for determining whether specific property elements (method, constructors, fields) can be auto-detected based on their visibility (access modifiers). |
|
JsonSerialize.Inclusion |
getSerializationInclusion()
|
|
Class<?> |
getSerializationView()
Method for checking which serialization view is being used, if any; null if none. |
|
|
introspect(Class<?> cls)
Method that will introspect full bean properties for the purpose of building a bean serializer |
|
|
introspectClassAnnotations(Class<?> cls)
Accessor for getting bean description that only contains class annotations: useful if no getter/setter/creator information is needed. |
|
|
introspectDirectClassAnnotations(Class<?> cls)
Accessor for getting bean description that only contains immediate class annotations: ones from the class, and its direct mix-in, if any, but not from super types. |
|
boolean |
isEnabled(SerializationConfig.Feature f)
Method for checking whether given feature is enabled or not |
|
void |
set(SerializationConfig.Feature f,
boolean state)
Method for enabling or disabling specified feature. |
|
void |
setAnnotationIntrospector(AnnotationIntrospector ai)
|
|
void |
setDateFormat(DateFormat df)
Method that will set the textual serialization to use for serializing Dates (and Calendars); or if null passed, simply disable textual serialization and use timestamp. |
|
void |
setIntrospector(ClassIntrospector<? extends BeanDescription> i)
|
|
void |
setMixInAnnotations(Map<Class<?>,Class<?>> sourceMixins)
Method to use for defining mix-in annotations to use for augmenting annotations that serializable classes have. |
|
void |
setSerializationInclusion(JsonSerialize.Inclusion props)
Method that will define global setting of which bean/map properties are to be included in serialization. |
|
void |
setSerializationView(Class<?> view)
Method for checking which serialization view is being used, if any; null if none. |
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final int DEFAULT_FEATURE_FLAGS
protected ClassIntrospector<? extends BeanDescription> _classIntrospector
protected AnnotationIntrospector _annotationIntrospector
protected int _featureFlags
protected DateFormat _dateFormat
SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS
being set to false).
Defaults to a ISO-8601 compliant format used by
StdDateFormat
.
Note that format object is not to be used as is by caller: since date format objects are not thread-safe, caller has to create a clone first.
protected JsonSerialize.Inclusion _serializationInclusion
Defaults to null for backwards compatibility; if left as null,
will check
deprecated SerializationConfig.Feature.WRITE_NULL_PROPERTIES
to choose between JsonSerialize.Inclusion.ALWAYS
and JsonSerialize.Inclusion.NON_NULL
.
protected Class<?> _serializationView
Object.class
is defined), meaning that all properties are to be included.
protected HashMap<ClassKey,Class<?>> _mixInAnnotations
Annotations associated with the value classes will be used to override annotations of the key class, associated with the same field or method. They can be further masked by sub-classes: you can think of it as injecting annotations between the target class and its sub-classes (or interfaces)
protected boolean _mixInAnnotationsShared
protected final TypeResolverBuilder<?> _typer
Object.class
)
protected VisibilityChecker<?> _visibilityChecker
JsonAutoDetect
annotation)
Constructor Detail |
---|
public SerializationConfig(ClassIntrospector<? extends BeanDescription> intr, AnnotationIntrospector annIntr, VisibilityChecker<?> vc)
protected SerializationConfig(SerializationConfig src, HashMap<ClassKey,Class<?>> mixins, TypeResolverBuilder<?> typer, VisibilityChecker<?> vc)
Method Detail |
---|
public void fromAnnotations(Class<?> cls)
Serialization annotations that are known to have effect are:
fromAnnotations
in interface MapperConfig<SerializationConfig>
cls
- Class of which class annotations to use
for changing configuration settingspublic SerializationConfig createUnshared(TypeResolverBuilder<?> typer, VisibilityChecker<?> vc)
createUnshared
in interface MapperConfig<SerializationConfig>
public void setIntrospector(ClassIntrospector<? extends BeanDescription> i)
setIntrospector
in interface MapperConfig<SerializationConfig>
public AnnotationIntrospector getAnnotationIntrospector()
AnnotationIntrospector
configured
to introspect annotation values used for configuration.
getAnnotationIntrospector
in interface MapperConfig<SerializationConfig>
public void setAnnotationIntrospector(AnnotationIntrospector ai)
setAnnotationIntrospector
in interface MapperConfig<SerializationConfig>
public void setMixInAnnotations(Map<Class<?>,Class<?>> sourceMixins)
Note: a copy of argument Map is created; the original Map is not modified or retained by this config object.
setMixInAnnotations
in interface MapperConfig<SerializationConfig>
public void addMixInAnnotations(Class<?> target, Class<?> mixinSource)
MapperConfig
mixinSource
are taken to override annotations
that target
(or its supertypes) has.
addMixInAnnotations
in interface MapperConfig<SerializationConfig>
target
- Class (or interface) whose annotations to effectively overridemixinSource
- Class (or interface) whose annotations are to
be "added" to target's annotations, overriding as necessarypublic Class<?> findMixInClassFor(Class<?> cls)
MapperConfig
findMixInClassFor
in interface ClassIntrospector.MixInResolver
findMixInClassFor
in interface MapperConfig<SerializationConfig>
public final boolean isEnabled(SerializationConfig.Feature f)
public DateFormat getDateFormat()
public Class<?> getSerializationView()
public JsonSerialize.Inclusion getSerializationInclusion()
public <T extends BeanDescription> T introspect(Class<?> cls)
public <T extends BeanDescription> T introspectClassAnnotations(Class<?> cls)
public <T extends BeanDescription> T introspectDirectClassAnnotations(Class<?> cls)
public TypeResolverBuilder<?> getDefaultTyper(JavaType baseType)
MapperConfig
getDefaultTyper
in interface MapperConfig<SerializationConfig>
public VisibilityChecker<?> getDefaultVisibilityChecker()
MapperConfig
JsonAutoDetect
annotation)
getDefaultVisibilityChecker
in interface MapperConfig<SerializationConfig>
public void enable(SerializationConfig.Feature f)
public void disable(SerializationConfig.Feature f)
public void set(SerializationConfig.Feature f, boolean state)
public void setSerializationInclusion(JsonSerialize.Inclusion props)
public void setDateFormat(DateFormat df)
SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS
: enable, if argument
is null; disable if non-null.
public void setSerializationView(Class<?> view)
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |