FileDocCategorySizeDatePackage
QName.javaAPI DocApache Xerces 3.0.15878Fri Sep 14 20:33:54 BST 2007org.apache.xerces.xni

QName

public class QName extends Object implements Cloneable
A structure that holds the components of an XML Namespaces qualified name.

To be used correctly, the strings must be identical references for equal strings. Within the parser, these values are considered symbols and should always be retrieved from the SymbolTable.

see
org.apache.xerces.util.SymbolTable
author
Andy Clark, IBM
version
$Id: QName.java 447247 2006-09-18 05:23:52Z mrglavas $

Fields Summary
public String
prefix
The qname prefix. For example, the prefix for the qname "a:foo" is "a".
public String
localpart
The qname localpart. For example, the localpart for the qname "a:foo" is "foo".
public String
rawname
The qname rawname. For example, the rawname for the qname "a:foo" is "a:foo".
public String
uri
The URI to which the qname prefix is bound. This binding must be performed by a XML Namespaces aware processor.
Constructors Summary
public QName()
Default constructor.

        clear();
    
public QName(String prefix, String localpart, String rawname, String uri)
Constructs a QName with the specified values.

        setValues(prefix, localpart, rawname, uri);
    
public QName(QName qname)
Constructs a copy of the specified QName.

        setValues(qname);
    
Methods Summary
public voidclear()
Clears the values of the qname components.

        prefix = null;
        localpart = null;
        rawname = null;
        uri = null;
    
public java.lang.Objectclone()
Returns a clone of this object.

        return new QName(this);
    
public booleanequals(java.lang.Object object)
Returns true if the two objects are equal.

        if (object instanceof QName) {
            QName qname = (QName)object;
            if (qname.uri != null) {
                return uri == qname.uri && localpart == qname.localpart;
            }
            else if (uri == null) {
                return rawname == qname.rawname;
            }
            // fall through and return not equal
        }
        return false;
    
public inthashCode()
Returns the hashcode for this object.

        if (uri != null) {
            return uri.hashCode() + 
                ((localpart != null) ? localpart.hashCode() : 0);
        }
        return (rawname != null) ? rawname.hashCode() : 0;
    
public voidsetValues(org.apache.xerces.xni.QName qname)
Convenience method to set the values of the qname components.

param
qname The qualified name to be copied.

        prefix = qname.prefix;
        localpart = qname.localpart;
        rawname = qname.rawname;
        uri = qname.uri;
    
public voidsetValues(java.lang.String prefix, java.lang.String localpart, java.lang.String rawname, java.lang.String uri)
Convenience method to set the values of the qname components.

param
prefix The qname prefix. (e.g. "a")
param
localpart The qname localpart. (e.g. "foo")
param
rawname The qname rawname. (e.g. "a:foo")
param
uri The URI binding. (e.g. "http://foo.com/mybinding")

        this.prefix = prefix;
        this.localpart = localpart;
        this.rawname = rawname;
        this.uri = uri;
    
public java.lang.StringtoString()
Returns a string representation of this object.


        StringBuffer str = new StringBuffer();
        boolean comma = false;
        if (prefix != null) {
            str.append("prefix=\"").append(prefix).append('"");
            comma = true;
        }
        if (localpart != null) {
            if (comma) {
                str.append(',");
            }
            str.append("localpart=\"").append(localpart).append('"");
            comma = true;
        }
        if (rawname != null) {
            if (comma) {
                str.append(',");
            }
            str.append("rawname=\"").append(rawname).append('"");
            comma = true;
        }
        if (uri != null) {
            if (comma) {
                str.append(',");
            }
            str.append("uri=\"").append(uri).append('"");
        }
        return str.toString();