View Javadoc
1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements. See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership. The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License. You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied. See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
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 }