Top Description Fields Constructors Methods
com.fasterxml.jackson.module.jaxb

public Class JaxbAnnotationIntrospector

extends AnnotationIntrospector
implements XmlExtensions, Versioned
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.core.Versioned, com.fasterxml.jackson.databind.AnnotationIntrospector.XmlExtensions
Imports
java.lang.annotation.Annotation, java.lang.reflect.*, java.util.*, javax.xml.bind.*, javax.xml.bind.annotation.*, javax.xml.bind.annotation.adapters.*, com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility, com.fasterxml.jackson.annotation.*, com.fasterxml.jackson.core.*, com.fasterxml.jackson.databind.*, com.fasterxml.jackson.databind.cfg.MapperConfig, com.fasterxml.jackson.databind.introspect.*, com.fasterxml.jackson.databind.jsontype.NamedType, .TypeResolverBuilder, com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder, com.fasterxml.jackson.databind.type.TypeFactory, com.fasterxml.jackson.databind.util.ClassUtil, .Converter, com.fasterxml.jackson.module.jaxb.deser.DataHandlerJsonDeserializer, com.fasterxml.jackson.module.jaxb.ser.DataHandlerJsonSerializer

Annotation introspector that leverages JAXB annotations where applicable to JSON mapping. As of Jackson 2.0, most JAXB annotations are supported at least to some degree. Ones that are NOT yet supported are: Note also the following limitations:
Authors
Ryan Heaton, Tatu Saloranta

Field Summary

Modifier and TypeField and Description
protected final JsonDeserializer<?>
protected final JsonSerializer<?>
protected final boolean
protected final String
protected JsonInclude.Include
_nonNillableInclusion

Inclusion value to return for properties annotated with XmlElement and XmlElementWrapper, in case nillable property is left as false.

protected final TypeFactory
protected String
_xmlValueName

When using XmlValue annotation, a placeholder name is assigned to property (unless overridden by explicit name); this configuration value specified what that name is.

protected static final boolean
protected static final String
protected static final JsonFormat.Value
protected static final JsonFormat.Value
protected static final String
private static final long

Constructor Summary

AccessConstructor and Description
public
JaxbAnnotationIntrospector()
Deprecated Since 2.1, use constructor that takes TypeFactory.

public
public
public
JaxbAnnotationIntrospector(TypeFactory
Type factory used for resolving type information
typeFactory
,
boolean
Whether XmlIDREF annotation should be processed JAXB style (meaning that references are always serialized using id), or not (first reference as full POJO, others as ids)
ignoreXmlIDREF
)

Method Summary

Modifier and TypeMethod and Description
private static PropertyName
_combineNames(String localName, String namespace, String defaultName)

protected Converter<Object, Object>
_converter(XmlAdapter<?, ?> adapter, boolean forSerialization)

protected String
protected Class<?>
private final Boolean
protected XmlAdapter<?, ?>
_findContentAdapter(Annotated ann, boolean forSerialization)

protected JavaType
protected JavaType
protected Class<?>
protected String
protected String
protected String
protected Class<?>
protected Class<?>
pack-priv JsonInclude.Include
protected String
_stdManglePropertyName(final String basename, final int offset)

protected TypeResolverBuilder<?>
private boolean
adapterTypeMatches(XmlAdapter<?, ?> adapter, Class<?> targetType)

private final XmlAdapter<Object, Object>
checkAdapter(XmlJavaTypeAdapter adapterInfo, Class<?> typeNeeded, boolean forSerialization)

protected XmlAccessType
findAccessType(Annotated ac)

Method for locating JAXB XmlAccessType annotation value for given annotated entity, if it has one, or inherits one from its ancestors (in JAXB sense, package etc).

private XmlAdapter<Object, Object>

Returns:

The adapter, or null if none.
findAdapter
(Annotated
The annotated element.
am
,
boolean
If true, adapter for serialization; if false, for deserialization
forSerialization
,
Class<?> type)

Finds the XmlAdapter for the specified annotation.

private Class<?>
private XmlAdapter<Object, Object>
findAdapterForClass(AnnotatedClass ac, boolean forSerialization)

private <A extends Annotation> A

Returns:

The annotation, or null if not found.
findAnnotation
(Class<A>
the annotation class.
annotationClass
,
Annotated
The annotated element.
annotated
,
boolean
Whether the annotation can be found on the package of the annotated element.
includePackage
,
boolean
Whether the annotation can be found on the class of the annotated element.
includeClass
,
boolean
Whether the annotation can be found on any superclasses of the class of the annotated element.
includeSuperclasses
)

Finds an annotation associated with given annotatable thing; or if not found, a default annotation it may have (from super class, package and so on)

public VisibilityChecker<?>
findAutoDetectVisibility(AnnotatedClass
Annotated class to introspect
ac
,
VisibilityChecker<?>
Default visibility settings in effect before any override
checker
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findAutoDetectVisibility.

Method for checking if annotations indicate changes to minimum visibility levels needed for auto-detecting property elements (fields, methods, constructors).

public Object
findContentDeserializer(Annotated a)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findContentDeserializer.

Method for getting a deserializer definition for content (values) of associated Collection, array or Map property.

public Object
findContentSerializer(Annotated a)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findContentSerializer.

Method for getting a serializer definition for content (values) of associated Collection, array or Map property.

public Object
findDeserializationContentConverter(AnnotatedMember
Annotated property (field, method) to check.
a
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findDeserializationContentConverter.

Method for finding Converter that annotated property has indicated needs to be used for values of container type (this also means that method should only be called for properties of container types, List/Map/array properties).

public Object
findDeserializationConverter(Annotated
Annotated property (field, method) or class to check for annotations
a
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findDeserializationConverter.

Method for finding Converter that annotated entity (property or class) has indicated to be used as part of deserialization.

public Object
findDeserializer(Annotated am)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findDeserializer.

Method for getting a deserializer definition on specified method or field.

public String[]
findEnumValues(Class<?>
Type of Enumeration
enumType
,
Enum<?>[]
Values of enumeration
enumValues
,
String[]
Matching declared names of enumeration values (with indexes matching enumValues entries)
names
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findEnumValues.

Deprecated

Method for efficiently figuring out which if given set of Enum values have explicitly defined name.

public String[]
findEnumValues(MapperConfig<?>
the mapper configuration to use
config
,
AnnotatedClass
the annotated class for which to find the explicit names
annotatedClass
,
Enum<?>[]
the set of Enum values to find the explicit names for
enumValues
,
String[]
the matching declared names of enumeration values (with indexes matching enumValues entries)
names
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findEnumValues.

Finds the explicitly defined name of the given set of Enum values, if any.

public JsonFormat.Value
findFormat(Annotated m)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findFormat.

Method for finding format annotations for property or class.

public String
findImplicitPropertyName(AnnotatedMember m)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findImplicitPropertyName.

Method for finding implicit name for a property that given annotated member (field, method, creator parameter) may represent.

private PropertyName
findJaxbPropertyName(Annotated ae, Class<?> aeType, String defaultName)

public Object
findKeyDeserializer(Annotated am)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findKeyDeserializer.

Method for getting a deserializer definition for keys of associated Map property.

public PropertyName
findNameForDeserialization(Annotated
Annotated entity to check
a
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findNameForDeserialization.

Method for checking whether given property accessors (method, field) has an annotation that suggests property name to use for deserialization (reading JSON into POJOs).

public PropertyName
findNameForSerialization(Annotated
Property accessor to check
a
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findNameForSerialization.

Method for checking whether given property accessors (method, field) has an annotation that suggests property name to use for serialization.

public String
findNamespace(MapperConfig<?>
Configuration settings in effect
config
,
Annotated
Annotated entity to introspect
ann
)

Implements com.fasterxml.jackson.databind.AnnotationIntrospector.XmlExtensions.findNamespace.

Method that can be called to figure out generic namespace property for an annotated object.

public ObjectIdInfo
findObjectIdInfo(Annotated
Annotated entity to introspect
ann
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findObjectIdInfo.

Method for checking whether given annotated thing (type, or accessor) indicates that values referenced (values of type of annotated class, or values referenced by annotated property; latter having precedence) should include Object Identifier, and if so, specify details of Object Identity used.

public ObjectIdInfo
findObjectReferenceInfo(Annotated
Annotated entity to introspect
ann
,
ObjectIdInfo
(optional) Base Object Id information, if any; null if none
base
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findObjectReferenceInfo.

Method for figuring out additional properties of an Object Identity reference

public TypeResolverBuilder<?>
findPropertyContentTypeResolver(MapperConfig<?>
Configuration settings in effect (for serialization or deserialization)
config
,
AnnotatedMember
Annotated member (field or method) to check for annotations
am
,
JavaType
Type of property for which resolver is to be found (must be a container type)
containerType
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyContentTypeResolver.

Method for checking if given structured property entity (field or method that has nominal value of Map, Collection or array type) has annotations that indicate that specific type resolver is to be used for handling type information of contained values.

public JsonInclude.Value
findPropertyInclusion(Annotated a)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyInclusion.

Method for checking inclusion criteria for a type (Class) or property (yes, method name is bit unfortunate -- not just for properties!).

public TypeResolverBuilder<?>
findPropertyTypeResolver(MapperConfig<?>
Configuration settings in effect (for serialization or deserialization)
config
,
AnnotatedMember
Annotated member (field or method) to check for annotations
am
,
JavaType
Base java type of property for which resolver is to be found
baseType
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyTypeResolver.

Method for checking if given property entity (field or method) has annotations that indicate that specific type resolver is to be used for handling instances.

private XmlRootElement
public PropertyName
findRootName(AnnotatedClass
Annotated class to introspect
ac
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findRootName.

Method for locating name used as "root name" (for use by some serializers when outputting root-level object -- mostly for XML compatibility purposes) for given class, if one is defined.

public Object
findSerializationContentConverter(AnnotatedMember
Annotated property (field, method) to check.
a
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findSerializationContentConverter.

Method for finding Converter that annotated property has indicated needs to be used for values of container type (this also means that method should only be called for properties of container types, List/Map/array properties).

public Object
findSerializationConverter(Annotated
Annotated property (field, method) or class to check for annotations
a
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findSerializationConverter.

Method for finding Converter that annotated entity (property or class) has indicated to be used as part of serialization.

public String[]
findSerializationPropertyOrder(AnnotatedClass ac)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findSerializationPropertyOrder.

Method for accessing defined property serialization order (which may be partial).

public Boolean
findSerializationSortAlphabetically(Annotated ann)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findSerializationSortAlphabetically.

Method for checking whether an annotation indicates that serialized properties for which no explicit is defined should be alphabetically (lexicograpically) ordered

public JsonSerializer<?>
findSerializer(Annotated am)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findSerializer.

Method for getting a serializer definition on specified method or field.

public List<NamedType>
findSubtypes(Annotated
Annotated entity (class, field/method) to check for annotations
a
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findSubtypes.

Method for locating annotation-specified subtypes related to annotated entity (class, method, field).

public String
findTypeName(AnnotatedClass
Class to check for type name annotations
ac
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findTypeName.

Method for checking if specified type has explicit name.

public TypeResolverBuilder<?>
findTypeResolver(MapperConfig<?>
Configuration settings in effect (for serialization or deserialization)
config
,
AnnotatedClass
Annotated class to check for annotations
ac
,
JavaType
Base java type of value for which resolver is to be found
baseType
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findTypeResolver.

Method for checking if given class has annotations that indicate that specific type resolver is to be used for handling instances.

public PropertyName
findWrapperName(Annotated ann)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findWrapperName.

Method used to check if specified property has annotation that indicates that it should be wrapped in an element; and if so, name to use.

public String
getNameUsedForXmlValue()

Accessor for getting currently configured placeholder named used for property annotated with XmlValue.

public JsonInclude.Include
protected final TypeFactory
public boolean
public boolean
hasIgnoreMarker(AnnotatedMember m)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.hasIgnoreMarker.

Method called to check whether given property is marked to be ignored.

public Boolean
hasRequiredMarker(AnnotatedMember m)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.hasRequiredMarker.

Method that can be called to check whether this member has an annotation that suggests whether value for matching property is required or not.

private boolean
isContainerType(Class<?> raw)

Helper method used to distinguish structured types (arrays, Lists, Maps), which with JAXB use different rules for defining content types.

private boolean

Returns:

Whether the type is assignable to class javax.activation.DataHandler
isDataHandler
(Class<?>
The type.
type
)

Determines whether the type is assignable to class javax.activation.DataHandler without requiring that class to be on the classpath.

public Boolean
isIgnorableType(AnnotatedClass
Annotated class to introspect
ac
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.isIgnorableType.

Method for checking whether properties that have specified type (class, not generics aware) should be completely ignored for serialization and deserialization purposes.

protected boolean

Returns:

Whether the annotation is in the JAXB package.
isJAXBAnnotation
(Annotation
The annotation.
ann
)

An annotation is handled if it's in the same package as @XmlElement, including subpackages.

public Boolean
isOutputAsAttribute(MapperConfig<?>
Configuration settings in effect
config
,
Annotated
Annotated entity to introspect
ann
)

Implements com.fasterxml.jackson.databind.AnnotationIntrospector.XmlExtensions.isOutputAsAttribute.

Here we assume fairly simple logic; if there is XmlAttribute to be found, we consider it an attribute; if XmlElement, not-an-attribute; and otherwise we will consider there to be no information.

public Boolean
isOutputAsCData(MapperConfig<?>
Configuration settings in effect
config
,
Annotated
Annotated entity to introspect
ann
)

Implements com.fasterxml.jackson.databind.AnnotationIntrospector.XmlExtensions.isOutputAsCData.

Method used to check whether given annotated element (field, method, constructor parameter) has indicator that suggests it should be wrapped in a CDATA tag.

public Boolean
isOutputAsText(MapperConfig<?>
Configuration settings in effect
config
,
Annotated
Annotated entity to introspect
ann
)

Implements com.fasterxml.jackson.databind.AnnotationIntrospector.XmlExtensions.isOutputAsText.

Method used to check whether given annotated element (field, method, constructor parameter) has indicator that suggests it should be serialized as text, without element wrapper.

private boolean

Returns:

Whether the field is invisible.
isVisible
(AnnotatedField
The field.
f
)

Whether the specified field is invisible, per the JAXB visibility rules.

private boolean
public JavaType
refineDeserializationType(final MapperConfig<?> config, final Annotated a, final JavaType baseType)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.refineDeserializationType.

Method called to find out possible type refinements to use for deserialization.

public JavaType
refineSerializationType(final MapperConfig<?> config, final Annotated a, final JavaType baseType)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.refineSerializationType.

Method called to find out possible type refinements to use for deserialization, including not just value itself but key and/or content type, if type has those.

public void
setNameUsedForXmlValue(String name)

Configuration method that can be used to change default name ("value") used for properties annotated with XmlValue; note that setting it to null will actually avoid name override, and name will instead be derived from underlying method name using standard bean name introspection.

public JaxbAnnotationIntrospector
setNonNillableInclusion(JsonInclude.Include incl)

Method to call to change inclusion criteria used for property annotated with XmlElement or XmlElementWrapper, with nillable set as false.

public Version
version()

Implements abstract com.fasterxml.jackson.databind.AnnotationIntrospector.version.

Implements com.fasterxml.jackson.core.Versioned.version.

Method that will return version information stored in and read from jar that contains this class.

Inherited from com.fasterxml.jackson.databind.AnnotationIntrospector:
_findAnnotation_hasAnnotation_hasOneOfallIntrospectorsallIntrospectorsfindAndAddVirtualPropertiesfindClassDescriptionfindCreatorAnnotationfindCreatorBindingfindDefaultEnumValuefindDefaultEnumValuefindEnumAliasesfindEnumAliasesfindEnumNamingStrategyfindEnumValuefindFilterIdfindIgnoreUnknownPropertiesfindInjectableValuefindInjectableValueIdfindKeySerializerfindMergeInfofindNamingStrategyfindNullSerializerfindPOJOBuilderfindPOJOBuilderConfigfindPolymorphicTypeInfofindPropertiesToIgnorefindPropertyAccessfindPropertyAliasesfindPropertyDefaultValuefindPropertyDescriptionfindPropertyIgnoralByNamefindPropertyIgnoralsfindPropertyInclusionByNamefindPropertyIndexfindReferenceTypefindRenameByFieldfindSerializationTypingfindSetterInfofindUnwrappingNameTransformerfindValueInstantiatorfindViewshasAnyGetterhasAnyGetterAnnotationhasAnySetterhasAnySetterAnnotationhasAsKeyhasAsValuehasCreatorAnnotationisAnnotationBundleisTypeIdnopInstancepairresolveSetterConflict