FileDocCategorySizeDatePackage
TimeSlot.javaAPI DocExample2750Mon Aug 27 20:11:36 BST 2007com.google.gwt.sample.dynatable.client

TimeSlot

public class TimeSlot extends Object implements com.google.gwt.user.client.rpc.IsSerializable, Comparable
Hold relevant data for a time slot. This class is intended to be serialized as part of RPC calls.

Fields Summary
private static final transient String[]
DAYS
private int
endMinutes
private int
startMinutes
private int
zeroBasedDayOfWeek
Constructors Summary
public TimeSlot()


    
  
public TimeSlot(int zeroBasedDayOfWeek, int startMinutes, int endMinutes)

    this.zeroBasedDayOfWeek = zeroBasedDayOfWeek;
    this.startMinutes = startMinutes;
    this.endMinutes = endMinutes;
  
Methods Summary
public intcompareTo(java.lang.Object o)

    TimeSlot other = (TimeSlot) o;
    if (zeroBasedDayOfWeek < other.zeroBasedDayOfWeek) {
      return -1;
    } else if (zeroBasedDayOfWeek > other.zeroBasedDayOfWeek) {
      return 1;
    } else {
      if (startMinutes < other.startMinutes) {
        return -1;
      } else if (startMinutes > other.startMinutes) {
        return 1;
      }
    }

    return 0;
  
public intgetDayOfWeek()

    return zeroBasedDayOfWeek;
  
public java.lang.StringgetDescription()

    return DAYS[zeroBasedDayOfWeek] + " " + getHrsMins(startMinutes) + "-"
        + getHrsMins(endMinutes);
  
public intgetEndMinutes()

    return endMinutes;
  
private java.lang.StringgetHrsMins(int mins)

    int hrs = mins / 60;
    if (hrs > 12) {
      hrs -= 12;
    }

    int remainder = mins % 60;

    return hrs + ":"
        + (remainder < 10 ? "0" + remainder : String.valueOf(remainder));
  
public intgetStartMinutes()

    return startMinutes;
  
public voidsetDayOfWeek(int zeroBasedDayOfWeek)

    if (0 <= zeroBasedDayOfWeek && zeroBasedDayOfWeek < 7) {
      this.zeroBasedDayOfWeek = zeroBasedDayOfWeek;
    } else {
      throw new IllegalArgumentException("day must be in the range 0-6");
    }
  
public voidsetEndMinutes(int endMinutes)

    this.endMinutes = endMinutes;
  
public voidsetStartMinutes(int startMinutes)

    this.startMinutes = startMinutes;