Class NamespaceHelper


  • public final class NamespaceHelper
    extends Object
    Namespace utilities.
    • Method Detail

      • getUniquePrefix

        public static String getUniquePrefix​(Element element,
                                             String namespaceURI)
        Create a unique namespace uri/prefix combination.
        Parameters:
        element -
        namespaceURI - namespace
        Returns:
        The namespace with the specified URI. If one doesn't exist, one is created.
      • getUniquePrefix

        public static String getUniquePrefix​(XMLStreamWriter writer,
                                             String namespaceURI,
                                             boolean declare)
                                      throws XMLStreamException
        Create a unique namespace uri/prefix combination.
        Parameters:
        writer - target writer.
        namespaceURI - namespace
        declare - whether to declare to the stream.
        Returns:
        The namespace with the specified URI. If one doesn't exist, one is created.
        Throws:
        XMLStreamException
      • getUniquePrefix

        public static String getUniquePrefix​(XMLStreamWriter writer,
                                             String namespaceURI,
                                             String preferred,
                                             boolean declare)
                                      throws XMLStreamException
        Make a unique prefix.
        Parameters:
        writer - target writer.
        namespaceURI - namespace
        preferred - if there's a proposed prefix (e.g. xsi), here it is.
        declare - whether to declare to the stream.
        Returns:
        the prefix.
        Throws:
        XMLStreamException
      • makeNamespaceFromClassName

        public static String makeNamespaceFromClassName​(String className,
                                                        String protocol)
        Generates the name of a XML namespace from a given class name and protocol. The returned namespace will take the form protocol://domain, where protocol is the given protocol, and domain the inversed package name of the given class name.

        For instance, if the given class name is org.codehaus.xfire.services.Echo, and the protocol is http, the resulting namespace would be http://services.xfire.codehaus.org.

        Parameters:
        className - the class name
        protocol - the protocol (eg. http)
        Returns:
        the namespace