home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-tomcat-addon-1.4.9-installer.exe / Entries.class (.txt) < prev    next >
Encoding:
Java Class File  |  2004-05-17  |  1.8 KB  |  45 lines

  1. package cal;
  2.  
  3. import java.util.Hashtable;
  4. import javax.servlet.http.HttpServletRequest;
  5.  
  6. public class Entries {
  7.    private Hashtable entries = new Hashtable(12);
  8.    private static final String[] time = new String[]{"8am", "9am", "10am", "11am", "12pm", "1pm", "2pm", "3pm", "4pm", "5pm", "6pm", "7pm", "8pm"};
  9.    public static final int rows = 12;
  10.  
  11.    public Entries() {
  12.       for(int i = 0; i < 12; ++i) {
  13.          this.entries.put(time[i], new Entry(time[i]));
  14.       }
  15.  
  16.    }
  17.  
  18.    public int getRows() {
  19.       return 12;
  20.    }
  21.  
  22.    public Entry getEntry(int index) {
  23.       return (Entry)this.entries.get(time[index]);
  24.    }
  25.  
  26.    public int getIndex(String tm) {
  27.       for(int i = 0; i < 12; ++i) {
  28.          if (tm.equals(time[i])) {
  29.             return i;
  30.          }
  31.       }
  32.  
  33.       return -1;
  34.    }
  35.  
  36.    public void processRequest(HttpServletRequest request, String tm) {
  37.       int index = this.getIndex(tm);
  38.       if (index >= 0) {
  39.          String descr = request.getParameter("description");
  40.          ((Entry)this.entries.get(time[index])).setDescription(descr);
  41.       }
  42.  
  43.    }
  44. }
  45.