public class TimeSequence extends java.lang.Object implements Sequential
Constructor and Description |
---|
TimeSequence()
Create a time sequence with no spans defined
|
TimeSequence(java.util.Collection<TimeSpan> timeSpans)
Create a time sequence from the collection of time spans
|
TimeSequence(java.util.List<java.util.Date> startDates,
java.util.List<java.util.Date> stopDates)
Create a TimeSequence by matching a set of start and stop dates.
|
Modifier and Type | Method and Description |
---|---|
void |
addTimeSegment(java.util.Date start,
java.util.Date stop)
Adds a time segment - a start/stop time - to the sequence's list of
start/stop times.
|
void |
addTimeSegment(java.util.Date start,
long duration)
Adds a time segment - a start/stop time - to the sequence's list of
start/stop times.
|
void |
addTimeSpan(TimeSpan span)
Adds a TimeSpan to the sequence's list of TimeSpans.
|
java.util.Date |
getActiveStartTime(java.util.Date time)
gets the start time of the time segment that includes time
|
java.util.Date |
getActiveStopTime(java.util.Date time)
gets the stop time of the time segment that includes time
|
java.util.Date |
getEarliestTime()
Returns the earliest time that this sequence is active.
|
java.util.Date |
getLatestTime()
Returns the latest time that this sequence is active.
|
java.util.SortedSet<TimeSpan> |
getTimeSpans()
returns a set of TimeSpan objects representing the sequence.
|
boolean |
isActive(java.util.Date testDate)
Returns whether the sequence of time spans is active at the test date.
|
boolean |
isActive(long millis)
Returns whether the sequence is active at the specified time.
|
public TimeSequence()
public TimeSequence(java.util.Collection<TimeSpan> timeSpans)
timeSpans
- a collection of time spanspublic TimeSequence(java.util.List<java.util.Date> startDates, java.util.List<java.util.Date> stopDates)
startDates
- the list of start datesstopDates
- the list of stop datespublic void addTimeSegment(java.util.Date start, java.util.Date stop)
addTimeSegment
in interface Sequential
start
- the new start timestop
- the new stop timepublic void addTimeSegment(java.util.Date start, long duration)
addTimeSegment
in interface Sequential
start
- the new start timeduration
- the duration of the time segment in millisecondspublic void addTimeSpan(TimeSpan span)
addTimeSpan
in interface Sequential
span
- the new timespanpublic java.util.Date getActiveStartTime(java.util.Date time)
getActiveStartTime
in interface Sequential
time
- the time to use to find the time segmentpublic java.util.Date getActiveStopTime(java.util.Date time)
getActiveStopTime
in interface Sequential
time
- the time to use to find the time segmentpublic java.util.Date getEarliestTime()
getEarliestTime
in interface Sequential
public java.util.Date getLatestTime()
getLatestTime
in interface Sequential
public java.util.SortedSet<TimeSpan> getTimeSpans()
getTimeSpans
in interface Sequential
public boolean isActive(java.util.Date testDate)
isActive
in interface Sequential
testDate
- the date to test to see if the sequence is active.public boolean isActive(long millis)
isActive
in interface Sequential
millis
- the time, in milliseconds after Jan 1, 1970, to test to
see if the sequence is active.