View Javadoc

1   package org.apache.maven.struts;
2   
3   /* ====================================================================
4    *   Copyright 2001-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  /**
21   * A class to hold data about a struts action as found in the struts
22   * configuration file
23   *
24   * @author  dion
25   * @version $Id: Action.java 170200 2005-05-15 06:24:19Z brett $
26   */
27  public class Action extends ObjectConfigurationEntry
28  {
29      /** context relative path of the submitted request */
30      private String path;
31      /** "request" or "session" - scope of the form bean for the action */
32      private String scope;
33      /** Whether the action is to be the default for the web app */
34      private String unknown;
35      /** Whether the form bean should be validated before the action is called */
36      private String validate;
37      
38      /** Creates a new instance of Action */
39      public Action()
40      {
41      }
42      
43      /** Getter for property scope.
44       * @return Value of property scope.
45       */
46      public String getScope()
47      {
48          return scope;
49      }
50      
51      /** Setter for property scope.
52       * @param scope New value of property scope.
53       */
54      public void setScope(String scope)
55      {
56          this.scope = scope;
57      }
58      
59      /** Getter for property unknown.
60       * @return Value of property unknown.
61       */
62      public String getUnknown()
63      {
64          return unknown;
65      }
66      
67      /** Setter for property unknown.
68       * @param unknown New value of property unknown.
69       */
70      public void setUnknown(String unknown)
71      {
72          this.unknown = unknown;
73      }
74      
75      /** Getter for property validate.
76       * @return Value of property validate.
77       */
78      public String getValidate()
79      {
80          return validate;
81      }
82      
83      /** Setter for property validate.
84       * @param validate New value of property validate.
85       */
86      public void setValidate(String validate)
87      {
88          this.validate = validate;
89      }
90      
91      /** Getter for property path.
92       * @return Value of property path.
93       */
94      public String getPath()
95      {
96          return path;
97      }
98      
99      /** Setter for property path.
100      * @param path New value of property path.
101      */
102     public void setPath(String path)
103     {
104         this.path = path;
105     }
106 
107     /** whether the passed object is the same as this one. In the case of an
108      * action object, the path is the unique qualifier. So two objects are equal
109      * if they have equal paths
110      * @param o any object
111      * @return true if o is the same as this object, false otherwise
112      */
113     public boolean equals(Object o)
114     {
115         if (o == null)
116         {
117             return false;
118         }
119         
120         if (getClass() != o.getClass())
121         {
122             return false;
123         }
124         
125         return getPath().equals(((Action) o).getPath());
126     }
127     
128     /** provides the hashCode of this object, which is determined by simply
129      * delegating the responsibility to the <code>path</code> property
130      * @return the hashCode of the name if not null, otherwise delegate to the
131      * parent class
132      */
133     public int hashCode()
134     {
135         if (getPath() != null)
136         {
137             return getPath().hashCode();
138         }
139         else
140         {
141             return super.hashCode();
142         }
143     }
144 
145 }