1 57 58 package org.enhydra.apache.xerces.utils; 59 60 66 public class QName { 67 68 72 76 private static final boolean FIND_URI_IS_MINUS_ONE = false; 77 78 82 83 public int prefix; 84 85 86 public int localpart; 87 88 89 public int rawname; 90 91 92 public int uri; 93 94 98 99 public QName() { 100 clear(); 101 } 102 103 104 public QName(int prefix, int localpart, int rawname) { 105 setValues(prefix, localpart, rawname, StringPool.EMPTY_STRING); 106 } 107 108 109 public QName(int prefix, int localpart, int rawname, int uri) { 110 setValues(prefix, localpart, rawname, uri); 111 } 112 113 114 public QName(QName qname) { 115 setValues(qname); 116 } 117 118 122 123 public void setValues(QName qname) { 124 if (FIND_URI_IS_MINUS_ONE) { 125 if (qname.uri == -1) { 126 try { 127 throw new Exception ("uri value is -1 instead of StringPool.EMPTY_STRING (0)"); 128 } 129 catch (Exception e) { 130 e.printStackTrace(System.err); 131 } 132 } 133 } 134 prefix = qname.prefix; 135 localpart = qname.localpart; 136 rawname = qname.rawname; 137 uri = qname.uri; 138 } 139 140 141 public void setValues(int prefix, int localpart, int rawname) { 142 setValues(prefix, localpart, rawname, StringPool.EMPTY_STRING); 143 } 144 145 146 public void setValues(int prefix, int localpart, int rawname, int uri) { 147 if (FIND_URI_IS_MINUS_ONE) { 148 if (uri == -1) { 149 try { 150 throw new Exception ("uri value is -1 instead of StringPool.EMPTY_STRING (0)"); 151 } 152 catch (Exception e) { 153 e.printStackTrace(System.err); 154 } 155 } 156 } 157 this.prefix = prefix; 158 this.localpart = localpart; 159 this.rawname = rawname; 160 this.uri = uri; 161 } 162 163 164 public void clear() { 165 prefix = -1; 166 localpart = -1; 167 rawname = -1; 168 uri = StringPool.EMPTY_STRING; 169 } 170 171 175 176 public boolean equals(Object object) { 177 if (object != null && object instanceof QName) { 178 QName qname = (QName)object; 179 if (uri == StringPool.EMPTY_STRING) { 180 return rawname == qname.rawname; 181 } 182 return localpart == qname.localpart && 183 uri == qname.uri; 184 } 185 return false; 186 } 187 188 189 public int hashCode() { 190 return (localpart << 16) | uri; 191 } 192 193 194 public String toString() { 195 StringBuffer str = new StringBuffer (); 196 str.append("prefix: "); 197 str.append(prefix); 198 str.append(", "); 199 str.append("localpart: "); 200 str.append(localpart); 201 str.append(", "); 202 str.append("rawname: "); 203 str.append(rawname); 204 str.append(", "); 205 str.append("uri: "); 206 str.append(uri); 207 return str.toString(); 208 } 209 210 211 public String toString(StringPool stringPool) { 212 StringBuffer str = new StringBuffer (); 213 str.append("prefix: "); 214 str.append(String.valueOf(stringPool.toString(prefix))); 215 str.append(", "); 216 str.append("localpart: "); 217 str.append(String.valueOf(stringPool.toString(localpart))); 218 str.append(", "); 219 str.append("rawname: "); 220 str.append(String.valueOf(stringPool.toString(rawname))); 221 str.append(", "); 222 str.append("uri: "); 223 str.append(String.valueOf(stringPool.toString(uri))); 224 return str.toString(); 225 } 226 227 } | Popular Tags |