View Javadoc

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