Class Utils


  • public class Utils
    extends Object
    This class contains utility methods.
    • Constructor Detail

      • Utils

        public Utils()
    • Method Detail

      • getNamespacePrefixMapping

        public static Map getNamespacePrefixMapping()
        Returns JAXB namespace prefix mapping. Key is the namespace and value is the prefix.
        Returns:
        a Map of JAXB namespace prefix mapping
      • getJAXBPackages

        public static String getJAXBPackages()
        Returns a String of JAXB packages seperated by ":".
        Returns:
        a String of JAXB packages seperated by ":".
      • DocumentToSOAPMessage

        public static jakarta.xml.soap.SOAPMessage DocumentToSOAPMessage​(Document doc)
                                                                  throws SOAPBindingException
        Converts Document to SOAPMessage
        Parameters:
        doc - the source Document
        Returns:
        SOAPMessage
        Throws:
        SOAPBindingException - if an error occurs while converting the document
      • convertJAXBToElement

        public static List convertJAXBToElement​(List jaxbObjs)
                                         throws JAXBException
        Converts a list of JAXB objects to a list of org.w3c.dom.Element
        Parameters:
        jaxbObjs - a list of JAXB objects
        Returns:
        a list of org.w3c.dom.Element
        Throws:
        JAXBException - if an error occurs while converting JAXB objects.
      • convertJAXBToElement

        public static Element convertJAXBToElement​(Object jaxbObj)
                                            throws JAXBException
        Converts a JAXB object to a org.w3c.dom.Element.
        Parameters:
        jaxbObj - a JAXB object
        Returns:
        a org.w3c.dom.Element
        Throws:
        JAXBException - if an error occurs while converting JAXB object.
      • convertJAXBToElement

        public static Element convertJAXBToElement​(Object jaxbObj,
                                                   boolean checkIdref)
                                            throws JAXBException
        Converts a JAXB object to a org.w3c.dom.Element.
        Parameters:
        jaxbObj - a JAXB object
        Returns:
        a org.w3c.dom.Element
        Throws:
        JAXBException - if an error occurs while converting JAXB object.
      • convertElementToJAXB

        public static List convertElementToJAXB​(List elements)
                                         throws JAXBException
        Converts a list of org.w3c.dom.Element to a list of JAXB objects.
        Parameters:
        elements - a list of org.w3c.dom.Element
        Returns:
        a list of JAXB objects
        Throws:
        JAXBException - if an error occurs while converting org.w3c.dom.Element.
      • convertElementToJAXB

        public static Object convertElementToJAXB​(Element element)
                                           throws JAXBException
        Converts a org.w3c.dom.Element to a JAXB object.
        Parameters:
        element - a org.w3c.dom.Element.
        Returns:
        a JAXB object
        Throws:
        JAXBException - if an error occurs while converting org.w3c.dom.Element
      • StringToBoolean

        public static Boolean StringToBoolean​(String str)
                                       throws Exception
        Converts a value of XML boolean type to Boolean object.
        Parameters:
        str - a value of XML boolean type
        Returns:
        a Boolean object
        Throws:
        Exception - if there is a syntax error
      • BooleanToString

        public static String BooleanToString​(Boolean bool)
        Converts a Boolean object to a String representing XML boolean.
        Parameters:
        bool - a Boolean object.
        Returns:
        a String representing the boolean value.
      • convertStringToQName

        public static QName convertStringToQName​(String str,
                                                 Element element)
        Converts a string value to a QName. The prefix of the string value is resolved to a namespace relative to the element.
        Parameters:
        str - the String to be converted.
        element - the Element object.
        Returns:
        the QName Object.
      • getNamespaceForPrefix

        public static String getNamespaceForPrefix​(String prefix,
                                                   Element e)
        Gets the XML namespace URI that is mapped to the specified prefix, in the context of the DOM element e
        Parameters:
        prefix - The namespace prefix to map
        e - The DOM element in which to calculate the prefix binding
        Returns:
        The XML namespace URI mapped to prefix in the context of e
      • enforceProcessingRules

        public static void enforceProcessingRules​(Message message,
                                                  String requestMessageID,
                                                  boolean isServer)
                                           throws SOAPBindingException,
                                                  SOAPFaultException
        Enforces message processiong rules defined in the spec.
        Parameters:
        message - a message
        requestMessageID - the request messageID if we are checking a response message or null if we are checking a request message
        isServer - true if this is a server
        Throws:
        SOAPBindingException - if the message violates rules on client.
        SOAPFaultException - if the message violates rules on server.
      • getString

        public static String getString​(String key,
                                       Object[] params)
        Gets localized string from resource bundle.
        Parameters:
        key - a key to a resource bundle
        params - parameters to MessageFormat
        Returns:
        a localized string.
      • getDefaultWSFVersion

        public static String getDefaultWSFVersion()
        Returns the default web services version.
        Returns:
        the default web services version.