1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/fastinfoset/QualifiedName.java Wed Apr 27 01:27:09 2016 +0800 1.3 @@ -0,0 +1,310 @@ 1.4 +/* 1.5 + * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + * 1.28 + * THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC. 1.29 + */ 1.30 + 1.31 +package com.sun.xml.internal.fastinfoset; 1.32 + 1.33 +import javax.xml.namespace.QName; 1.34 + 1.35 +public class QualifiedName { 1.36 + public String prefix; 1.37 + public String namespaceName; 1.38 + public String localName; 1.39 + public String qName; 1.40 + public int index; 1.41 + public int prefixIndex; 1.42 + public int namespaceNameIndex; 1.43 + public int localNameIndex; 1.44 + public int attributeId; 1.45 + public int attributeHash; 1.46 + private QName qNameObject; 1.47 + 1.48 + public QualifiedName() { } 1.49 + 1.50 + public QualifiedName(String prefix, String namespaceName, String localName, String qName) { 1.51 + this.prefix = prefix; 1.52 + this.namespaceName = namespaceName; 1.53 + this.localName = localName; 1.54 + this.qName = qName; 1.55 + this.index = -1; 1.56 + this.prefixIndex = 0; 1.57 + this.namespaceNameIndex = 0; 1.58 + this.localNameIndex = -1; 1.59 + } 1.60 + 1.61 + public void set(String prefix, String namespaceName, String localName, String qName) { 1.62 + this.prefix = prefix; 1.63 + this.namespaceName = namespaceName; 1.64 + this.localName = localName; 1.65 + this.qName = qName; 1.66 + this.index = -1; 1.67 + this.prefixIndex = 0; 1.68 + this.namespaceNameIndex = 0; 1.69 + this.localNameIndex = -1; 1.70 + this.qNameObject = null; 1.71 + } 1.72 + 1.73 + public QualifiedName(String prefix, String namespaceName, String localName, String qName, int index) { 1.74 + this.prefix = prefix; 1.75 + this.namespaceName = namespaceName; 1.76 + this.localName = localName; 1.77 + this.qName = qName; 1.78 + this.index = index; 1.79 + this.prefixIndex = 0; 1.80 + this.namespaceNameIndex = 0; 1.81 + this.localNameIndex = -1; 1.82 + } 1.83 + 1.84 + public final QualifiedName set(String prefix, String namespaceName, String localName, String qName, int index) { 1.85 + this.prefix = prefix; 1.86 + this.namespaceName = namespaceName; 1.87 + this.localName = localName; 1.88 + this.qName = qName; 1.89 + this.index = index; 1.90 + this.prefixIndex = 0; 1.91 + this.namespaceNameIndex = 0; 1.92 + this.localNameIndex = -1; 1.93 + this.qNameObject = null; 1.94 + return this; 1.95 + } 1.96 + 1.97 + public QualifiedName(String prefix, String namespaceName, String localName, String qName, int index, 1.98 + int prefixIndex, int namespaceNameIndex, int localNameIndex) { 1.99 + this.prefix = prefix; 1.100 + this.namespaceName = namespaceName; 1.101 + this.localName = localName; 1.102 + this.qName = qName; 1.103 + this.index = index; 1.104 + this.prefixIndex = prefixIndex + 1; 1.105 + this.namespaceNameIndex = namespaceNameIndex + 1; 1.106 + this.localNameIndex = localNameIndex; 1.107 + } 1.108 + 1.109 + public final QualifiedName set(String prefix, String namespaceName, String localName, String qName, int index, 1.110 + int prefixIndex, int namespaceNameIndex, int localNameIndex) { 1.111 + this.prefix = prefix; 1.112 + this.namespaceName = namespaceName; 1.113 + this.localName = localName; 1.114 + this.qName = qName; 1.115 + this.index = index; 1.116 + this.prefixIndex = prefixIndex + 1; 1.117 + this.namespaceNameIndex = namespaceNameIndex + 1; 1.118 + this.localNameIndex = localNameIndex; 1.119 + this.qNameObject = null; 1.120 + return this; 1.121 + } 1.122 + 1.123 + public QualifiedName(String prefix, String namespaceName, String localName) { 1.124 + this.prefix = prefix; 1.125 + this.namespaceName = namespaceName; 1.126 + this.localName = localName; 1.127 + this.qName = createQNameString(prefix, localName); 1.128 + this.index = -1; 1.129 + this.prefixIndex = 0; 1.130 + this.namespaceNameIndex = 0; 1.131 + this.localNameIndex = -1; 1.132 + } 1.133 + 1.134 + public final QualifiedName set(String prefix, String namespaceName, String localName) { 1.135 + this.prefix = prefix; 1.136 + this.namespaceName = namespaceName; 1.137 + this.localName = localName; 1.138 + this.qName = createQNameString(prefix, localName); 1.139 + this.index = -1; 1.140 + this.prefixIndex = 0; 1.141 + this.namespaceNameIndex = 0; 1.142 + this.localNameIndex = -1; 1.143 + this.qNameObject = null; 1.144 + return this; 1.145 + } 1.146 + 1.147 + public QualifiedName(String prefix, String namespaceName, String localName, 1.148 + int prefixIndex, int namespaceNameIndex, int localNameIndex, 1.149 + char[] charBuffer) { 1.150 + this.prefix = prefix; 1.151 + this.namespaceName = namespaceName; 1.152 + this.localName = localName; 1.153 + 1.154 + if (charBuffer != null) { 1.155 + final int l1 = prefix.length(); 1.156 + final int l2 = localName.length(); 1.157 + final int total = l1 + l2 + 1; 1.158 + if (total < charBuffer.length) { 1.159 + prefix.getChars(0, l1, charBuffer, 0); 1.160 + charBuffer[l1] = ':'; 1.161 + localName.getChars(0, l2, charBuffer, l1 + 1); 1.162 + this.qName = new String(charBuffer, 0, total); 1.163 + } else { 1.164 + this.qName = createQNameString(prefix, localName); 1.165 + } 1.166 + } else { 1.167 + this.qName = this.localName; 1.168 + } 1.169 + 1.170 + this.prefixIndex = prefixIndex + 1; 1.171 + this.namespaceNameIndex = namespaceNameIndex + 1; 1.172 + this.localNameIndex = localNameIndex; 1.173 + this.index = -1; 1.174 + } 1.175 + 1.176 + public final QualifiedName set(String prefix, String namespaceName, String localName, 1.177 + int prefixIndex, int namespaceNameIndex, int localNameIndex, 1.178 + char[] charBuffer) { 1.179 + this.prefix = prefix; 1.180 + this.namespaceName = namespaceName; 1.181 + this.localName = localName; 1.182 + 1.183 + if (charBuffer != null) { 1.184 + final int l1 = prefix.length(); 1.185 + final int l2 = localName.length(); 1.186 + final int total = l1 + l2 + 1; 1.187 + if (total < charBuffer.length) { 1.188 + prefix.getChars(0, l1, charBuffer, 0); 1.189 + charBuffer[l1] = ':'; 1.190 + localName.getChars(0, l2, charBuffer, l1 + 1); 1.191 + this.qName = new String(charBuffer, 0, total); 1.192 + } else { 1.193 + this.qName = createQNameString(prefix, localName); 1.194 + } 1.195 + } else { 1.196 + this.qName = this.localName; 1.197 + } 1.198 + 1.199 + this.prefixIndex = prefixIndex + 1; 1.200 + this.namespaceNameIndex = namespaceNameIndex + 1; 1.201 + this.localNameIndex = localNameIndex; 1.202 + this.index = -1; 1.203 + this.qNameObject = null; 1.204 + return this; 1.205 + } 1.206 + 1.207 + public QualifiedName(String prefix, String namespaceName, String localName, int index) { 1.208 + this.prefix = prefix; 1.209 + this.namespaceName = namespaceName; 1.210 + this.localName = localName; 1.211 + this.qName = createQNameString(prefix, localName); 1.212 + this.index = index; 1.213 + this.prefixIndex = 0; 1.214 + this.namespaceNameIndex = 0; 1.215 + this.localNameIndex = -1; 1.216 + } 1.217 + 1.218 + public final QualifiedName set(String prefix, String namespaceName, String localName, int index) { 1.219 + this.prefix = prefix; 1.220 + this.namespaceName = namespaceName; 1.221 + this.localName = localName; 1.222 + this.qName = createQNameString(prefix, localName); 1.223 + this.index = index; 1.224 + this.prefixIndex = 0; 1.225 + this.namespaceNameIndex = 0; 1.226 + this.localNameIndex = -1; 1.227 + this.qNameObject = null; 1.228 + return this; 1.229 + } 1.230 + 1.231 + public QualifiedName(String prefix, String namespaceName, String localName, int index, 1.232 + int prefixIndex, int namespaceNameIndex, int localNameIndex) { 1.233 + this.prefix = prefix; 1.234 + this.namespaceName = namespaceName; 1.235 + this.localName = localName; 1.236 + this.qName = createQNameString(prefix, localName); 1.237 + this.index = index; 1.238 + this.prefixIndex = prefixIndex + 1; 1.239 + this.namespaceNameIndex = namespaceNameIndex + 1; 1.240 + this.localNameIndex = localNameIndex; 1.241 + } 1.242 + 1.243 + public final QualifiedName set(String prefix, String namespaceName, String localName, int index, 1.244 + int prefixIndex, int namespaceNameIndex, int localNameIndex) { 1.245 + this.prefix = prefix; 1.246 + this.namespaceName = namespaceName; 1.247 + this.localName = localName; 1.248 + this.qName = createQNameString(prefix, localName); 1.249 + this.index = index; 1.250 + this.prefixIndex = prefixIndex + 1; 1.251 + this.namespaceNameIndex = namespaceNameIndex + 1; 1.252 + this.localNameIndex = localNameIndex; 1.253 + this.qNameObject = null; 1.254 + return this; 1.255 + } 1.256 + 1.257 + // Qualified Name as a Namespace Name 1.258 + public QualifiedName(String prefix, String namespaceName) { 1.259 + this.prefix = prefix; 1.260 + this.namespaceName = namespaceName; 1.261 + this.localName = ""; 1.262 + this.qName = ""; 1.263 + this.index = -1; 1.264 + this.prefixIndex = 0; 1.265 + this.namespaceNameIndex = 0; 1.266 + this.localNameIndex = -1; 1.267 + } 1.268 + 1.269 + public final QualifiedName set(String prefix, String namespaceName) { 1.270 + this.prefix = prefix; 1.271 + this.namespaceName = namespaceName; 1.272 + this.localName = ""; 1.273 + this.qName = ""; 1.274 + this.index = -1; 1.275 + this.prefixIndex = 0; 1.276 + this.namespaceNameIndex = 0; 1.277 + this.localNameIndex = -1; 1.278 + this.qNameObject = null; 1.279 + return this; 1.280 + } 1.281 + 1.282 + public final QName getQName() { 1.283 + if (qNameObject == null) { 1.284 + qNameObject = new QName(namespaceName, localName, prefix); 1.285 + } 1.286 + 1.287 + return qNameObject; 1.288 + } 1.289 + 1.290 + public final String getQNameString() { 1.291 + if (this.qName != "") { 1.292 + return this.qName; 1.293 + } 1.294 + 1.295 + return this.qName = createQNameString(prefix, localName); 1.296 + } 1.297 + 1.298 + public final void createAttributeValues(int size) { 1.299 + attributeId = localNameIndex | (namespaceNameIndex << 20); 1.300 + attributeHash = localNameIndex % size; 1.301 + } 1.302 + 1.303 + private final String createQNameString(String p, String l) { 1.304 + if (p != null && p.length() > 0) { 1.305 + final StringBuffer b = new StringBuffer(p); 1.306 + b.append(':'); 1.307 + b.append(l); 1.308 + return b.toString(); 1.309 + } else { 1.310 + return l; 1.311 + } 1.312 + } 1.313 +}