1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.wss4j.policy.model;
20
21 import java.util.Map;
22
23 public class XPath {
24
25 public enum Version {
26 V1("1"),
27 V2("2");
28
29 private final String version;
30
31 Version(String version) {
32 this.version = version;
33 }
34
35 public String getVersion() {
36 return version;
37 }
38 }
39
40 private final String xPath;
41 private final Version version;
42 private final String filter;
43 private final Map<String, String> prefixNamespaceMap;
44
45 public XPath(String xPath, Version version, String filter, Map<String, String> prefixNamespaceMap) {
46 this.xPath = xPath;
47 this.version = version;
48 this.filter = filter;
49 this.prefixNamespaceMap = prefixNamespaceMap;
50 }
51
52 public String getXPath() {
53 return xPath;
54 }
55
56 public Version getVersion() {
57 return version;
58 }
59
60 public String getFilter() {
61 return filter;
62 }
63
64 public Map<String, String> getPrefixNamespaceMap() {
65 return prefixNamespaceMap;
66 }
67
68 @Override
69 public boolean equals(Object object) {
70 if (object == this) {
71 return true;
72 }
73 if (!(object instanceof XPath)) {
74 return false;
75 }
76
77 XPath that = (XPath)object;
78 if (xPath != null && !xPath.equals(that.xPath)
79 || xPath == null && that.xPath != null) {
80 return false;
81 }
82 if (version != that.version) {
83 return false;
84 }
85
86 return !(filter != null && !filter.equals(that.filter)
87 || filter == null && that.filter != null);
88 }
89
90 @Override
91 public int hashCode() {
92 int result = 17;
93 if (xPath != null) {
94 result = 31 * result + xPath.hashCode();
95 }
96 if (version != null) {
97 result = 31 * result + version.hashCode();
98 }
99 if (filter != null) {
100 result = 31 * result + filter.hashCode();
101 }
102
103 return result;
104 }
105 }