1 24 25 package org.apache.webdav.lib.util; 26 27 import org.w3c.dom.Node ; 28 29 32 public class QName 33 { 34 private String namespaceURI; 35 private String localName; 36 private int hashCode; 37 38 public QName(String namespaceURI, String localName) 39 { 40 this.namespaceURI = (namespaceURI == null ? "" : namespaceURI).intern(); 41 this.localName = localName.intern(); 42 43 String hash1 = this.namespaceURI.hashCode() + ""; 44 String hash2 = this.localName.hashCode() + ""; 45 String hash3 = hash1 + '_' + hash2; 46 this.hashCode=hash3.hashCode(); 47 } 48 49 public String getNamespaceURI() 50 { 51 return this.namespaceURI; 52 } 53 54 public String getLocalName() 55 { 56 return this.localName; 57 } 58 59 public int hashCode() 60 { 61 return this.hashCode; 62 } 63 64 public boolean equals(Object obj) 65 { 66 return (obj != null 67 && (obj instanceof QName) 68 && namespaceURI == ((QName)obj).getNamespaceURI() 69 && localName == ((QName)obj).getLocalName()); 70 } 71 72 public boolean matches(Node node) 73 { 74 return (node!=null) 75 && (node.getNamespaceURI()!=null) 76 && (node.getLocalName()!=null) 77 && (node.getNamespaceURI().intern()==this.namespaceURI) 78 && (node.getLocalName().intern()==this.localName); 79 } 80 81 public String toString() 82 { 83 return namespaceURI + ':' + localName; 84 } 85 } 86 | Popular Tags |