001    /*
002    * Copyright 2004 The Apache Software Foundation
003    *
004    * Licensed under the Apache License, Version 2.0 (the "License");
005    * you may not use this file except in compliance with the License.
006    * You may obtain a copy of the License at
007    *
008    *     http://www.apache.org/licenses/LICENSE-2.0
009    *
010    * Unless required by applicable law or agreed to in writing, software
011    * distributed under the License is distributed on an "AS IS" BASIS,
012    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013    * See the License for the specific language governing permissions and
014    * limitations under the License.
015    */
016    package cal;
017    
018    import java.util.Enumeration;
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