All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.xerces.xni.QName Maven / Gradle / Ivy

Go to download

Xerces2 is the next generation of high performance, fully compliant XML parsers in the Apache Xerces family. This new version of Xerces introduces the Xerces Native Interface (XNI), a complete framework for building parser components and configurations that is extremely modular and easy to program. The Apache Xerces2 parser is the reference implementation of XNI but other parser components, configurations, and parsers can be written using the Xerces Native Interface. For complete design and implementation documents, refer to the XNI Manual. Xerces2 is a fully conforming XML Schema 1.0 processor. A partial experimental implementation of the XML Schema 1.1 Structures and Datatypes Working Drafts (December 2009) and an experimental implementation of the XML Schema Definition Language (XSD): Component Designators (SCD) Candidate Recommendation (January 2010) are provided for evaluation. For more information, refer to the XML Schema page. Xerces2 also provides a complete implementation of the Document Object Model Level 3 Core and Load/Save W3C Recommendations and provides a complete implementation of the XML Inclusions (XInclude) W3C Recommendation. It also provides support for OASIS XML Catalogs v1.1. Xerces2 is able to parse documents written according to the XML 1.1 Recommendation, except that it does not yet provide an option to enable normalization checking as described in section 2.13 of this specification. It also handles namespaces according to the XML Namespaces 1.1 Recommendation, and will correctly serialize XML 1.1 documents if the DOM level 3 load/save APIs are in use.

There is a newer version: 2.12.2
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.xerces.xni;

/**
 * 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 $ */ public class QName implements Cloneable { // // Data // /** * The qname prefix. For example, the prefix for the qname "a:foo" * is "a". */ public String prefix; /** * The qname localpart. For example, the localpart for the qname "a:foo" * is "foo". */ public String localpart; /** * The qname rawname. For example, the rawname for the qname "a:foo" * is "a:foo". */ public String rawname; /** * The URI to which the qname prefix is bound. This binding must be * performed by a XML Namespaces aware processor. */ public String uri; // // Constructors // /** Default constructor. */ public QName() { clear(); } // () /** Constructs a QName with the specified values. */ public QName(String prefix, String localpart, String rawname, String uri) { setValues(prefix, localpart, rawname, uri); } // (String,String,String,String) /** Constructs a copy of the specified QName. */ public QName(QName qname) { setValues(qname); } // (QName) // // Public methods // /** * Convenience method to set the values of the qname components. * * @param qname The qualified name to be copied. */ public void setValues(QName qname) { prefix = qname.prefix; localpart = qname.localpart; rawname = qname.rawname; uri = qname.uri; } // setValues(QName) /** * 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") */ public void setValues(String prefix, String localpart, String rawname, String uri) { this.prefix = prefix; this.localpart = localpart; this.rawname = rawname; this.uri = uri; } // setValues(String,String,String,String) /** Clears the values of the qname components. */ public void clear() { prefix = null; localpart = null; rawname = null; uri = null; } // clear() // // Cloneable methods // /** Returns a clone of this object. */ public Object clone() { return new QName(this); } // clone():Object // // Object methods // /** Returns the hashcode for this object. */ public int hashCode() { if (uri != null) { return uri.hashCode() + ((localpart != null) ? localpart.hashCode() : 0); } return (rawname != null) ? rawname.hashCode() : 0; } // hashCode():int /** Returns true if the two objects are equal. */ public boolean equals(Object object) { 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; } // equals(Object):boolean /** Returns a string representation of this object. */ public String toString() { 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(); } // toString():String } // class QName





© 2015 - 2024 Weber Informatics LLC | Privacy Policy