Source code: com/clra/web/ValidateMemberAccountYear.java
1 /*
2 * Copyright (c) Carnegie Lake Rowing Association 2002. All rights reserved.
3 * Distributed under the GPL license. See doc/COPYING.
4 * $RCSfile: ValidateMemberAccountYear.java,v $
5 * $Date: 2003/02/26 03:38:46 $
6 * $Revision: 1.3 $
7 */
8
9 package com.clra.web;
10
11 import java.util.Calendar;
12 import org.apache.struts.action.ActionError;
13 import org.apache.struts.action.ActionErrors;
14
15 /**
16 * Checks whether the year a member joined the rowing association is reasonable.
17 *
18 * @version $Id: ValidateMemberAccountYear.java,v 1.3 2003/02/26 03:38:46 rphall Exp $
19 * @author <a href="mailto:rphall@pluto.njcc.com">Rick Hall</a>
20 */
21 class ValidateMemberAccountYear extends ValidateMember {
22
23 public final static String PROPERTY_ACCOUNTYEAR = "accountYear";
24
25 public final int FIRST_YEAR =
26 Integer.parseInt( Configuration.ACCOUNT_FIRSTYEAR );
27
28 // This static definition means the app has to be restarted at least
29 // once per year. Seems eminently reasonable.
30 public final int THIS_YEAR = Calendar.getInstance().get( Calendar.YEAR );
31
32 public final String STR_THIS_YEAR = "" + THIS_YEAR;
33
34 ValidateMemberAccountYear( MemberInfoForm f ) {
35 super( f );
36 }
37
38 /**
39 * Checks whether the year a member joined the rowing association
40 * is reasonable.
41 */
42 void validate( ActionErrors errors ) {
43 if ( errors == null ) {
44 throw new IllegalArgumentException( "null action errors" );
45 }
46 final int accountYear = form.getAccountYear();
47 if ( accountYear < FIRST_YEAR ) {
48 ActionError ae =
49 new ActionError( "validate.member.accountYear.lowYear" );
50 errors.add( PROPERTY_ACCOUNTYEAR, ae );
51 }
52 else if ( THIS_YEAR < accountYear ) {
53 String strThisYear = "" + STR_THIS_YEAR;
54 ActionError ae =
55 new ActionError( "validate.member.accountYear.lowYear", strThisYear );
56 errors.add( PROPERTY_ACCOUNTYEAR, ae );
57 }
58 return;
59 } // validate(ActionErrors)
60
61 } // ValidateMemberAccountYear
62
63 /*
64 * $Log: ValidateMemberAccountYear.java,v $
65 * Revision 1.3 2003/02/26 03:38:46 rphall
66 * Added copyright and GPL license
67 *
68 * Revision 1.2 2003/02/20 04:35:13 rphall
69 * Removed gratuitous use of CLRA acronym
70 *
71 * Revision 1.1 2003/02/19 20:45:11 rphall
72 * Moved to ValidateMemberAccountYear
73 *
74 * Revision 1.2 2003/02/19 03:24:22 rphall
75 * Implemented validation
76 *
77 * Revision 1.1 2003/02/11 21:13:15 rphall
78 * Separate class for specific validation task; stubbed implementation
79 *
80 */
81