4 * Class to encapsulate an XML-style name (either for tagnames,
10 * <li> Namespace aware parsers must supply a local name
12 * <li> Non-namespace aware parsers should supply a local name,
13 * and, if present and applicable, also a prefix
17 public class XMLName {
18 private String namespaceURI;
19 private String localName;
20 private String prefix;
22 public XMLName(String aLocalName) {
23 this(null, null, aLocalName);
26 public XMLName(String aNamespaceURI, String aPrefix, String aLocalName) {
32 localName = aLocalName;
35 if (aNamespaceURI!=null)
36 namespaceURI = aNamespaceURI;
39 public XMLName(String aNamespaceURI, String aLocalName) {
40 this (aNamespaceURI, null, aLocalName);
44 * Returns the namespace URI if available
46 public String getNamespaceURI() {
51 * Returns the name of the tag, stripped from prefix
53 public String getLocalName() {
58 * Returns the prefix of the tag, if present
60 public String getPrefix() {
64 public int hashCode() {
65 if (namespaceURI == null)
66 return localName.hashCode() + 3*prefix.hashCode();
67 return localName.hashCode() + 3*namespaceURI.hashCode();
70 public String toString() {
71 return ((namespaceURI.length()>0)? "["+namespaceURI+"]":"")+((prefix.length()>0)?prefix+":":"")+localName;
74 public boolean equals(Object anObject) {
75 if (anObject instanceof mir.util.xml.XMLName) {
76 if (namespaceURI==null)
77 return (((mir.util.xml.XMLName) anObject).namespaceURI == null) &&
78 prefix.equals(((mir.util.xml.XMLName) anObject).prefix) &&
79 localName.equals(((mir.util.xml.XMLName) anObject).localName);
81 return namespaceURI.equals(((mir.util.xml.XMLName) anObject).namespaceURI) &&
82 localName.equals(((mir.util.xml.XMLName) anObject).localName);