FileDocCategorySizeDatePackage
QName.javaAPI DocJava SE 5 API7499Fri Aug 26 14:55:56 BST 2005com.sun.org.apache.xerces.internal.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
com.sun.org.apache.xerces.internal.util.SymbolTable
author
Andy Clark, IBM
version
$Id: QName.java,v 1.5 2002/01/29 01:15:19 lehors Exp $

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.hashCode();
        }
        return rawname.hashCode();
    
public voidsetValues(com.sun.org.apache.xerces.internal.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=\""+prefix+'"");
            comma = true;
        }
        if (localpart != null) {
            if (comma) {
                str.append(',");
            }
            str.append("localpart=\""+localpart+'"");
            comma = true;
        }
        if (rawname != null) {
            if (comma) {
                str.append(',");
            }
            str.append("rawname=\""+rawname+'"");
            comma = true;
        }
        if (uri != null) {
            if (comma) {
                str.append(',");
            }
            str.append("uri=\""+uri+'"");
        }
        return str.toString();