Save This Page
Home » apache-woden-src-1.0M8 » javax » xml » namespace » [javadoc | source]
javax.xml.namespace
public class: QName [javadoc | source]
java.lang.Object
   javax.xml.namespace.QName

All Implemented Interfaces:
    Serializable

QName class represents the value of a qualified name as specified in XML Schema Part2: Datatypes specification.

The WSDL4J version of QName has been copied and updated for Apache Woden to match the Javadoc of the QName class defined for Java 5.0 at:
http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/namespace/QName.html

The value of a QName contains a namespaceURI, a localPart and a prefix. The localPart provides the local part of the qualified name. The namespaceURI is a URI reference identifying the namespace. The prefix corresponds to a namespace declaration 'xmlns:somePrefix' in the underlying xml.

Note: Some of this impl code was taken from Axis.

The constructors throw an IllegalArgumentException if the 'localPart' argument is null, but if it is the empty string ("") they just create the QName object with the localPart set to the empty string. The 'prefix' property defaults to the empty string for the two constructors that do not take a 'prefix' argument. The constructor that does take a 'prefix' argument will throw an IllegalArgumentException if a null value is used (i.e. the absence of any 'prefix' must be specified explicitly as the empty string "").

The valueOf method behaves like the constructors in that a null value will throw an IllegalArgumentException, but an empty string "" value will be treated as a localPart rather than an IllegalArgumentException to retain compatibility with v1.0 QName.

To support the deserialization of objects that were serialized with an older version of QName (i.e. without a 'prefix' field), the readObject method will check if the 'prefix' value is null after default deserialization and if so, change it to the empty string.

Constructor:
 public QName(String localPart) 
    Constructor for the QName. Takes a localPart and sets the namespace and prefix to the empty string "".
    Parameters:
    localPart - Local part of the QName
    Throws:
    IllegalArgumentException - if localPart is null.
 public QName(String namespaceURI,
    String localPart) 
    Constructor for the QName. Takes a localPart and a namespace and sets the prefix to the empty string "". If namespace is null, it defaults to the empty string.
    Parameters:
    namespaceURI - Namespace URI for the QName
    localPart - Local part of the QName.
    Throws:
    IllegalArgumentException - if localPart is null.
 public QName(String namespaceURI,
    String localPart,
    String prefix) 
    Constructor for the QName. Takes a localPart, a namespace and a prefix. If the namespace is null, it defaults to the empty string "". The localPart and prefix cannot be null. If they are, an IllegalArgumentException is thrown. If there is no prefix, an empty string "" must be specified.
    Parameters:
    namespaceURI - Namespace URI for the QName
    localPart - Local part of the QName.
    prefix - the xmlns-declared prefix for this namespaceURI
    Throws:
    IllegalArgumentException - if localPart or prefix is null.
Method from javax.xml.namespace.QName Summary:
equals,   getLocalPart,   getNamespaceURI,   getPrefix,   hashCode,   toString,   valueOf
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.xml.namespace.QName Detail:
 public final boolean equals(Object obj) 
    Tests this QName for equality with another object.

    If the given object is not a QName or is null then this method returns false.

    For two QNames to be considered equal requires that both localPart and namespaceURI must be equal. This method uses String.equals to check equality of localPart and namespaceURI. The prefix is NOT used to determine equality. Any class that extends QName is required to satisfy this equality contract.

    This method satisfies the general contract of the Object.equals method.

 public String getLocalPart() 
    Gets the Local part for this QName
 public String getNamespaceURI() 
    Gets the Namespace URI for this QName
 public String getPrefix() 
    Gets the prefix for this QName
 public final int hashCode() 
    Returns a hash code value for this QName object. The hash code is based on both the localPart and namespaceURI parts of the QName. This method satisfies the general contract of the Object.hashCode method.
 public String toString() 
    Returns a string representation of this QName
 public static QName valueOf(String s) 
    Returns a QName holding the value of the specified String.

    The string must be in the form returned by the QName.toString() method, i.e. "{namespaceURI}localPart", with the "{namespaceURI}" part being optional. If the Namespace URI .equals(""), only the local part should be provided. An empty string "" value will be treated as the localPart.

    The prefix value CANNOT be represented in the String and will be set to "".

    This method doesn't do a full validation of the resulting QName. In particular, it doesn't check that the resulting namespace URI is a legal URI (per RFC 2396 and RFC 2732), nor that the resulting local part is a legal NCName per the XML Namespaces specification.