Class JacksonXmlAnnotationIntrospector
- java.lang.Object
-
- com.fasterxml.jackson.databind.AnnotationIntrospector
-
- com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector
-
- com.fasterxml.jackson.dataformat.xml.JacksonXmlAnnotationIntrospector
-
- All Implemented Interfaces:
Versioned
,AnnotationIntrospector.XmlExtensions
,XmlAnnotationIntrospector
,java.io.Serializable
public class JacksonXmlAnnotationIntrospector extends JacksonAnnotationIntrospector implements XmlAnnotationIntrospector
Extension ofJacksonAnnotationIntrospector
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, classcom.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector
).- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.AnnotationIntrospector
AnnotationIntrospector.ReferenceProperty, AnnotationIntrospector.XmlExtensions
-
Nested classes/interfaces inherited from interface com.fasterxml.jackson.dataformat.xml.XmlAnnotationIntrospector
XmlAnnotationIntrospector.Pair
-
-
Field Summary
Fields Modifier and Type Field Description static 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.
-
Constructor Summary
Constructors Constructor Description JacksonXmlAnnotationIntrospector()
JacksonXmlAnnotationIntrospector(boolean defaultUseWrapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
findAndAddVirtualProperties(MapperConfig<?> config, AnnotatedClass ac, java.util.List<BeanPropertyWriter> properties)
Due to issue [dataformat-xml#578] need to suppress calls to this method to avoid duplicate virtual properties from being added.PropertyName
findNameForDeserialization(Annotated a)
Method for checking whether given property accessors (method, field) has an annotation that suggests property name to use for deserialization (reading JSON into POJOs).PropertyName
findNameForSerialization(Annotated a)
Method for checking whether given property accessors (method, field) has an annotation that suggests property name to use for serialization.java.lang.String
findNamespace(MapperConfig<?> config, Annotated ann)
Method that can be called to figure out generic namespace property for an annotated object.PropertyName
findRootName(AnnotatedClass ac)
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.PropertyName
findWrapperName(Annotated ann)
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.java.lang.Boolean
isOutputAsAttribute(MapperConfig<?> config, Annotated ann)
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)java.lang.Boolean
isOutputAsCData(MapperConfig<?> config, Annotated ann)
Method used to check whether given annotated element (field, method, constructor parameter) has indicator that suggests it should be wrapped in a CDATA tag.java.lang.Boolean
isOutputAsText(MapperConfig<?> config, Annotated ann)
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.void
setDefaultUseWrapper(boolean b)
-
Methods inherited from class com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector
findAutoDetectVisibility, findClassDescription, findContentDeserializer, findContentSerializer, findCreatorAnnotation, findCreatorBinding, findDefaultEnumValue, findDeserializationContentConverter, findDeserializationConverter, findDeserializer, findEnumAliases, findEnumNamingStrategy, findEnumValue, findEnumValues, findFilterId, findFormat, findImplicitPropertyName, findInjectableValue, findInjectableValueId, findKeyDeserializer, findKeySerializer, findMergeInfo, findNamingStrategy, findNullSerializer, findObjectIdInfo, findObjectReferenceInfo, findPOJOBuilder, findPOJOBuilderConfig, findPropertyAccess, findPropertyAliases, findPropertyContentTypeResolver, findPropertyDefaultValue, findPropertyDescription, findPropertyIgnoralByName, findPropertyIgnorals, findPropertyInclusion, findPropertyInclusionByName, findPropertyIndex, findPropertyTypeResolver, findReferenceType, findRenameByField, findSerializationContentConverter, findSerializationConverter, findSerializationPropertyOrder, findSerializationSortAlphabetically, findSerializationTyping, findSerializer, findSetterInfo, findSubtypes, findTypeName, findTypeResolver, findUnwrappingNameTransformer, findValueInstantiator, findViews, hasAnyGetter, hasAnyGetterAnnotation, hasAnySetter, hasAnySetterAnnotation, hasAsKey, hasAsValue, hasAsValueAnnotation, hasCreatorAnnotation, hasIgnoreMarker, hasRequiredMarker, isAnnotationBundle, isIgnorableType, isTypeId, refineDeserializationType, refineSerializationType, resolveSetterConflict, setConstructorPropertiesImpliesCreator, version
-
Methods inherited from class com.fasterxml.jackson.databind.AnnotationIntrospector
allIntrospectors, allIntrospectors, findIgnoreUnknownProperties, findPropertiesToIgnore, nopInstance, pair
-
-
-
-
Field Detail
-
DEFAULT_USE_WRAPPER
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.- See Also:
- Constant Field Values
-
-
Method Detail
-
setDefaultUseWrapper
public void setDefaultUseWrapper(boolean b)
-
findWrapperName
public PropertyName findWrapperName(Annotated ann)
Description copied from class:AnnotationIntrospector
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.- Overrides:
findWrapperName
in classAnnotationIntrospector
- Returns:
- Wrapper name to use, if any, or
PropertyName.USE_DEFAULT
to indicate that no wrapper element should be used.
-
findRootName
public PropertyName findRootName(AnnotatedClass ac)
Description copied from class:AnnotationIntrospector
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.- Overrides:
findRootName
in classJacksonAnnotationIntrospector
- Parameters:
ac
- Annotated class to introspect- Returns:
- Root name to use, if any;
null
if not
-
findNamespace
public java.lang.String findNamespace(MapperConfig<?> config, Annotated ann)
Description copied from interface:AnnotationIntrospector.XmlExtensions
Method that can be called to figure out generic namespace property for an annotated object.- Specified by:
findNamespace
in interfaceAnnotationIntrospector.XmlExtensions
- Parameters:
config
- Configuration settings in effectann
- Annotated entity to introspect- Returns:
- Null if annotated thing does not define any namespace information; non-null namespace (which may be empty String) otherwise.
-
findAndAddVirtualProperties
public void findAndAddVirtualProperties(MapperConfig<?> config, AnnotatedClass ac, java.util.List<BeanPropertyWriter> properties)
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.- Overrides:
findAndAddVirtualProperties
in classJacksonAnnotationIntrospector
- Since:
- 2.15
-
isOutputAsAttribute
public java.lang.Boolean isOutputAsAttribute(MapperConfig<?> config, Annotated ann)
Description copied from interface:AnnotationIntrospector.XmlExtensions
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)- Specified by:
isOutputAsAttribute
in interfaceAnnotationIntrospector.XmlExtensions
- Parameters:
config
- Configuration settings in effectann
- Annotated entity to introspect- Returns:
- Null if no indicator found;
True
orFalse
otherwise
-
isOutputAsText
public java.lang.Boolean isOutputAsText(MapperConfig<?> config, Annotated ann)
Description copied from interface:AnnotationIntrospector.XmlExtensions
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.- Specified by:
isOutputAsText
in interfaceAnnotationIntrospector.XmlExtensions
- Parameters:
config
- Configuration settings in effectann
- Annotated entity to introspect- Returns:
- Null if no indicator found;
True
orFalse
otherwise
-
isOutputAsCData
public java.lang.Boolean isOutputAsCData(MapperConfig<?> config, Annotated ann)
Description copied from interface:AnnotationIntrospector.XmlExtensions
Method used to check whether given annotated element (field, method, constructor parameter) has indicator that suggests it should be wrapped in a CDATA tag.- Specified by:
isOutputAsCData
in interfaceAnnotationIntrospector.XmlExtensions
- Parameters:
config
- Configuration settings in effectann
- Annotated entity to introspect- Returns:
- Null if no indicator found;
True
orFalse
otherwise
-
findNameForSerialization
public PropertyName findNameForSerialization(Annotated a)
Description copied from class:AnnotationIntrospector
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 (possiblyPropertyName.USE_DEFAULT
, which means "use default heuristics").- Overrides:
findNameForSerialization
in classJacksonAnnotationIntrospector
- Parameters:
a
- Property accessor to check- Returns:
- Name to use if found; null if not.
-
findNameForDeserialization
public PropertyName findNameForDeserialization(Annotated a)
Description copied from class:AnnotationIntrospector
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 (possiblyPropertyName.USE_DEFAULT
, which means "use default heuristics").- Overrides:
findNameForDeserialization
in classJacksonAnnotationIntrospector
- Parameters:
a
- Annotated entity to check- Returns:
- Name to use if found;
null
if not.
-
-