1 22 23 package org.xquark.schema.datatypes; 24 25 26 public class QName { 27 28 private String namespaceURI; 29 private String localName; 30 31 public QName(String local) { 32 this(null, local); 33 } 34 35 public QName(String uri, String local) { 36 namespaceURI = uri; 37 localName = local; 38 } 39 40 public boolean equals(Object obj) { 41 if (this == obj) return true; 42 if (!checkClass(obj)) return false; 43 QName qname = (QName)obj; 44 return (namespaceURI == null ? qname.namespaceURI == null : namespaceURI.equals(qname.namespaceURI)) 45 && localName.equals(qname.localName); 46 } 47 48 protected boolean checkClass(Object obj) { 49 return obj instanceof QName; 50 } 51 52 public int hashCode() { 53 return (namespaceURI == null ? 0 : namespaceURI.hashCode()) ^ localName.hashCode(); 54 } 55 56 public String getNamespaceURI() { 57 return namespaceURI; 58 } 59 60 public String getLocalName() { 61 return localName; 62 } 63 64 public String toString() { 65 if (namespaceURI == null) return localName; 66 else return "{"+namespaceURI+"}"+localName; 67 } 68 } 69 | Popular Tags |