1 16 17 package org.apache.xerces.xni; 18 19 33 public class QName 34 implements Cloneable { 35 36 40 44 public String prefix; 45 46 50 public String localpart; 51 52 56 public String rawname; 57 58 62 public String uri; 63 64 68 69 public QName() { 70 clear(); 71 } 73 74 public QName(String prefix, String localpart, String rawname, String uri) { 75 setValues(prefix, localpart, rawname, uri); 76 } 78 79 public QName(QName qname) { 80 setValues(qname); 81 } 83 87 92 public void setValues(QName qname) { 93 prefix = qname.prefix; 94 localpart = qname.localpart; 95 rawname = qname.rawname; 96 uri = qname.uri; 97 } 99 107 public void setValues(String prefix, String localpart, String rawname, 108 String uri) { 109 this.prefix = prefix; 110 this.localpart = localpart; 111 this.rawname = rawname; 112 this.uri = uri; 113 } 115 116 public void clear() { 117 prefix = null; 118 localpart = null; 119 rawname = null; 120 uri = null; 121 } 123 127 128 public Object clone() { 129 return new QName(this); 130 } 132 136 137 public int hashCode() { 138 if (uri != null) { 139 return uri.hashCode() + 140 ((localpart != null) ? localpart.hashCode() : 0); 141 } 142 return (rawname != null) ? rawname.hashCode() : 0; 143 } 145 146 public boolean equals(Object object) { 147 if (object instanceof QName) { 148 QName qname = (QName)object; 149 if (qname.uri != null) { 150 return uri == qname.uri && localpart == qname.localpart; 151 } 152 else if (uri == null) { 153 return rawname == qname.rawname; 154 } 155 } 157 return false; 158 } 160 161 public String toString() { 162 163 StringBuffer str = new StringBuffer (); 164 boolean comma = false; 165 if (prefix != null) { 166 str.append("prefix=\""+prefix+'"'); 167 comma = true; 168 } 169 if (localpart != null) { 170 if (comma) { 171 str.append(','); 172 } 173 str.append("localpart=\""+localpart+'"'); 174 comma = true; 175 } 176 if (rawname != null) { 177 if (comma) { 178 str.append(','); 179 } 180 str.append("rawname=\""+rawname+'"'); 181 comma = true; 182 } 183 if (uri != null) { 184 if (comma) { 185 str.append(','); 186 } 187 str.append("uri=\""+uri+'"'); 188 } 189 return str.toString(); 190 191 } 193 } | Popular Tags |