001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package cal; 018 019 import java.util.Hashtable; 020 021 import javax.servlet.http.HttpServletRequest; 022 023 public class Entries { 024 025 private Hashtable entries; 026 private static final String[] time = {"8am", "9am", "10am", "11am", "12pm", 027 "1pm", "2pm", "3pm", "4pm", "5pm", "6pm", 028 "7pm", "8pm"}; 029 public static final int rows = 12; 030 031 public Entries() { 032 entries = new Hashtable(rows); 033 for (int i = 0; i < rows; i++) { 034 entries.put(time[i], new Entry(time[i])); 035 } 036 } 037 038 public int getRows() { 039 return rows; 040 } 041 042 public Entry getEntry(int index) { 043 return (Entry) this.entries.get(time[index]); 044 } 045 046 public int getIndex(String tm) { 047 for (int i = 0; i < rows; i++) 048 if (tm.equals(time[i])) return i; 049 return -1; 050 } 051 052 public void processRequest(HttpServletRequest request, String tm) { 053 int index = getIndex(tm); 054 if (index >= 0) { 055 String descr = request.getParameter("description"); 056 ((Entry) entries.get(time[index])).setDescription(descr); 057 } 058 } 059 060 } 061 062 063 064 065 066 067 068 069 070 071 072 073