1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.servlet;
20
21 import java.io.IOException;
22 import java.util.Arrays;
23
24 import org.eclipse.jetty.util.annotation.ManagedAttribute;
25 import org.eclipse.jetty.util.annotation.ManagedObject;
26
27 @ManagedObject("Servlet Mapping")
28 public class ServletMapping
29 {
30 private String[] _pathSpecs;
31 private String _servletName;
32 private boolean _default;
33
34
35
36 public ServletMapping()
37 {
38 }
39
40
41
42
43
44 @ManagedAttribute(value="url patterns", readonly=true)
45 public String[] getPathSpecs()
46 {
47 return _pathSpecs;
48 }
49
50
51
52
53
54 @ManagedAttribute(value="servlet name", readonly=true)
55 public String getServletName()
56 {
57 return _servletName;
58 }
59
60
61
62
63
64 public void setPathSpecs(String[] pathSpecs)
65 {
66 _pathSpecs = pathSpecs;
67 }
68
69
70
71
72
73
74
75 public boolean containsPathSpec (String pathSpec)
76 {
77 if (_pathSpecs == null || _pathSpecs.length == 0)
78 return false;
79
80 for (String p:_pathSpecs)
81 {
82 if (p.equals(pathSpec))
83 return true;
84 }
85 return false;
86 }
87
88
89
90
91
92 public void setPathSpec(String pathSpec)
93 {
94 _pathSpecs = new String[]{pathSpec};
95 }
96
97
98
99
100
101 public void setServletName(String servletName)
102 {
103 _servletName = servletName;
104 }
105
106
107
108 @ManagedAttribute(value="default", readonly=true)
109 public boolean isDefault()
110 {
111 return _default;
112 }
113
114
115
116 public void setDefault(boolean fromDefault)
117 {
118 _default = fromDefault;
119 }
120
121
122 public String toString()
123 {
124 return (_pathSpecs==null?"[]":Arrays.asList(_pathSpecs).toString())+"=>"+_servletName;
125 }
126
127
128 public void dump(Appendable out, String indent) throws IOException
129 {
130 out.append(String.valueOf(this)).append("\n");
131 }
132 }