Class XmlTypeUtils

java.lang.Object
org.jvnet.basicjaxb.xml.bind.model.util.XmlTypeUtils

public class XmlTypeUtils extends Object
Utility methods to introspect on the XmlType annotation.
  • Method Details

    • isJAXBElement

      public static boolean isJAXBElement(Object value)
      Is the given object an instance of JAXBElement.
      Parameters:
      value - The object to inspect.
      Returns:
      True when the object is an instance of JAXBElement; otherwise, false.
    • isXmlRootElement

      public static boolean isXmlRootElement(Object value)
      Is the given object bound to an XmlRootElement.
      Parameters:
      value - The object to inspect.
      Returns:
      True when the object is bound to an XmlRootElement; otherwise, false.
    • isXmlRootElement

      public static boolean isXmlRootElement(Class<?> targetClass)
      Is the given target class bound to an XmlRootElement.
      Parameters:
      targetClass - The class to inspect.
      Returns:
      True when the target class is bound to an XmlRootElement; otherwise, false.
    • getTypeName

      public static QName getTypeName(Class<?> targetClass)
      Get the QName for the given target class.

      Introspect on the XmlType annotation when present or use a default identifier suitable for variables to determine the local part.

      Introspect on the XmlType annotation when present or use a default namespace from the package containing the target class.

      Parameters:
      targetClass - The class used to resolve a QName.
      Returns:
      The QName for the given target class.
    • getPrefix

      public static String getPrefix(Package targetPackage, String namespaceURI)
      Get the XML namespace prefix for the given package and namespace.
      Parameters:
      targetPackage - The target package to extract the XML namespace.
      namespaceURI - The XML namespace used to select the prefix.
      Returns:
      The XML namespace prefix or null.
    • getNamespace

      public static String getNamespace(Package targetPackage)
      Get the XML namespace from given package.
      Parameters:
      targetPackage - The target package to extract the XML namespace.
      Returns:
      The XML namespace or an empty string.