1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.xolite;
17
18
19
20
21
22
23
24 public class NamespacedName {
25
26
27 private String uri;
28 private String name;
29
30
31 public NamespacedName(String namespaceUri, String localName) {
32 uri = (namespaceUri == null) ? "" : namespaceUri;
33 name = localName;
34 }
35
36
37 public String getNamespaceUri() {
38 return uri;
39 }
40
41
42 public String getLocalName() {
43 return name;
44 }
45
46
47 public String toString() {
48 return uri + ":" + name;
49 }
50
51
52 public boolean equals(Object obj) {
53 if (obj == null) return false;
54 if (getClass() != obj.getClass()) return false;
55 NamespacedName qName = (NamespacedName) obj;
56 if (!name.equals(qName.name)) return false;
57 if (uri == null) {
58 if (qName.uri != null) return false;
59 } else {
60 if (!uri.equals(qName.uri)) return false;
61 }
62 return true;
63 }
64
65
66 public int hashCode() {
67 int uriHash = (uri == null) ? 999 : uri.hashCode();
68 int nameHash = (name == null) ? 777 : name.hashCode();
69 return (uriHash << 15) + nameHash;
70 }
71
72
73 }