1 16 package org.apache.commons.jxpath.ri; 17 18 19 26 public class QName { 27 private String prefix; 28 private String name; 29 30 public QName(String qualifiedName) { 31 int index = qualifiedName.indexOf(':'); 32 if (index == -1) { 33 prefix = null; 34 name = qualifiedName; 35 } 36 else { 37 prefix = qualifiedName.substring(0, index); 38 name = qualifiedName.substring(index + 1); 39 } 40 } 41 42 public QName(String prefix, String localName) { 43 this.prefix = prefix; 44 this.name = localName; 45 } 46 47 public String getPrefix() { 48 return prefix; 49 } 50 51 public String getName() { 52 return name; 53 } 54 55 public String toString() { 56 if (prefix != null) { 57 return prefix + ':' + name; 58 } 59 return name; 60 } 61 62 public int hashCode() { 63 return name.hashCode(); 64 } 65 66 public boolean equals(Object object) { 67 if (!(object instanceof QName)) { 68 return false; 69 } 70 if (this == object) { 71 return true; 72 } 73 QName that = (QName) object; 74 if (!this.name.equals(that.name)) { 75 return false; 76 } 77 78 if ((this.prefix == null && that.prefix != null) 79 || (this.prefix != null && !this.prefix.equals(that.prefix))) { 80 return false; 81 } 82 83 return true; 84 } 85 } | Popular Tags |