1 57 58 package com.sun.org.apache.xerces.internal.xni; 59 60 74 public class QName 75 implements Cloneable { 76 77 81 85 public String prefix; 86 87 91 public String localpart; 92 93 97 public String rawname; 98 99 103 public String uri; 104 105 109 110 public QName() { 111 clear(); 112 } 114 115 public QName(String prefix, String localpart, String rawname, String uri) { 116 setValues(prefix, localpart, rawname, uri); 117 } 119 120 public QName(QName qname) { 121 setValues(qname); 122 } 124 128 133 public void setValues(QName qname) { 134 prefix = qname.prefix; 135 localpart = qname.localpart; 136 rawname = qname.rawname; 137 uri = qname.uri; 138 } 140 148 public void setValues(String prefix, String localpart, String rawname, 149 String uri) { 150 this.prefix = prefix; 151 this.localpart = localpart; 152 this.rawname = rawname; 153 this.uri = uri; 154 } 156 157 public void clear() { 158 prefix = null; 159 localpart = null; 160 rawname = null; 161 uri = null; 162 } 164 168 169 public Object clone() { 170 return new QName(this); 171 } 173 177 178 public int hashCode() { 179 if (uri != null) { 180 return uri.hashCode() + localpart.hashCode(); 181 } 182 return rawname.hashCode(); 183 } 185 186 public boolean equals(Object object) { 187 if (object instanceof QName) { 188 QName qname = (QName)object; 189 if (qname.uri != null) { 190 return uri == qname.uri && localpart == qname.localpart; 191 } 192 else if (uri == null) { 193 return rawname == qname.rawname; 194 } 195 } 197 return false; 198 } 200 201 public String toString() { 202 203 StringBuffer str = new StringBuffer (); 204 boolean comma = false; 205 if (prefix != null) { 206 str.append("prefix=\""+prefix+'"'); 207 comma = true; 208 } 209 if (localpart != null) { 210 if (comma) { 211 str.append(','); 212 } 213 str.append("localpart=\""+localpart+'"'); 214 comma = true; 215 } 216 if (rawname != null) { 217 if (comma) { 218 str.append(','); 219 } 220 str.append("rawname=\""+rawname+'"'); 221 comma = true; 222 } 223 if (uri != null) { 224 if (comma) { 225 str.append(','); 226 } 227 str.append("uri=\""+uri+'"'); 228 } 229 return str.toString(); 230 231 } 233 } | Popular Tags |