01: /*
02: * Copyright 2006 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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;
21: import java.util.List;
22:
23: /**
24: * Hold the relevant data for a Schedule. This class is meant to be serialized
25: * in RPC calls.
26: */
27: public class Schedule implements IsSerializable {
28:
29: /**
30: * @gwt.typeArgs <com.google.gwt.sample.dynatable.client.TimeSlot>
31: */
32: private List<TimeSlot> timeSlots = new ArrayList<TimeSlot>();
33:
34: public Schedule() {
35: }
36:
37: public void addTimeSlot(TimeSlot timeSlot) {
38: timeSlots.add(timeSlot);
39: }
40:
41: public String getDescription(boolean[] daysFilter) {
42: String s = null;
43: for (TimeSlot timeSlot : timeSlots) {
44: if (daysFilter[timeSlot.getDayOfWeek()]) {
45: if (s == null) {
46: s = timeSlot.getDescription();
47: } else {
48: s += ", " + timeSlot.getDescription();
49: }
50: }
51: }
52:
53: if (s != null) {
54: return s;
55: } else {
56: return "";
57: }
58: }
59:
60: @Override
61: public String toString() {
62: return getDescription(null);
63: }
64:
65: }
|