View Javadoc

1   /***
2   Copyright (C) 2005 The Java Community
3   
4   This program is free software; you can redistribute it and/or modify  it under
5   the terms of the GNU General Public License as published by  the Free Software
6   Foundation; either version 2 of the License, or  (at your option) any later
7   version.
8   
9   This program is distributed in the hope that it will be useful,  but WITHOUT
10  ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS
11  FOR A PARTICULAR PURPOSE. See the  GNU General Public License for more details.
12  
13  You should have received a copy of the GNU General Public License  along with
14  this program; if not, write to the Free Software  Foundation, Inc., 59 Temple
15  Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17  package org.bejug.javacareers.jobs.model;
18  
19  import java.util.Locale;
20  
21  import org.apache.commons.lang.builder.CompareToBuilder;
22  import org.apache.commons.lang.builder.EqualsBuilder;
23  import org.apache.commons.lang.builder.HashCodeBuilder;
24  import org.apache.commons.lang.builder.ToStringBuilder;
25  
26  
27  /***
28   * 
29   * @author Sven Schauwvliege (Last modified by $Author$)
30   * @version $Revision$ $Date$
31   */
32  public abstract class AbstractParameter extends AbstractPersistableObject {
33      
34      /***
35       * the name of the parameter.
36       */
37      private String name = null;
38  
39      /***
40       * the name of the description.
41       */
42      private String description = null;
43  
44      /***
45       * the locale of this parameter.
46       */
47      private String locale = null;
48  
49      /***
50       * default constructor.
51       */
52      public AbstractParameter() {
53          super();
54      }
55  
56  
57  
58      /***
59       * General constructor.
60       * @param name the name of the parameter.
61       * @param description the description of the parameter.
62       * @param locale the locale of the parameter.
63       */
64      public AbstractParameter(String name, String description, String locale) {
65          super();
66          this.name = name;
67          this.description = description;
68          this.locale = locale;
69      }
70  
71      /***
72       * @return Returns the description.
73       */
74      public String getDescription() {
75          return description;
76      }
77  
78      /***
79       * @param description The description to set.
80       */
81      public void setDescription(String description) {
82          this.description = description;
83      }
84  
85      /***
86       * Set the locale of this parameter.
87       * @param locale a String indicating the locale of this parameter.
88       */
89      public void setLocale(String locale) {
90          this.locale = locale;
91      }
92      
93      /***
94       * @return the locale as a String-object.
95       */
96      public String getLocale() {
97          return locale;
98      }
99      
100     /***
101      * @return Returns the name.
102      */
103     public String getName() {
104         return name;
105     }
106 
107     /***
108      * @param name The name to set.
109      */
110     public void setName(String name) {
111         this.name = name;
112     }
113     
114     /***
115      * @return the locale of this parameter as a locale object.
116      */
117     public Locale getLocaleObject() {
118         //first check if we have something
119         if (locale == null || locale.equals("")) {
120             return Locale.getDefault();
121         }
122         return new Locale(locale.substring(0, 2), locale.substring(3, 5));
123     }
124 
125     
126     /***
127      * {@inheritDoc}
128      */
129     public int compareTo(Object o) {
130         AbstractParameter myClass = (AbstractParameter) o;
131         return new CompareToBuilder()
132           .appendSuper(super.compareTo(o))
133           .append(this.name, myClass.getName())
134           .append(this.description, myClass.getDescription())
135           .append(this.locale, myClass.getLocale())
136           .toComparison();
137     }
138     
139     
140     /***
141      * {@inheritDoc}
142      */
143     public boolean equals(Object o) {
144     	if ( ! (o instanceof AbstractParameter)) {
145     	     return false;
146     	   }
147     	   if (this == o) {
148     	     return true;
149     	   }
150     	   AbstractParameter param = (AbstractParameter) o;
151     	   return new EqualsBuilder()    	  
152     	   		.appendSuper(super.equals(o))
153     	   		.append(this.name, param.getName())
154     	   		.append(this.description, param.getDescription())
155     	   		.append(this.locale, param.getLocale())
156     	        .isEquals();
157     }
158     
159     
160     /***
161      * {@inheritDoc}
162      */
163     public int hashCode() {
164         return new HashCodeBuilder(71, 17)
165 	          .append(this.name)
166 	          .append(this.description)
167 	          .append(this.locale)
168 	          .toHashCode();
169     }
170     
171     
172     /***
173      * {@inheritDoc}
174      */
175     public String toString() {
176     	return new ToStringBuilder(this)
177     		.appendSuper(super.toString())
178     		.append("name", this.name)
179     		.append("description", this.description)
180     		.append("locale", this.locale)    		
181     		.toString();
182     }
183 }
184 /***
185  * 
186  * $Log$
187  * Revision 1.2  2005/12/20 15:36:45  shally
188  * CheckStyle and PMD changes.
189  *
190  * Revision 1.1  2005/08/31 12:15:09  bme_jcs
191  * refactoring and introduction of apache builders
192  *
193  * Revision 1.1  2005/08/26 07:58:25  ge0ffrey
194  * split up the sources in service, serviceimpl and webclient
195  *
196  * Revision 1.5  2005/06/20 15:33:58  psong09
197  * moved boolean editable to AbstrackPersistableObject
198  *
199  * Revision 1.4  2005/06/17 11:42:42  schauwvliege
200  * CheckStyle/ PMD
201  *
202  * Revision 1.3  2005/06/14 13:13:34  psong09
203  * added boolean 'editable'
204  *
205  * Revision 1.2  2005/06/09 08:18:43  bejug_cc
206  * Fix initial import
207  *
208  * Revision 1.6  2005/05/11 17:00:31  sja
209  * Made the class actually abstract.
210  *
211  * Revision 1.5  2005/05/11 16:59:20  sja
212  * Added last modified CVS tag.
213  *
214  * Revision 1.4  2005/05/11 12:49:30  ssc
215  * Checstyle errors
216  *
217  * Revision 1.3  2005/05/11 11:29:32  ssc
218  * Checstyle errors
219  *
220  * Revision 1.2  2005/05/10 13:51:52  bme
221  * added localization support
222  *
223  * Revision 1.1  2005/04/29 12:21:33  bme
224  * first release
225  *
226  * Revision 1.1  2005/04/25 13:25:57  ssc
227  * Add ParameterizedObject
228  *
229  *
230  *
231  */    
232