View Javadoc

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