1 /*
2 * $Id$
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.struts.scripting;
23
24 import org.apache.struts.action.ActionForm;
25 import org.apache.struts.action.ActionForward;
26 import org.apache.struts.action.ActionMapping;
27 import org.apache.struts.util.MessageResources;
28
29
30 /**
31 * Holds Struts objects.
32 */
33 public class StrutsInfo {
34
35 /** Forward name. */
36 private String forwardName = null;
37
38 /** Forward object. */
39 private ActionForward forward = null;
40
41 /** ActionForm for this request. */
42 private ActionForm form = null;
43
44 /** ActionMapping for this request. */
45 private ActionMapping mapping = null;
46
47 /** ScriptAction instance for this request. */
48 private ScriptAction action = null;
49
50 /** The message resources for this request. */
51 private MessageResources res = null;
52
53 /**
54 * Constructor.
55 *
56 * @param action The action instance
57 * @param mapping The action mapping
58 * @param form The action form
59 * @param res The message resources for the current locale
60 */
61 public StrutsInfo(ScriptAction action, ActionMapping mapping,
62 ActionForm form, MessageResources res) {
63 this.action = action;
64 this.mapping = mapping;
65 this.form = form;
66 this.res = res;
67 }
68
69 /**
70 * Sets the forward name.
71 *
72 * @param f The forward name
73 */
74 public void setForwardName(String f) {
75 forwardName = f;
76 }
77
78 /**
79 * Gets the forward object. If none is set, it tries to find the set
80 * forward name.
81 *
82 * @return The action forward
83 */
84 public ActionForward getForward() {
85 if (forward == null) {
86 if (forwardName != null) {
87 return mapping.findForward(forwardName);
88 }
89 }
90 return forward;
91 }
92
93 /**
94 * Sets the action forward object.
95 *
96 * @param f The action forward
97 */
98 public void setForward(ActionForward f) {
99 forward = f;
100 }
101
102 /**
103 * Sets the action form.
104 *
105 * @param form The action form
106 */
107 public void setForm(ActionForm form) {
108 this.form = form;
109 }
110
111 /**
112 * Sets the action mapping.
113 *
114 * @param mapping The action mapping
115 */
116 public void setMapping(ActionMapping mapping) {
117 this.mapping = mapping;
118 }
119
120 /**
121 * Sets the action instance.
122 *
123 * @param action The Struts action
124 */
125 public void setAction(ScriptAction action) {
126 this.action = action;
127 }
128
129 /**
130 * Sets the message resources.
131 *
132 * @param res The message resources
133 */
134 public void setMessages(MessageResources res) {
135 this.res = res;
136 }
137
138 /**
139 * Gets the action form.
140 *
141 * @return The action form
142 */
143 public ActionForm getForm() {
144 return form;
145 }
146
147 /**
148 * Gets the action mapping.
149 *
150 * @return The action mapping
151 */
152 public ActionMapping getMapping() {
153 return mapping;
154 }
155
156 /**
157 * Gets the action instance.
158 *
159 * @return The Struts action
160 */
161 public ScriptAction getAction() {
162 return action;
163 }
164
165 /**
166 * Gets the message resources.
167 *
168 * @return The message resources
169 */
170 public MessageResources getMessages() {
171 return res;
172 }
173 }