001: /*
002: * $Id: ActionMapping.java 471756 2006-11-06 15:01:43Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts2.dispatcher.mapper;
022:
023: import java.util.Map;
024:
025: import com.opensymphony.xwork2.Result;
026:
027: /**
028: * Simple class that holds the action mapping information used to invoke a
029: * Struts action. The name and namespace are required, but the params map
030: * is optional, and as such may be null. If a params map is supplied,
031: * it <b>must</b> be a mutable map, such as a HashMap.
032: *
033: */
034: public class ActionMapping {
035:
036: private String name;
037: private String namespace;
038: private String method;
039: private Map params;
040: private Result result;
041:
042: /**
043: * Constructs an ActionMapping
044: */
045: public ActionMapping() {
046: }
047:
048: /**
049: * Constructs an ActionMapping with a default result
050: *
051: * @param result The default result
052: */
053: public ActionMapping(Result result) {
054: this .result = result;
055: }
056:
057: /**
058: * Constructs an ActionMapping with its values
059: *
060: * @param name The action name
061: * @param namespace The action namespace
062: * @param method The method
063: * @param params The extra parameters
064: */
065: public ActionMapping(String name, String namespace, String method,
066: Map params) {
067: this .name = name;
068: this .namespace = namespace;
069: this .method = method;
070: this .params = params;
071: }
072:
073: /**
074: * @return The action name
075: */
076: public String getName() {
077: return name;
078: }
079:
080: /**
081: * @return The action namespace
082: */
083: public String getNamespace() {
084: return namespace;
085: }
086:
087: /**
088: * @return The extra parameters
089: */
090: public Map getParams() {
091: return params;
092: }
093:
094: /**
095: * @return The method
096: */
097: public String getMethod() {
098: if (null != method && "".equals(method)) {
099: 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: * @param result The result
114: */
115: public void setResult(Result result) {
116: this .result = result;
117: }
118:
119: /**
120: * @param name The action name
121: */
122: public void setName(String name) {
123: this .name = name;
124: }
125:
126: /**
127: * @param namespace The action namespace
128: */
129: public void setNamespace(String namespace) {
130: this .namespace = namespace;
131: }
132:
133: /**
134: * @param method The method name to call on the action
135: */
136: public void setMethod(String method) {
137: this .method = method;
138: }
139:
140: /**
141: * @param params The extra parameters for this mapping
142: */
143: public void setParams(Map params) {
144: this.params = params;
145: }
146: }
|