Top Description Fields Constructors Methods
com.fasterxml.jackson.dataformat.xml

public Class JacksonXmlAnnotationIntrospector

extends JacksonAnnotationIntrospector
implements XmlAnnotationIntrospector
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.dataformat.xml.XmlAnnotationIntrospector, com.fasterxml.jackson.databind.AnnotationIntrospector.XmlExtensions
Imports
java.lang.annotation.Annotation, java.util.List, com.fasterxml.jackson.annotation.JsonProperty, .JsonTypeInfo, com.fasterxml.jackson.databind.JavaType, .PropertyName, com.fasterxml.jackson.databind.cfg.MapperConfig, com.fasterxml.jackson.databind.introspect.*, com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder, com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder, com.fasterxml.jackson.databind.ser.BeanPropertyWriter, com.fasterxml.jackson.dataformat.xml.annotation.*

Extension of JacksonAnnotationIntrospector that is needed to support additional xml-specific annotation that Jackson provides. Note, however, that there is no JAXB annotation support here; that is provided with separate introspector (see https://github.com/FasterXML/jackson-modules-base/tree/master/jaxb, class com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector).

Field Summary

Modifier and TypeField and Description
protected boolean
private static final Class<? extends Annotation>[]
public static final boolean
DEFAULT_USE_WRAPPER

For backwards compatibility with 2.0, the default behavior is to assume use of List wrapper if no annotations are used.

private static final long
Inherited from com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector:
_annotationsInside_cfgConstructorPropertiesImpliesCreator

Constructor Summary

AccessConstructor and Description
public
public
JacksonXmlAnnotationIntrospector(boolean defaultUseWrapper)

Method Summary

Modifier and TypeMethod and Description
protected StdTypeResolverBuilder
_constructStdTypeResolverBuilder()

Overrides com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector._constructStdTypeResolverBuilder.

We will override this method so that we can return instance that cleans up type id property name to be a valid xml name.

protected TypeResolverBuilder<?>
protected PropertyName
public void
findAndAddVirtualProperties(MapperConfig<?> config, AnnotatedClass ac, List<BeanPropertyWriter> properties)

Overrides com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector.findAndAddVirtualProperties.

Due to issue [dataformat-xml#578] need to suppress calls to this method to avoid duplicate virtual properties from being added.

public PropertyName
findNameForDeserialization(Annotated
Annotated entity to check
a
)

Overrides com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector.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.introspect.JacksonAnnotationIntrospector.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 PropertyName
findRootName(AnnotatedClass
Annotated class to introspect
ac
)

Overrides com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector.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 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 Boolean
isOutputAsAttribute(MapperConfig<?>
Configuration settings in effect
config
,
Annotated
Annotated entity to introspect
ann
)

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

Method used to check whether given annotated element (field, method, constructor parameter) has indicator that suggests it be output as an XML attribute or not (if not, then as element)

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.

public void
Inherited from com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector:
_classIfExplicit_classIfExplicit_constructNoTypeResolverBuilder_constructVirtualProperty_constructVirtualProperty_findConstructorName_findTypeResolver_isIgnorable_propertyNamefindAutoDetectVisibilityfindClassDescriptionfindContentDeserializerfindContentSerializerfindCreatorAnnotationfindCreatorBindingfindDefaultEnumValuefindDefaultEnumValuefindDeserializationContentConverterfindDeserializationConverterfindDeserializerfindEnumAliasesfindEnumAliasesfindEnumNamingStrategyfindEnumValuefindEnumValuesfindEnumValuesfindFilterIdfindFormatfindImplicitPropertyNamefindInjectableValuefindInjectableValueIdfindKeyDeserializerfindKeySerializerfindMergeInfofindNamingStrategyfindNullSerializerfindObjectIdInfofindObjectReferenceInfofindPOJOBuilderfindPOJOBuilderConfigfindPolymorphicTypeInfofindPropertyAccessfindPropertyAliasesfindPropertyContentTypeResolverfindPropertyDefaultValuefindPropertyDescriptionfindPropertyIgnoralByNamefindPropertyIgnoralsfindPropertyInclusionfindPropertyInclusionByNamefindPropertyIndexfindPropertyTypeResolverfindReferenceTypefindRenameByFieldfindSerializationContentConverterfindSerializationConverterfindSerializationPropertyOrderfindSerializationSortAlphabeticallyfindSerializationTypingfindSerializerfindSetterInfofindSubtypesfindTypeNamefindTypeResolverfindUnwrappingNameTransformerfindValueInstantiatorfindViewshasAnyGetterhasAnyGetterAnnotationhasAnySetterhasAnySetterAnnotationhasAsKeyhasAsValuehasAsValueAnnotationhasCreatorAnnotationhasIgnoreMarkerhasRequiredMarkerisAnnotationBundleisIgnorableTypeisTypeIdreadResolverefineDeserializationTyperefineSerializationTyperesolveSetterConflictsetConstructorPropertiesImpliesCreatorversion

Field Detail

_cfgDefaultUseWrapperback to summary
protected boolean _cfgDefaultUseWrapper
ANNOTATIONS_TO_INFER_XML_PROPback to summary
private static final Class<? extends Annotation>[] ANNOTATIONS_TO_INFER_XML_PROP
Annotations
@SuppressWarnings:unchecked
DEFAULT_USE_WRAPPERback to summary
public static final boolean DEFAULT_USE_WRAPPER

For backwards compatibility with 2.0, the default behavior is to assume use of List wrapper if no annotations are used.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector.serialVersionUID.

Constructor Detail

JacksonXmlAnnotationIntrospectorback to summary
public JacksonXmlAnnotationIntrospector()
JacksonXmlAnnotationIntrospectorback to summary
public JacksonXmlAnnotationIntrospector(boolean defaultUseWrapper)

Method Detail

_constructStdTypeResolverBuilderback to summary
protected StdTypeResolverBuilder _constructStdTypeResolverBuilder()

Overrides com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector._constructStdTypeResolverBuilder.

We will override this method so that we can return instance that cleans up type id property name to be a valid xml name.

Annotations
@Override
_constructStdTypeResolverBuilderback to summary
protected TypeResolverBuilder<?> _constructStdTypeResolverBuilder(MapperConfig<?> config, JsonTypeInfo.Value typeInfo, JavaType baseType)

Overrides com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector._constructStdTypeResolverBuilder.

Doc from com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector._constructStdTypeResolverBuilder.

Helper method for constructing standard TypeResolverBuilder implementation.

Annotations
@Override
_findXmlNameback to summary
protected PropertyName _findXmlName(Annotated a)
findAndAddVirtualPropertiesback to summary
public void findAndAddVirtualProperties(MapperConfig<?> config, AnnotatedClass ac, List<BeanPropertyWriter> properties)

Overrides com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector.findAndAddVirtualProperties.

Due to issue [dataformat-xml#578] need to suppress calls to this method to avoid duplicate virtual properties from being added. Not elegant but .. works.

Annotations
@Override
Since
2.15
findNameForDeserializationback to summary
public PropertyName findNameForDeserialization(Annotated a)

Overrides com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector.findNameForDeserialization.

Doc from 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). Should return null if no annotation is found; otherwise a non-null name (possibly PropertyName#USE_DEFAULT, which means "use default heuristics").

Parameters
a:Annotated

Annotated entity to check

Returns:PropertyName

Name to use if found; null if not.

Annotations
@Override
findNameForSerializationback to summary
public PropertyName findNameForSerialization(Annotated a)

Overrides com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector.findNameForSerialization.

Doc from 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. Should return null if no annotation is found; otherwise a non-null name (possibly PropertyName#USE_DEFAULT, which means "use default heuristics").

Parameters
a:Annotated

Property accessor to check

Returns:PropertyName

Name to use if found; null if not.

Annotations
@Override
findNamespaceback to summary
public String findNamespace(MapperConfig<?> config, Annotated ann)

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

Doc from com.fasterxml.jackson.databind.AnnotationIntrospector.XmlExtensions.findNamespace.

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

Parameters
config:MapperConfig<?>

Configuration settings in effect

ann:Annotated

Annotated entity to introspect

Returns:String

Null if annotated thing does not define any namespace information; non-null namespace (which may be empty String) otherwise.

Annotations
@Override
findRootNameback to summary
public PropertyName findRootName(AnnotatedClass ac)

Overrides com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector.findRootName.

Doc from 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. Returns null if no declaration found; can return explicit empty String, which is usually ignored as well as null.

Note

method signature changed in 2.1, to return PropertyName instead of String.

Parameters
ac:AnnotatedClass

Annotated class to introspect

Returns:PropertyName

Root name to use, if any; null if not

Annotations
@Override
findWrapperNameback to summary
public PropertyName findWrapperName(Annotated ann)

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

Doc from 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. Note that not all serializers and deserializers support use this method: currently (2.1) it is only used by XML-backed handlers.

Returns:PropertyName

Wrapper name to use, if any, or PropertyName#USE_DEFAULT to indicate that no wrapper element should be used.

Annotations
@Override
isOutputAsAttributeback to summary
public Boolean isOutputAsAttribute(MapperConfig<?> config, Annotated ann)

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

Doc from com.fasterxml.jackson.databind.AnnotationIntrospector.XmlExtensions.isOutputAsAttribute.

Method used to check whether given annotated element (field, method, constructor parameter) has indicator that suggests it be output as an XML attribute or not (if not, then as element)

Parameters
config:MapperConfig<?>

Configuration settings in effect

ann:Annotated

Annotated entity to introspect

Returns:Boolean

Null if no indicator found; True or False otherwise

Annotations
@Override
isOutputAsCDataback to summary
public Boolean isOutputAsCData(MapperConfig<?> config, Annotated ann)

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

Doc from 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.

Parameters
config:MapperConfig<?>

Configuration settings in effect

ann:Annotated

Annotated entity to introspect

Returns:Boolean

Null if no indicator found; True or False otherwise

Annotations
@Override
isOutputAsTextback to summary
public Boolean isOutputAsText(MapperConfig<?> config, Annotated ann)

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

Doc from 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.

Parameters
config:MapperConfig<?>

Configuration settings in effect

ann:Annotated

Annotated entity to introspect

Returns:Boolean

Null if no indicator found; True or False otherwise

Annotations
@Override
setDefaultUseWrapperback to summary
public void setDefaultUseWrapper(boolean b)