Class JacksonXmlAnnotationIntrospector

All Implemented Interfaces:
Versioned, AnnotationIntrospector.XmlExtensions, XmlAnnotationIntrospector, Serializable

public class JacksonXmlAnnotationIntrospector extends JacksonAnnotationIntrospector implements XmlAnnotationIntrospector
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).
See Also:
  • Field Details

    • 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:
  • Constructor Details

    • JacksonXmlAnnotationIntrospector

      public JacksonXmlAnnotationIntrospector()
    • JacksonXmlAnnotationIntrospector

      public JacksonXmlAnnotationIntrospector(boolean defaultUseWrapper)
  • Method Details

    • 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 class AnnotationIntrospector
      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 class JacksonAnnotationIntrospector
      Parameters:
      ac - Annotated class to introspect
      Returns:
      Root name to use, if any; null if not
    • findNamespace

      public 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 interface AnnotationIntrospector.XmlExtensions
      Parameters:
      config - Configuration settings in effect
      ann - 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, 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 class JacksonAnnotationIntrospector
      Since:
      2.15
    • isOutputAsAttribute

      public 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 interface AnnotationIntrospector.XmlExtensions
      Parameters:
      config - Configuration settings in effect
      ann - Annotated entity to introspect
      Returns:
      Null if no indicator found; True or False otherwise
    • isOutputAsText

      public 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 interface AnnotationIntrospector.XmlExtensions
      Parameters:
      config - Configuration settings in effect
      ann - Annotated entity to introspect
      Returns:
      Null if no indicator found; True or False otherwise
    • isOutputAsCData

      public 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 interface AnnotationIntrospector.XmlExtensions
      Parameters:
      config - Configuration settings in effect
      ann - Annotated entity to introspect
      Returns:
      Null if no indicator found; True or False 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 (possibly PropertyName.USE_DEFAULT, which means "use default heuristics").
      Overrides:
      findNameForSerialization in class JacksonAnnotationIntrospector
      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 (possibly PropertyName.USE_DEFAULT, which means "use default heuristics").
      Overrides:
      findNameForDeserialization in class JacksonAnnotationIntrospector
      Parameters:
      a - Annotated entity to check
      Returns:
      Name to use if found; null if not.