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 <a href="mailto:Jeff.Suttor@Sun.com">Jeff Suttor</a> 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 74 /** 75 * <p>Stream Unique Identifier.</p> 76 * 77 * <p>Due to a historical defect, QName was released with multiple 78 * serialVersionUID values even though its serialization was the 79 * same.</p> 80 * 81 * <p>To workaround this issue, serialVersionUID is set with either 82 * a default value or a compatibility value. To use the 83 * compatibility value, set the system property:</p> 84 * 85 * <code>com.sun.xml.namespace.QName.useCompatibleSerialVersionUID=1.0</code> 86 * 87 * <p>This workaround was inspired by classes in the javax.management 88 * package, e.g. ObjectName, etc. 89 * See CR6267224 for original defect report.</p> 90 */ 91 private static final long serialVersionUID; 92 /** 93 * <p>Default <code>serialVersionUID</code> value.</p> 94 */ 95 private static final long defaultSerialVersionUID = -9120448754896609940L; 96 /** 97 * <p>Compatibility <code>serialVersionUID</code> value.</p> 98 */ 99 private static final long compatibleSerialVersionUID = 4418622981026545151L; 100 /** 101 * <p>Flag to use default or campatible serialVersionUID.</p> 102 */ 103 private static boolean useDefaultSerialVersionUID = true; 104 static { 105 try { 106 // use a privileged block as reading a system property 107 String valueUseCompatibleSerialVersionUID = SecuritySupport.getSystemProperty( 108 "com.sun.xml.namespace.QName.useCompatibleSerialVersionUID"); 109 110 useDefaultSerialVersionUID = (valueUseCompatibleSerialVersionUID != null 111 && valueUseCompatibleSerialVersionUID.equals("1.0")) ? false : true; 112 } catch (Exception exception) { 113 // use default if any Exceptions 114 useDefaultSerialVersionUID = true; 115 } 116 117 // set serialVersionUID to desired value 118 if (useDefaultSerialVersionUID) { 119 serialVersionUID = defaultSerialVersionUID; 120 } else { 121 serialVersionUID = compatibleSerialVersionUID; 122 } 123 } 124 125 /** 126 * <p>Namespace URI of this <code>QName</code>.</p> 127 */ 128 private final String namespaceURI; 129 130 /** 131 * <p>local part of this <code>QName</code>.</p> 132 */ 133 private final String localPart; 134 135 /** 136 * <p>prefix of this <code>QName</code>.</p> 137 */ 138 private final String prefix; 139 140 /** 141 * <p><code>QName</code> constructor specifying the Namespace URI 142 * and local part.</p> 143 * | 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 <a href="mailto:Jeff.Suttor@Sun.com">Jeff Suttor</a> 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 */ 89 private final String prefix; 90 91 /** 92 * <p><code>QName</code> constructor specifying the Namespace URI 93 * and local part.</p> 94 * |