1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts2.dispatcher.mapper;
23
24 import java.util.Map;
25
26 import com.opensymphony.xwork2.Result;
27
28 /***
29 * Simple class that holds the action mapping information used to invoke a
30 * Struts action. The name and namespace are required, but the params map
31 * is optional, and as such may be null. If a params map is supplied,
32 * it <b>must</b> be a mutable map, such as a HashMap.
33 *
34 */
35 public class ActionMapping {
36
37 private String name;
38 private String namespace;
39 private String method;
40 private String extension;
41 private Map<String, Object> params;
42 private Result result;
43
44 /***
45 * Constructs an ActionMapping
46 */
47 public ActionMapping() {}
48
49 /***
50 * Constructs an ActionMapping with a default result
51 *
52 * @param result The default result
53 */
54 public ActionMapping(Result result) {
55 this.result = result;
56 }
57
58 /***
59 * Constructs an ActionMapping with its values
60 *
61 * @param name The action name
62 * @param namespace The action namespace
63 * @param method The method
64 * @param params The extra parameters
65 */
66 public ActionMapping(String name, String namespace, String method, Map<String, Object> params) {
67 this.name = name;
68 this.namespace = namespace;
69 this.method = method;
70 this.params = params;
71 }
72
73 /***
74 * @return The action name
75 */
76 public String getName() {
77 return name;
78 }
79
80 /***
81 * @return The action namespace
82 */
83 public String getNamespace() {
84 return namespace;
85 }
86
87 /***
88 * @return The extra parameters
89 */
90 public Map<String, Object> getParams() {
91 return params;
92 }
93
94 /***
95 * @return The method
96 */
97 public String getMethod() {
98 if (null != method && "".equals(method)) {
99 return null;
100 } else {
101 return method;
102 }
103 }
104
105 /***
106 * @return The default result
107 */
108 public Result getResult() {
109 return result;
110 }
111
112 /***
113 * @return The extension used during this request
114 */
115 public String getExtension() {
116 return extension;
117 }
118
119 /***
120 * @param result The result
121 */
122 public void setResult(Result result) {
123 this.result = result;
124 }
125
126 /***
127 * @param name The action name
128 */
129 public void setName(String name) {
130 this.name = name;
131 }
132
133 /***
134 * @param namespace The action namespace
135 */
136 public void setNamespace(String namespace) {
137 this.namespace = namespace;
138 }
139
140 /***
141 * @param method The method name to call on the action
142 */
143 public void setMethod(String method) {
144 this.method = method;
145 }
146
147 /***
148 * @param params The extra parameters for this mapping
149 */
150 public void setParams(Map<String, Object> params) {
151 this.params = params;
152 }
153
154 /***
155 * @param extension The extension used in the request
156 */
157 public void setExtension(String extension) {
158 this.extension = extension;
159 }
160 }