org.exist.dom
Class QName

java.lang.Object
  extended by org.exist.dom.QName
All Implemented Interfaces:
Comparable

public class QName
extends Object
implements Comparable

Represents a QName, consisting of a local name, a namespace URI and a prefix.

Author:
Wolfgang

Field Summary
static QName COMMENT_QNAME
           
static QName DOCTYPE_QNAME
           
static QName DOCUMENT_QNAME
           
static QName EMPTY_QNAME
           
static QName TEXT_QNAME
           
 
Constructor Summary
QName(QName other)
           
QName(String name)
           
QName(String localName, String namespaceURI)
           
QName(String localName, String namespaceURI, String prefix)
          Construct a QName.
 
Method Summary
 int compareTo(Object o)
          Compares two QNames by comparing namespace URI and local names.
 boolean equals(Object obj)
          Checks two QNames for equality.
 boolean equalsSimple(QName other)
           
static String extractLocalName(String qname)
          Extract the local name from a QName string.
static String extractPrefix(String qname)
          Extract the prefix from a QName string.
 String getLocalName()
           
 String getNamespaceURI()
           
 byte getNameType()
           
 String getPrefix()
           
 String getStringValue()
           
 int hashCode()
           
static boolean isQName(String name)
           
 boolean needsNamespaceDecl()
          Returns true if the QName defines a namespace URI.
static QName parse(XQueryContext context, String qname)
          Parses the given string into a QName.
static QName parse(XQueryContext context, String qname, String defaultNS)
          Parses the given string into a QName.
 void setLocalName(String name)
           
 void setNamespaceURI(String namespaceURI)
           
 void setNameType(byte type)
           
 void setPrefix(String prefix)
           
 QName toJavaQName()
           
 String toString()
          (deprecated) : use for debugging purpose only, use getStringValue() for production
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_QNAME

public static final QName EMPTY_QNAME

DOCUMENT_QNAME

public static final QName DOCUMENT_QNAME

TEXT_QNAME

public static final QName TEXT_QNAME

COMMENT_QNAME

public static final QName COMMENT_QNAME

DOCTYPE_QNAME

public static final QName DOCTYPE_QNAME
Constructor Detail

QName

public QName(String localName,
             String namespaceURI,
             String prefix)
Construct a QName. The prefix might be null for the default namespace or if no prefix has been defined for the QName. The namespace URI should be set to the empty string, if no namespace URI is defined.

Parameters:
localName -
namespaceURI -
prefix -

QName

public QName(String localName,
             String namespaceURI)

QName

public QName(QName other)

QName

public QName(String name)
Method Detail

getLocalName

public String getLocalName()

setLocalName

public void setLocalName(String name)

getNamespaceURI

public String getNamespaceURI()

setNamespaceURI

public void setNamespaceURI(String namespaceURI)

needsNamespaceDecl

public boolean needsNamespaceDecl()
Returns true if the QName defines a namespace URI.


getPrefix

public String getPrefix()

setPrefix

public void setPrefix(String prefix)

setNameType

public void setNameType(byte type)

getNameType

public byte getNameType()

getStringValue

public String getStringValue()

toString

public String toString()
(deprecated) : use for debugging purpose only, use getStringValue() for production

Overrides:
toString in class Object

compareTo

public int compareTo(Object o)
Compares two QNames by comparing namespace URI and local names. The prefixes are not relevant.

Specified by:
compareTo in interface Comparable
See Also:
Comparable.compareTo(java.lang.Object)

equals

public boolean equals(Object obj)
Checks two QNames for equality. Two QNames are equal if their namespace URIs, local names and prefixes are equal.

Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

equalsSimple

public boolean equalsSimple(QName other)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toJavaQName

public QName toJavaQName()

extractPrefix

public static String extractPrefix(String qname)
                            throws IllegalArgumentException
Extract the prefix from a QName string.

Parameters:
qname -
Returns:
the prefix, if found
Throws:
IllegalArgumentException - if the qname starts with a leading :

extractLocalName

public static String extractLocalName(String qname)
                               throws IllegalArgumentException
Extract the local name from a QName string.

Parameters:
qname -
Throws:
IllegalArgumentException - if the qname starts with a leading : or ends with a :

parse

public static QName parse(XQueryContext context,
                          String qname,
                          String defaultNS)
                   throws XPathException
Parses the given string into a QName. The method uses context to look up a namespace URI for an existing prefix.

Parameters:
context -
qname -
defaultNS - the default namespace to use if no namespace prefix is present.
Returns:
QName
Throws:
IllegalArgumentException - if no namespace URI is mapped to the prefix
XPathException

parse

public static QName parse(XQueryContext context,
                          String qname)
                   throws XPathException
Parses the given string into a QName. The method uses context to look up a namespace URI for an existing prefix. This method uses the default element namespace for qnames without prefix.

Parameters:
context -
qname -
Throws:
IllegalArgumentException - if no namespace URI is mapped to the prefix
XPathException

isQName

public static final boolean isQName(String name)


Copyright (C) Wolfgang Meier. All rights reserved.