Apache CXF API

org.apache.cxf.aegis.util
Class NamespaceHelper

java.lang.Object
  extended by org.apache.cxf.aegis.util.NamespaceHelper

public final class NamespaceHelper
extends Object

Namespace utilities.


Method Summary
static QName createQName(Element e, String value, String defaultNamespace)
           
static QName createQName(NamespaceContext nc, String value)
           
static String getPrefix(Element element, String namespaceURI)
           
static void getPrefixes(Element element, String namespaceURI, List<String> prefixes)
           
static String getUniquePrefix(Element element, String namespaceURI)
          Create a unique namespace uri/prefix combination.
static String getUniquePrefix(javax.xml.stream.XMLStreamWriter writer, String namespaceURI, boolean declare)
          Create a unique namespace uri/prefix combination.
static String getUniquePrefix(javax.xml.stream.XMLStreamWriter writer, String namespaceURI, String preferred, boolean declare)
          Make a unique prefix.
static String makeNamespaceFromClassName(String className, String protocol)
          Generates the name of a XML namespace from a given class name and protocol.
static String makePackageName(String namespace)
          Method makePackageName
static QName readQName(javax.xml.stream.XMLStreamReader reader)
          Reads a QName from the element text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getUniquePrefix

public static String getUniquePrefix(Element element,
                                     String namespaceURI)
Create a unique namespace uri/prefix combination.

Parameters:
nsUri -
Returns:
The namespace with the specified URI. If one doesn't exist, one is created.

getPrefix

public static String getPrefix(Element element,
                               String namespaceURI)

getPrefixes

public static void getPrefixes(Element element,
                               String namespaceURI,
                               List<String> prefixes)

getUniquePrefix

public static String getUniquePrefix(javax.xml.stream.XMLStreamWriter writer,
                                     String namespaceURI,
                                     boolean declare)
                              throws javax.xml.stream.XMLStreamException
Create a unique namespace uri/prefix combination.

Parameters:
nsUri -
Returns:
The namespace with the specified URI. If one doesn't exist, one is created.
Throws:
javax.xml.stream.XMLStreamException

getUniquePrefix

public static String getUniquePrefix(javax.xml.stream.XMLStreamWriter writer,
                                     String namespaceURI,
                                     String preferred,
                                     boolean declare)
                              throws javax.xml.stream.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:
javax.xml.stream.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

makePackageName

public static String makePackageName(String namespace)
Method makePackageName

Parameters:
namespace -
Returns:

readQName

public static QName readQName(javax.xml.stream.XMLStreamReader reader)
                       throws javax.xml.stream.XMLStreamException
Reads a QName from the element text. Reader must be positioned at the start tag.

Parameters:
reader -
Returns:
Throws:
javax.xml.stream.XMLStreamException

createQName

public static QName createQName(NamespaceContext nc,
                                String value)

createQName

public static QName createQName(Element e,
                                String value,
                                String defaultNamespace)

Apache CXF API

Apache CXF