1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.jxpath.ri;
18
19 import java.io.Serializable;
20
21
22
23
24
25
26
27
28
29 public class QName implements Serializable {
30 private static final long serialVersionUID = 7616199282015091496L;
31
32 private String prefix;
33 private String name;
34 private String qualifiedName;
35
36
37
38
39
40 public QName(String qualifiedName) {
41 this.qualifiedName = qualifiedName;
42 int index = qualifiedName.indexOf(':');
43 prefix = index < 0 ? null : qualifiedName.substring(0, index);
44 name = index < 0 ? qualifiedName : qualifiedName.substring(index + 1);
45 }
46
47
48
49
50
51
52 public QName(String prefix, String localName) {
53 this.prefix = prefix;
54 this.name = localName;
55 this.qualifiedName = prefix == null ? localName : prefix + ':' + localName;
56 }
57
58
59
60
61
62 public String getPrefix() {
63 return prefix;
64 }
65
66
67
68
69
70 public String getName() {
71 return name;
72 }
73
74 public String toString() {
75 return qualifiedName;
76 }
77
78 public int hashCode() {
79 return name.hashCode();
80 }
81
82 public boolean equals(Object object) {
83 if (this == object) {
84 return true;
85 }
86 if (!(object instanceof QName)) {
87 return false;
88 }
89 return qualifiedName.equals(((QName) object).qualifiedName);
90 }
91 }