< prev index next >

src/java.xml/share/classes/javax/xml/namespace/QName.java

Print this page


   1 /*
   2  * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.xml.namespace;
  27 
  28 import java.io.Serializable;
  29 import javax.xml.XMLConstants;
  30 import jdk.xml.internal.SecuritySupport;
  31 
  32 /**
  33  * <p><code>QName</code> represents a <strong>qualified name</strong>
  34  * as defined in the XML specifications: <a
  35  * href="http://www.w3.org/TR/xmlschema-2/#QName">XML Schema Part2:
  36  * Datatypes specification</a>, <a
  37  * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">Namespaces
  38  * in XML</a>, <a
  39  * href="http://www.w3.org/XML/xml-names-19990114-errata">Namespaces
  40  * in XML Errata</a>.</p>
  41  *
  42  * <p>The value of a <code>QName</code> contains a <strong>Namespace
  43  * URI</strong>, <strong>local part</strong> and
  44  * <strong>prefix</strong>.</p>
  45  *
  46  * <p>The prefix is included in <code>QName</code> to retain lexical
  47  * information <strong><em>when present</em></strong> in an {@link
  48  * javax.xml.transform.Source XML input source}. The prefix is
  49  * <strong><em>NOT</em></strong> used in {@link #equals(Object)
  50  * QName.equals(Object)} or to compute the {@link #hashCode()
  51  * QName.hashCode()}.  Equality and the hash code are defined using
  52  * <strong><em>only</em></strong> the Namespace URI and local part.</p>
  53  *
  54  * <p>If not specified, the Namespace URI is set to {@link
  55  * javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI}.
  56  * If not specified, the prefix is set to {@link
  57  * javax.xml.XMLConstants#DEFAULT_NS_PREFIX
  58  * XMLConstants.DEFAULT_NS_PREFIX}.</p>
  59  *
  60  * <p><code>QName</code> is immutable.</p>
  61  *
  62  * @author Jeff Suttor
  63  * @see <a href="http://www.w3.org/TR/xmlschema-2/#QName">
  64  *   XML Schema Part2: Datatypes specification</a>
  65  * @see <a href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">
  66  *   Namespaces in XML</a>
  67  * @see <a href="http://www.w3.org/XML/xml-names-19990114-errata">
  68  *   Namespaces in XML Errata</a>
  69  * @since 1.5
  70  */
  71 
  72 public class QName implements Serializable {
  73     // tests show that the ID is the same from JDK 1.5 through JDK 9
  74     private static final long serialVersionUID = -9120448754896609940L;
  75 
  76     /**
  77      * <p>Namespace URI of this <code>QName</code>.</p>
  78      */
  79     private final String namespaceURI;
  80 
  81     /**
  82      * <p>local part of this <code>QName</code>.</p>
  83      */
  84     private final String localPart;
  85 
  86     /**
  87      * <p>prefix of this <code>QName</code>.</p>
  88      */


   1 /*
   2  * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.xml.namespace;
  27 
  28 import java.io.Serializable;
  29 import javax.xml.XMLConstants;
  30 import jdk.xml.internal.SecuritySupport;
  31 
  32 /**
  33  * <p><code>QName</code> represents a <strong>qualified name</strong>
  34  * as defined in the XML specifications: <a
  35  * href="http://www.w3.org/TR/xmlschema-2/#QName">XML Schema Part2:
  36  * Datatypes specification</a>, <a
  37  * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">Namespaces
  38  * in XML</a>.


  39  *
  40  * <p>The value of a <code>QName</code> contains a <strong>Namespace
  41  * URI</strong>, <strong>local part</strong> and
  42  * <strong>prefix</strong>.</p>
  43  *
  44  * <p>The prefix is included in <code>QName</code> to retain lexical
  45  * information <strong><em>when present</em></strong> in an {@link
  46  * javax.xml.transform.Source XML input source}. The prefix is
  47  * <strong><em>NOT</em></strong> used in {@link #equals(Object)
  48  * QName.equals(Object)} or to compute the {@link #hashCode()
  49  * QName.hashCode()}.  Equality and the hash code are defined using
  50  * <strong><em>only</em></strong> the Namespace URI and local part.</p>
  51  *
  52  * <p>If not specified, the Namespace URI is set to {@link
  53  * javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI}.
  54  * If not specified, the prefix is set to {@link
  55  * javax.xml.XMLConstants#DEFAULT_NS_PREFIX
  56  * XMLConstants.DEFAULT_NS_PREFIX}.</p>
  57  *
  58  * <p><code>QName</code> is immutable.</p>
  59  *
  60  * @author Jeff Suttor
  61  * @see <a href="http://www.w3.org/TR/xmlschema-2/#QName">
  62  *   XML Schema Part2: Datatypes specification</a>
  63  * @see <a href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">
  64  *   Namespaces in XML</a>


  65  * @since 1.5
  66  */
  67 
  68 public class QName implements Serializable {
  69     // tests show that the ID is the same from JDK 1.5 through JDK 9
  70     private static final long serialVersionUID = -9120448754896609940L;
  71 
  72     /**
  73      * <p>Namespace URI of this <code>QName</code>.</p>
  74      */
  75     private final String namespaceURI;
  76 
  77     /**
  78      * <p>local part of this <code>QName</code>.</p>
  79      */
  80     private final String localPart;
  81 
  82     /**
  83      * <p>prefix of this <code>QName</code>.</p>
  84      */


< prev index next >