Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/apache/struts/action/ActionMapping.java


1   /*
2    * $Id: ActionMapping.java 54929 2004-10-16 16:38:42Z germuska $ 
3    *
4    * Copyright 2000-2004 The Apache Software Foundation.
5    * 
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    * 
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   * 
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  
20  package org.apache.struts.action;
21  
22  
23  import java.util.ArrayList;
24  
25  import org.apache.struts.config.ActionConfig;
26  import org.apache.struts.config.ForwardConfig;
27  
28  
29  /**
30   * <p>An <strong>ActionMapping</strong> represents the information that the
31   * controller, <code>RequestProcessor</code>, knows about the mapping
32   * of a particular request to an instance of a particular <code>Action</code> class.
33   * The <code>ActionMapping</code> instance used to select a particular
34   * <code>Action</code> is passed on to that <code>Action</code>, thereby providing
35   * access to any custom configuration information included with the
36   * <code>ActionMapping</code> object.</p>
37   *
38   * <p>Since Struts 1.1 this class extends <code>ActionConfig</code>.
39   *
40   * <p><strong>NOTE</strong> - This class would have been deprecated and
41   * replaced by <code>org.apache.struts.config.ActionConfig</code> except
42   * for the fact that it is part of the public API that existing applications
43   * are using.</p>
44   *
45   * @version $Rev: 54929 $ $Date: 2004-10-16 09:38:42 -0700 (Sat, 16 Oct 2004) $
46   */
47  
48  public class ActionMapping extends ActionConfig {
49  
50  
51  
52      /**
53       * <p>Find and return the <code>ForwardConfig</code> instance defining
54       * how forwarding to the specified logical name should be handled. This is
55       * performed by checking local and then global configurations for the
56       * specified forwarding configuration. If no forwarding configuration
57       * can be found, return <code>null</code>.</p>
58       *
59       * @param name Logical name of the forwarding instance to be returned
60       */
61      public ActionForward findForward(String name) {
62  
63          ForwardConfig config = findForwardConfig(name);
64          if (config == null) {
65              config = getModuleConfig().findForwardConfig(name);
66          }
67          return ((ActionForward) config);
68  
69      }
70  
71  
72      /**
73       * <p>Return the logical names of all locally defined forwards for this
74       * mapping. If there are no such forwards, a zero-length array
75       * is returned.</p>
76       */
77      public String[] findForwards() {
78  
79          ArrayList results = new ArrayList();
80          ForwardConfig fcs[] = findForwardConfigs();
81          for (int i = 0; i < fcs.length; i++) {
82              results.add(fcs[i].getName());
83          }
84          return ((String[]) results.toArray(new String[results.size()]));
85  
86      }
87  
88  
89      /**
90       * <p>Create (if necessary) and return an {@link ActionForward} that
91       * corresponds to the <code>input</code> property of this Action.</p>
92       *
93       * @since Struts 1.1
94       */
95      public ActionForward getInputForward() {
96  
97          if (getModuleConfig().getControllerConfig().getInputForward()) {
98              return (findForward(getInput()));
99          } else {
100             return (new ActionForward(getInput()));
101         }
102 
103     }
104 
105 
106 }