speedscheduler
Class Schedule

java.lang.Object
  extended by speedscheduler.Schedule
All Implemented Interfaces:
java.io.Serializable

public class Schedule
extends java.lang.Object
implements java.io.Serializable

The Schedule is fundamental to SpeedScheduler. It stores two Time objects, a set of days of the week, and rate information (max up rate, max down rate, and whether transfers should be paused during this Schedule). SpeedScheduler passes instances of Schedule all over the place to figure out when to do what.

See Also:
Serialized Form

Field Summary
private  boolean downloadsPaused
           
private  boolean enabled
           
private  Time endTime
           
private  int maxDownloadRate
           
private  int maxUploadRate
           
private  boolean seedsPaused
           
private  boolean[] selectedDays
           
private  Time startTime
           
 
Constructor Summary
Schedule()
          Creates a new schedule with default values.
Schedule(boolean[] selectedDays, Time startTime, Time endTime, int maxUploadRate, int maxDownloadRate, boolean downloadsPaused, boolean seedsPaused)
          Create a new Schedule with a specified set of days, start/end times, and rate configuration.
 
Method Summary
 boolean areDownloadsPaused()
          Gets whether transfers are supposed to be paused during this Schedule.
 boolean areSeedsPaused()
           
 boolean equals(java.lang.Object o)
          Compares the specified Schedule (t) with this one.
 java.lang.String getDaySelectionString()
          Gets a human-readable string to show which days of the week have been selected.
 java.lang.String getDownloadRateString()
          Gets a human-readable string representing the max download speed for this Schedule.
 Time getEndTime()
          Gets the end time for this Schedule, represented as a Time object.
 java.lang.String getHourSelectionString()
          Gets a nicely formatted string representing the hours selected by this Schedule.
 int getMaxDownloadRate()
          Gets the max download rate for this schedule.
 int getMaxUploadRate()
          Gets the max upload rate for this schedule.
 boolean[] getSelectedDays()
          Gets the raw boolean array (of size TimeUtils.WEEK_LEN) to show which days have been selected for this Schedule.
 Time getStartTime()
          Gets the start time for this Schedule.
 java.lang.String getUploadRateString()
          Gets a human-readable string representing the max upload speed for this Schedule.
 int hashCode()
          Gets this object's hash code
 boolean inSpan(Time time)
          Returns true if the specified Time object falls withing the span covered by this Schedule.
 boolean isDaySelected(int dayIndex)
          Given a day index, gets whether that day is selected by this Schedule.
 boolean isEnabled()
          Gets whether this Schedule is enabled by the user.
 void setDownloadsPaused(boolean paused)
          Sets whether downloading torrents are supposed to be paused during this Schedule.
 void setEnabled(boolean enabled)
          Enable or disable this schedule
 void setEndTime(Time endTime)
          Sets the end time.
 void setMaxDownloadRate(int maxDownloadRate)
          Sets the max download rate for this schedule.
 void setMaxUploadRate(int maxUploadRate)
          Sets the max upload rate for this schedule.
 void setSeedsPaused(boolean paused)
          Sets whether seeding torrents are supposed to be paused during this Schedule.
 void setSelectedDays(boolean[] selectedDays)
          Sets the selected days for this Schedule.
 void setStartTime(Time startTime)
          Sets the start time for this Schedule.
 boolean toggleEnabledState()
          Toggles the schedule from enabled to disabled and vice versa.
 java.lang.String toString()
          Gets a human readable representation of this Schedule, mostly for debugging purposes.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

startTime

private Time startTime

endTime

private Time endTime

selectedDays

private boolean[] selectedDays

maxUploadRate

private int maxUploadRate

maxDownloadRate

private int maxDownloadRate

seedsPaused

private boolean seedsPaused

downloadsPaused

private boolean downloadsPaused

enabled

private boolean enabled
Constructor Detail

Schedule

public Schedule(boolean[] selectedDays,
                Time startTime,
                Time endTime,
                int maxUploadRate,
                int maxDownloadRate,
                boolean downloadsPaused,
                boolean seedsPaused)
Create a new Schedule with a specified set of days, start/end times, and rate configuration.

Parameters:
selectedDays - An array of 7 booleans (see TimeUtils.WEEK_LEN) representing which days of the week this Schedule applies to. True entries in thearray indicate that this Schedule does apply, and False entries indicate the opposite. Sunday is index 0 and Saturday is index 6.
startTime - The start time of this Schedule.
endTime - The end time of this Schedule.
maxUploadRate - The maxium upload rate for this Schedule.
maxDownloadRate - The maxium download rate for this Schedule.
downloadsPaused - True if all torrents should be paused during this Schedule.

Schedule

public Schedule()
Creates a new schedule with default values.

Method Detail

getDaySelectionString

public java.lang.String getDaySelectionString()
Gets a human-readable string to show which days of the week have been selected. Examples: "Monday through Friday", "Monday, Wednesday, Friday", "Saturday, Sunday".

Returns:
The string representing the days selected.

getEndTime

public Time getEndTime()
Gets the end time for this Schedule, represented as a Time object.

Returns:
The end time.

getHourSelectionString

public java.lang.String getHourSelectionString()
Gets a nicely formatted string representing the hours selected by this Schedule. Examples "8:00am - 10:00am", "All day", "Midnight - 3:00am".

Returns:
The string.

getUploadRateString

public java.lang.String getUploadRateString()
Gets a human-readable string representing the max upload speed for this Schedule. Examples: "8 kbytes/sec", "Unlimited".

Returns:
The string.

getDownloadRateString

public java.lang.String getDownloadRateString()
Gets a human-readable string representing the max download speed for this Schedule. Examples: "8 kbytes/sec", "Unlimited".

Returns:

getSelectedDays

public boolean[] getSelectedDays()
Gets the raw boolean array (of size TimeUtils.WEEK_LEN) to show which days have been selected for this Schedule. Sunday is index 0, and Saturday is index 6.

Returns:
The array of selected days.

getStartTime

public Time getStartTime()
Gets the start time for this Schedule.

Returns:
The start time.

inSpan

public boolean inSpan(Time time)
Returns true if the specified Time object falls withing the span covered by this Schedule.

Parameters:
time - The time to check.
Returns:
True if the specified Time is within this Schedule, false otherwise.

isDaySelected

public boolean isDaySelected(int dayIndex)
Given a day index, gets whether that day is selected by this Schedule.

Parameters:
dayIndex -
Returns:

setEndTime

public void setEndTime(Time endTime)
Sets the end time.

Parameters:
endTime - The end time.

setSelectedDays

public void setSelectedDays(boolean[] selectedDays)
Sets the selected days for this Schedule.

Parameters:
selectedDays - The selected days array.

setStartTime

public void setStartTime(Time startTime)
Sets the start time for this Schedule.

Parameters:
startTime - The start time.

toString

public java.lang.String toString()
Gets a human readable representation of this Schedule, mostly for debugging purposes.

Overrides:
toString in class java.lang.Object
Returns:
the string.

getMaxDownloadRate

public int getMaxDownloadRate()
Gets the max download rate for this schedule.

Returns:
The max download rate.

setMaxDownloadRate

public void setMaxDownloadRate(int maxDownloadRate)
Sets the max download rate for this schedule.


getMaxUploadRate

public int getMaxUploadRate()
Gets the max upload rate for this schedule.

Returns:
The max upload rate.

setMaxUploadRate

public void setMaxUploadRate(int maxUploadRate)
Sets the max upload rate for this schedule.


areDownloadsPaused

public boolean areDownloadsPaused()
Gets whether transfers are supposed to be paused during this Schedule.

Returns:
True if so, false otherwise.

setDownloadsPaused

public void setDownloadsPaused(boolean paused)
Sets whether downloading torrents are supposed to be paused during this Schedule.


setSeedsPaused

public void setSeedsPaused(boolean paused)
Sets whether seeding torrents are supposed to be paused during this Schedule.


equals

public boolean equals(java.lang.Object o)
Compares the specified Schedule (t) with this one.

Overrides:
equals in class java.lang.Object
Parameters:
t - The Schedule to compare to this one
Returns:
True if the Schedules are equivelant or the same Schedule instance, and false otherwise.

hashCode

public int hashCode()
Gets this object's hash code

Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

isEnabled

public boolean isEnabled()
Gets whether this Schedule is enabled by the user.

Returns:
True if this Schedule is enabled by the user, false otherwise.

setEnabled

public void setEnabled(boolean enabled)
Enable or disable this schedule

Parameters:
enabled - The enabled to set.

toggleEnabledState

public boolean toggleEnabledState()
Toggles the schedule from enabled to disabled and vice versa.

Returns:
The enabled state AFTER the toggle.

areSeedsPaused

public boolean areSeedsPaused()
Returns:
Whether seeds are paused during this schedule.