/Users/lyon/j4p/src/net/server/cal/Entries.java
|
1 /*
2 * Copyright (c) 1999 Sun Microsystems, Inc. All Rights Reserved.
3 *
4 * This software is the confidential and proprietary information of Sun
5 * Microsystems, Inc. ("Confidential Information"). You shall not
6 * disclose such Confidential Information and shall use it only in
7 * accordance with the terms of the license agreement you entered into
8 * with Sun.
9 *
10 * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
11 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
13 * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
14 * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
15 * THIS SOFTWARE OR ITS DERIVATIVES.
16 *
17 */
18
19 package net.server.cal;
20
21 import javax.servlet.http.HttpServletRequest;
22 import java.util.Hashtable;
23
24 public class Entries {
25
26 private Hashtable entries;
27 private static final String[] time = {"8am", "9am", "10am", "11am", "12pm",
28 "1pm", "2pm", "3pm", "4pm", "5pm", "6pm",
29 "7pm", "8pm"};
30 public static final int rows = 12;
31
32 public Entries() {
33 entries = new Hashtable(rows);
34 for (int i = 0; i < rows; i++) {
35 entries.put(time[i], new Entry(time[i]));
36 }
37 }
38
39 public int getRows() {
40 return rows;
41 }
42
43 public Entry getEntry(int index) {
44 return (Entry) this.entries.get(time[index]);
45 }
46
47 public int getIndex(String tm) {
48 for (int i = 0; i < rows; i++)
49 if (tm.equals(time[i])) return i;
50 return -1;
51 }
52
53 public void processRequest(HttpServletRequest request, String tm) {
54 int index = getIndex(tm);
55 if (index >= 0) {
56 String descr = request.getParameter("description");
57 ((Entry) entries.get(time[index])).setDescription(descr);
58 }
59 }
60
61 }
62
63
64
65
66
67
68
69
70
71
72
73
74
75