KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > sample > dynatable > client > Schedule


1 /*
2  * Copyright 2006 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16 package com.google.gwt.sample.dynatable.client;
17
18 import com.google.gwt.user.client.rpc.IsSerializable;
19
20 import java.util.ArrayList JavaDoc;
21 import java.util.Iterator JavaDoc;
22 import java.util.List JavaDoc;
23
24 /**
25  * Hold the relevant data for a Schedule. This class is meant to be serialized
26  * in RPC calls.
27  */

28 public class Schedule implements IsSerializable {
29
30   /**
31    * @gwt.typeArgs <com.google.gwt.sample.dynatable.client.TimeSlot>
32    */

33   private List JavaDoc timeSlots = new ArrayList JavaDoc();
34
35   public Schedule() {
36   }
37
38   public void addTimeSlot(TimeSlot timeSlot) {
39     timeSlots.add(timeSlot);
40   }
41
42   public String JavaDoc getDescription(boolean[] daysFilter) {
43     String JavaDoc s = null;
44     for (Iterator JavaDoc iter = timeSlots.iterator(); iter.hasNext();) {
45       TimeSlot timeSlot = (TimeSlot) iter.next();
46       if (daysFilter[timeSlot.getDayOfWeek()]) {
47         if (s == null) {
48           s = timeSlot.getDescription();
49         } else {
50           s += ", " + timeSlot.getDescription();
51         }
52       }
53     }
54
55     if (s != null) {
56       return s;
57     } else {
58       return "";
59     }
60   }
61
62   public String JavaDoc toString() {
63     return getDescription(null);
64   }
65
66 }
67
Popular Tags