1 /* 2 * Copyright 2008 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; 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 private List<TimeSlot> timeSlots = new ArrayList<TimeSlot>(); 30 Schedule()31 public Schedule() { 32 } 33 addTimeSlot(TimeSlot timeSlot)34 public void addTimeSlot(TimeSlot timeSlot) { 35 timeSlots.add(timeSlot); 36 } 37 getDescription(boolean[] daysFilter)38 public String getDescription(boolean[] daysFilter) { 39 String s = null; 40 for (TimeSlot timeSlot : timeSlots) { 41 if (daysFilter[timeSlot.getDayOfWeek()]) { 42 if (s == null) { 43 s = timeSlot.getDescription(); 44 } else { 45 s += ", " + timeSlot.getDescription(); 46 } 47 } 48 } 49 50 if (s != null) { 51 return s; 52 } else { 53 return ""; 54 } 55 } 56 57 @Override toString()58 public String toString() { 59 return getDescription(null); 60 } 61 62 } 63