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