Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/clra/rowing/Attendance.java


1   /*
2    * Copyright (c) Carnegie Lake Rowing Association 2002. All rights reserved.
3    * Distributed under the GPL license. See doc/COPYING.
4    * $RCSfile: Attendance.java,v $
5    * $Date: 2003/02/26 03:38:45 $
6    * $Revision: 1.3 $
7    */
8   
9   package com.clra.rowing;
10  
11  import java.io.Serializable;
12  
13  /**
14   * Defines the possible attendance values for a participant in a rowing
15   * session.
16   *
17   * @version $Id: Attendance.java,v 1.3 2003/02/26 03:38:45 rphall Exp $
18   * @author <a href="mailto:rphall@pluto.njcc.com">Rick Hall</a>
19   */
20  public class Attendance implements Serializable {
21  
22    /**
23     * Indicates that a participant showed up for a practice, regardless of
24     * whether participant was a signup, a substitute, or an extra.
25     */
26    public final static String NAME_PRESENT = "PRESENT";
27  
28    /**
29     * Indicates that a signed-up participant did not show up for a practice,
30     * but either was not assigned, or was assigned but found a substitute.
31     */
32    public final static String NAME_ABSENT = "ABSENT";
33  
34    public final static Attendance PRESENT = new Attendance( NAME_PRESENT );
35  
36    public final static Attendance ABSENT = new Attendance( NAME_ABSENT );
37  
38    private final String name;
39  
40    protected Attendance( String name ) {
41  
42      // Assign blank final
43      this.name = name;
44  
45      // Enforce preconditions
46    }
47  
48    /**
49     * Attendance is not a required field in a participant record, therefore
50     * if a null or blank name is passed to this method, an
51     * IllegalArgumentException is <strong>NOT</strong> thrown,
52     * but rather a null instance is returned.
53     * </p><p>
54     * Note: values not defined by this class, will throw a RowingException.
55     */
56    public static Attendance getAttendance( String name )
57      throws RowingException {
58  
59      Attendance retVal = null;
60      if ( name != null && name.trim().length() != 0 ) {
61        name = name.trim();
62        if ( name.equalsIgnoreCase( NAME_PRESENT ) ) {
63          retVal = PRESENT;
64        }
65        else if ( name.equalsIgnoreCase( NAME_ABSENT ) ) {
66          retVal = ABSENT;
67        }
68        else {
69          throw new RowingException( "invalid name == '" + name + "'" );
70        }
71      }
72  
73      return retVal;
74    } // getAttendance(String)
75  
76    public String getName() {
77      return name;
78    }
79  
80    public String toString() {
81      return name;
82    }
83  
84    public int hashCode() {
85      return this.getName().hashCode();
86    }
87  
88    public boolean equals( Object o ) {
89  
90      boolean retVal = false;
91      if ( o instanceof Attendance ) {
92        retVal = this.getName().equalsIgnoreCase( ((Attendance)o).getName() );
93      }
94  
95      return retVal;
96    } // equals(Object)
97  
98  } // Attendance
99  
100 /*
101  * $Log: Attendance.java,v $
102  * Revision 1.3  2003/02/26 03:38:45  rphall
103  * Added copyright and GPL license
104  *
105  * Revision 1.2  2002/02/18 18:03:42  rphall
106  * Ran dos2unix to remove ^M (carriage return) from end of lines
107  *
108  * Revision 1.1.1.1  2002/01/03 21:57:28  rphall
109  * Initial load, 5th try, Jan-03-2002 4:57 PM
110  *
111  * Revision 1.8  2001/12/19 02:19:16  rphall
112  * Fixed static getXxx factory method to accept blank names
113  *
114  * Revision 1.7  2001/12/18 16:43:48  rphall
115  * Serializable
116  *
117  * Revision 1.6  2001/12/18 13:29:18  rphall
118  * Added 'equals' and 'hashCode' methods
119  *
120  * Revision 1.5  2001/12/13 21:17:04  rphall
121  * Fixed handling of null name in static lookup
122  *
123  * Revision 1.4  2001/12/13 01:30:21  rphall
124  * Enrollment business and web objects
125  *
126  * Revision 1.3  2001/11/23 18:25:22  rphall
127  * Simplified class to a tagging data type
128  *
129  * Revision 1.1  2001/11/18 17:07:07  rphall
130  * Checkpt before major revision of rowing package
131  *
132  */
133