package org.apache.maven.struts;

/* ====================================================================
 * The Apache Software License, Version 1.1
 *
 * Copyright (c) 2002 The Apache Software Foundation.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Apache" and "Apache Software Foundation" and
 *    "Apache Maven" must not be used to endorse or promote products
 *    derived from this software without prior written permission. For
 *    written permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    "Apache Maven", nor may "Apache" appear in their name, without
 *    prior written permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
 * ====================================================================
 */

/**
 * A class to hold data about a struts action as found in the struts
 * configuration file
 *
 * @author  dion
 * @version $Id: Action.java,v 1.1 2003/01/24 03:45:51 jvanzyl Exp $
 */
public class Action extends ObjectConfigurationEntry
{
    /** context relative path of the submitted request */
    private String path;
    /** "request" or "session" - scope of the form bean for the action */
    private String scope;
    /** Whether the action is to be the default for the web app */
    private String unknown;
    /** Whether the form bean should be validated before the action is called */
    private String validate;
    
    /** Creates a new instance of Action */
    public Action()
    {
    }
    
    /** Getter for property scope.
     * @return Value of property scope.
     */
    public String getScope()
    {
        return scope;
    }
    
    /** Setter for property scope.
     * @param scope New value of property scope.
     */
    public void setScope(String scope)
    {
        this.scope = scope;
    }
    
    /** Getter for property unknown.
     * @return Value of property unknown.
     */
    public String getUnknown()
    {
        return unknown;
    }
    
    /** Setter for property unknown.
     * @param unknown New value of property unknown.
     */
    public void setUnknown(String unknown)
    {
        this.unknown = unknown;
    }
    
    /** Getter for property validate.
     * @return Value of property validate.
     */
    public String getValidate()
    {
        return validate;
    }
    
    /** Setter for property validate.
     * @param validate New value of property validate.
     */
    public void setValidate(String validate)
    {
        this.validate = validate;
    }
    
    /** Getter for property path.
     * @return Value of property path.
     */
    public String getPath()
    {
        return path;
    }
    
    /** Setter for property path.
     * @param path New value of property path.
     */
    public void setPath(String path)
    {
        this.path = path;
    }

    /** whether the passed object is the same as this one. In the case of an
     * action object, the path is the unique qualifier. So two objects are equal
     * if they have equal paths
     * @param o any object
     * @return true if o is the same as this object, false otherwise
     */
    public boolean equals(Object o)
    {
        if (o == null)
        {
            return false;
        }
        
        if (getClass() != o.getClass())
        {
            return false;
        }
        
        return getPath().equals(((Action) o).getPath());
    }
    
    /** provides the hashCode of this object, which is determined by simply
     * delegating the responsibility to the <code>path</code> property
     * @return the hashCode of the name if not null, otherwise delegate to the
     * parent class
     */
    public int hashCode()
    {
        if (getPath() != null)
        {
            return getPath().hashCode();
        }
        else
        {
            return super.hashCode();
        }
    }

}
