1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.http.pathmap;
20
21
22
23
24 public abstract class PathSpec implements Comparable<PathSpec>
25 {
26 protected String pathSpec;
27 protected PathSpecGroup group;
28 protected int pathDepth;
29 protected int specLength;
30
31 @Override
32 public int compareTo(PathSpec other)
33 {
34
35 int diff = this.group.ordinal() - other.group.ordinal();
36 if (diff != 0)
37 {
38 return diff;
39 }
40
41
42 diff = other.specLength - this.specLength;
43 if (diff != 0)
44 {
45 return diff;
46 }
47
48
49 return this.pathSpec.compareTo(other.pathSpec);
50 }
51
52 @Override
53 public boolean equals(Object obj)
54 {
55 if (this == obj)
56 {
57 return true;
58 }
59 if (obj == null)
60 {
61 return false;
62 }
63 if (getClass() != obj.getClass())
64 {
65 return false;
66 }
67 PathSpec other = (PathSpec)obj;
68 if (pathSpec == null)
69 {
70 if (other.pathSpec != null)
71 {
72 return false;
73 }
74 }
75 else if (!pathSpec.equals(other.pathSpec))
76 {
77 return false;
78 }
79 return true;
80 }
81
82 public PathSpecGroup getGroup()
83 {
84 return group;
85 }
86
87
88
89
90
91
92
93
94 public int getPathDepth()
95 {
96 return pathDepth;
97 }
98
99
100
101
102
103
104
105
106 public abstract String getPathInfo(String path);
107
108
109
110
111
112
113
114
115 public abstract String getPathMatch(String path);
116
117
118
119
120
121
122 public String getDeclaration()
123 {
124 return pathSpec;
125 }
126
127
128
129
130
131
132
133
134
135
136 public abstract String getRelativePath(String base, String path);
137
138 @Override
139 public int hashCode()
140 {
141 final int prime = 31;
142 int result = 1;
143 result = (prime * result) + ((pathSpec == null)?0:pathSpec.hashCode());
144 return result;
145 }
146
147
148
149
150
151
152
153
154 public abstract boolean matches(String path);
155
156 @Override
157 public String toString()
158 {
159 StringBuilder str = new StringBuilder();
160 str.append(this.getClass().getSimpleName()).append("[\"");
161 str.append(pathSpec);
162 str.append("\",pathDepth=").append(pathDepth);
163 str.append(",group=").append(group);
164 str.append("]");
165 return str.toString();
166 }
167 }