1 38 39 40 package com.sun.xml.fastinfoset; 41 42 import javax.xml.namespace.QName ; 43 44 public class QualifiedName { 45 public final String prefix; 46 public final String namespaceName; 47 public final String localName; 48 public String qName; 49 public final int index; 50 public final int prefixIndex; 51 public final int namespaceNameIndex; 52 public final int localNameIndex; 53 public int attributeId; 54 public int attributeHash; 55 private QName qNameObject; 56 57 public QualifiedName(String prefix, String namespaceName, String localName, String qName) { 58 this.prefix = prefix; 59 this.namespaceName = namespaceName; 60 this.localName = localName; 61 this.qName = qName; 62 this.index = -1; 63 this.prefixIndex = 0; 64 this.namespaceNameIndex = 0; 65 this.localNameIndex = -1; 66 } 67 68 public QualifiedName(String prefix, String namespaceName, String localName, String qName, int index) { 69 this.prefix = prefix; 70 this.namespaceName = namespaceName; 71 this.localName = localName; 72 this.qName = qName; 73 this.index = index; 74 this.prefixIndex = 0; 75 this.namespaceNameIndex = 0; 76 this.localNameIndex = -1; 77 } 78 79 public QualifiedName(String prefix, String namespaceName, String localName, String qName, int index, 80 int prefixIndex, int namespaceNameIndex, int localNameIndex) { 81 this.prefix = prefix; 82 this.namespaceName = namespaceName; 83 this.localName = localName; 84 this.qName = qName; 85 this.index = index; 86 this.prefixIndex = prefixIndex + 1; 87 this.namespaceNameIndex = namespaceNameIndex + 1; 88 this.localNameIndex = localNameIndex; 89 } 90 91 public QualifiedName(String prefix, String namespaceName, String localName) { 92 this.prefix = prefix; 93 this.namespaceName = namespaceName; 94 this.localName = localName; 95 this.qName = createQNameString(prefix, localName); 96 this.index = -1; 97 this.prefixIndex = 0; 98 this.namespaceNameIndex = 0; 99 this.localNameIndex = -1; 100 } 101 102 public QualifiedName(String prefix, String namespaceName, String localName, 103 int prefixIndex, int namespaceNameIndex, int localNameIndex, 104 char[] charBuffer) { 105 this.prefix = prefix; 106 this.namespaceName = namespaceName; 107 this.localName = localName; 108 109 if (charBuffer != null) { 110 final int l1 = prefix.length(); 111 final int l2 = localName.length(); 112 final int total = l1 + l2 + 1; 113 if (total < charBuffer.length) { 114 prefix.getChars(0, l1, charBuffer, 0); 115 charBuffer[l1] = ':'; 116 localName.getChars(0, l2, charBuffer, l1 + 1); 117 this.qName = new String (charBuffer, 0, total); 118 } else { 119 this.qName = createQNameString(prefix, localName); 120 } 121 } else { 122 this.qName = this.localName; 123 } 124 125 this.prefixIndex = prefixIndex + 1; 126 this.namespaceNameIndex = namespaceNameIndex + 1; 127 this.localNameIndex = localNameIndex; 128 this.index = -1; 129 } 130 131 public QualifiedName(String prefix, String namespaceName, String localName, int index) { 132 this.prefix = prefix; 133 this.namespaceName = namespaceName; 134 this.localName = localName; 135 this.qName = createQNameString(prefix, localName); 136 this.index = index; 137 this.prefixIndex = 0; 138 this.namespaceNameIndex = 0; 139 this.localNameIndex = -1; 140 } 141 142 public QualifiedName(String prefix, String namespaceName, String localName, int index, 143 int prefixIndex, int namespaceNameIndex, int localNameIndex) { 144 this.prefix = prefix; 145 this.namespaceName = namespaceName; 146 this.localName = localName; 147 this.qName = createQNameString(prefix, localName); 148 this.index = index; 149 this.prefixIndex = prefixIndex + 1; 150 this.namespaceNameIndex = namespaceNameIndex + 1; 151 this.localNameIndex = localNameIndex; 152 } 153 154 public QualifiedName(String prefix, String namespaceName) { 156 this.prefix = prefix; 157 this.namespaceName = namespaceName; 158 this.localName = ""; 159 this.qName = ""; 160 this.index = -1; 161 this.prefixIndex = 0; 162 this.namespaceNameIndex = 0; 163 this.localNameIndex = -1; 164 } 165 166 public final QName getQName() { 167 if (qNameObject == null) { 168 qNameObject = new QName (namespaceName, localName, prefix); 169 } 170 171 return qNameObject; 172 } 173 174 public final String getQNameString() { 175 if (this.qName != "") { 176 return this.qName; 177 } 178 179 return this.qName = createQNameString(prefix, localName); 180 } 181 182 public final void createAttributeValues(int size) { 183 attributeId = localNameIndex | (namespaceNameIndex << 20); 184 attributeHash = localNameIndex % size; 185 } 186 187 private final String createQNameString(String p, String l) { 188 if (p != null && p != "") { 189 final StringBuffer b = new StringBuffer (p); 190 b.append(':'); 191 b.append(l); 192 return b.toString(); 193 } else { 194 return l; 195 } 196 } 197 } 198 | Popular Tags |