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    import javax.servlet.http.*;
021    
022    public class Entries {
023    
024      private Hashtable entries;
025      private static final String[] time = {"8am", "9am", "10am", "11am", "12pm", 
026                                            "1pm", "2pm", "3pm", "4pm", "5pm", "6pm",
027                                            "7pm", "8pm" };
028      public static final int rows = 12;
029    
030      public Entries () {   
031       entries = new Hashtable (rows);
032       for (int i=0; i < rows; i++) {
033         entries.put (time[i], new Entry(time[i]));
034       }
035      }
036    
037      public int getRows () {
038        return rows;
039      }
040    
041      public Entry getEntry (int index) {
042        return (Entry)this.entries.get(time[index]);
043      }
044    
045      public int getIndex (String tm) {
046        for (int i=0; i<rows; i++)
047          if(tm.equals(time[i])) return i;
048        return -1;
049      }
050    
051      public void processRequest (HttpServletRequest request, String tm) {
052        int index = getIndex (tm);
053        if (index >= 0) {
054          String descr = request.getParameter ("description");
055          ((Entry)entries.get(time[index])).setDescription (descr);
056        }
057      }
058    
059    }
060    
061    
062    
063    
064    
065    
066    
067    
068    
069    
070    
071    
072