/*
 * $Header: /home/cvs/struts/xdocs/struts1.2/documentation/ja/src/share/org/apache/struts/action/ActionMapping.java,v 1.4 2005/03/12 12:59:29 tatakaha Exp $
 * $Revision: 1.4 $
 * $Date: 2005/03/12 12:59:29 $
 *
 * Copyright 2000-2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


package org.apache.struts.action;


import java.util.ArrayList;

import org.apache.struts.config.ActionConfig;
import org.apache.struts.config.ForwardConfig;


/**
 * <p>コントローラの<code>RequestProcessor</code>が知っている、
 * <code>Action</code>クラスのインスタンスとリクエストのマッピング情報を、
 * <strong>ActionMapping</strong>は表わします。
 * <code>Action</code>を選択するために使用した<code>ActionMapping</code>のインスタンスは、
 * 選択した<code>Action</code>に渡されますので、
 * <code>ActionMapping</code>オブジェクトに含まれている任意のカスタム情報にアクセスすることができます。</p>
 * {@primary <p>An <strong>ActionMapping</strong> represents the information that the
 * controller, <code>RequestProcessor</code>, knows about the mapping
 * of a particular request to an instance of a particular <code>Action</code> class.
 * The <code>ActionMapping</code> instance used to select a particular
 * <code>Action</code> is passed on to that <code>Action</code>, thereby providing
 * access to any custom configuration information included with the
 * <code>ActionMapping</code> object.</p>}
 *
 * <p>Struts 1.1からこのクラスは<code>ActionConfig</code>を拡張しています。</P>
 * {@primary <p>Since Struts 1.1 this class extends <code>ActionConfig</code>.}
 *
 * <p><strong>注意</strong> - 
 * このクラスが既存アプリケーションが使用している公開APIの一部であるという事実がなければ、
 * このクラスの使用は推奨されずに<code>org.apache.struts.config.ActionConfig</code>に置き換えられていたでしょう。</p>
 * {@primary <p><strong>NOTE</strong> - This class would have been deprecated and
 * replaced by <code>org.apache.struts.config.ActionConfig</code> except
 * for the fact that it is part of the public API that existing applications
 * are using.</p>}
 *
 * @version $Revision: 1.4 $ $Date: 2005/03/12 12:59:29 $
 * @translator おかだひでひさ
 * @translator 横田 健彦
 * @translator 棚澤 昌幸
 * @editor
 * @update 2005/3/12
 * @status firstdraft
 * @memo ブロックA
 */

public class ActionMapping extends ActionConfig {



    /**
     * <p>指定された論理名へのフォワードがどのように扱われるべきかを定義している、
     * <code>ForwardConfig</code>インスタンスを探して返します。
     * このメソッドは指定されたフォワードの設定のためにローカルな設定をチェックし次にグローバルな設置をチェックします。
     * フォワードの設定を見つけることができなかった場合、
     * <code>null</code>を返します。</p>
     * {@primary <p>Find and return the <code>ForwardConfig</code> instance defining
     * how forwarding to the specified logical name should be handled. This is
     * performed by checking local and then global configurations for the
     * specified forwarding configuration. If no forwarding configuration
     * can be found, return <code>null</code>.</p>}
     *
     * @param name 返されるフォワードインスタンスの論理名
     * {@primary @param name Logical name of the forwarding instance to be returned}
     */
    public ActionForward findForward(String name) {

        ForwardConfig config = findForwardConfig(name);
        if (config == null) {
            config = getModuleConfig().findForwardConfig(name);
        }
        return ((ActionForward) config);

    }


    /**
     * <p>このマッピングに定義された全てのローカルフォワードの論理名を返します。
     * 定義されたフォワードが一つもない場合、
     * 長さ0の配列を返します。</p>
     * {@primary <p>Return the logical names of all locally defined forwards for this
     * mapping. If there are no such forwards, a zero-length array
     * is returned.</p>}
     */
    public String[] findForwards() {

        ArrayList results = new ArrayList();
        ForwardConfig fcs[] = findForwardConfigs();
        for (int i = 0; i < fcs.length; i++) {
            results.add(fcs[i].getName());
        }
        return ((String[]) results.toArray(new String[results.size()]));

    }


    /**
     * <p>このアクションの<code>input</code>プロパティに対応する{@link ActionForward}を、
     * (必要に応じて)生成して返します。</p>
     * {@primary <p>Create (if necessary) and return an {@link ActionForward} that
     * corresponds to the <code>input</code> property of this Action.</p>}
     *
     * @since Struts 1.1
     */
    public ActionForward getInputForward() {

        if (getModuleConfig().getControllerConfig().getInputForward()) {
            return (findForward(getInput()));
        } else {
            return (new ActionForward(getInput()));
        }

    }


}
