org.sakaiproject.component.legacy.time
Class BasicTimeService.MyTimeRange

java.lang.Object
  extended byorg.sakaiproject.component.legacy.time.BasicTimeService.MyTimeRange
All Implemented Interfaces:
Cloneable, TimeRange
Enclosing class:
BasicTimeService

public class BasicTimeService.MyTimeRange
extends Object
implements TimeRange

TimeRange implementation


Field Summary
protected  boolean m_endIncluded
           
protected  Time m_endTime
           
protected  boolean m_startIncluded
           
protected  Time m_startTime
           
 
Constructor Summary
BasicTimeService.MyTimeRange(long start, long duration)
          construct from a time long and a duration long in ms
BasicTimeService.MyTimeRange(String str)
          construct from a string, in our format
BasicTimeService.MyTimeRange(Time startAndEnd)
          construct from a single time
BasicTimeService.MyTimeRange(Time start, Time end)
          construct from a two times - inclusive
BasicTimeService.MyTimeRange(Time start, Time end, boolean startIncluded, boolean endIncluded)
          construct from a two times, and start and end inclusion booleans
 
Method Summary
 void adjust(TimeRange original, TimeRange modified)
          Adjust this time range based on the difference between the origRange and the modRange, if any
 Object clone()
          Clone the TimeRange
 boolean contains(Time time)
          is this time in my range?
 boolean contains(TimeRange range)
          do I completely contain this other range?
 long duration()
          compute the duration, in ms, of the time range
 boolean equals(Object obj)
          equals to another time range
 Time firstTime()
          what is the first time range included?
 Time firstTime(long fudge)
          what is the first time range included?
 boolean isSingleTime()
          check if the time range is really just a single time
 Time lastTime()
          what is the last time range included?
 Time lastTime(long fudge)
          what is the last time range included?
 boolean overlaps(TimeRange range)
          do I overlap this other range at all?
protected  void parse(String str, Time earliest, Time latest)
          parse from a string - resolve fully earliest ('!')
 void shiftBackward(long i)
          Shift the time range back an intervel
 void shiftForward(long i)
          Shift the time range forward an intervel
 String toString()
          format the range
 String toStringHR()
          format the range - human readable
 void zoom(double f)
          Enlarge or shrink the time range by multiplying a zooming factor
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_startIncluded

protected boolean m_startIncluded

m_endIncluded

protected boolean m_endIncluded

m_startTime

protected Time m_startTime

m_endTime

protected Time m_endTime
Constructor Detail

BasicTimeService.MyTimeRange

public BasicTimeService.MyTimeRange(Time start,
                                    Time end,
                                    boolean startIncluded,
                                    boolean endIncluded)
construct from a two times, and start and end inclusion booleans


BasicTimeService.MyTimeRange

public BasicTimeService.MyTimeRange(String str)
construct from a string, in our format

Parameters:
str - the time range string

BasicTimeService.MyTimeRange

public BasicTimeService.MyTimeRange(Time startAndEnd)
construct from a single time


BasicTimeService.MyTimeRange

public BasicTimeService.MyTimeRange(long start,
                                    long duration)
construct from a time long and a duration long in ms

Parameters:
start - time value
duration - ms duration

BasicTimeService.MyTimeRange

public BasicTimeService.MyTimeRange(Time start,
                                    Time end)
construct from a two times - inclusive

Method Detail

clone

public Object clone()
Description copied from interface: TimeRange
Clone the TimeRange

Specified by:
clone in interface TimeRange

contains

public boolean contains(Time time)
is this time in my range?

Specified by:
contains in interface TimeRange
Parameters:
time - The time to check for inclusion.
Returns:
true if the time is in the range, false if not

overlaps

public boolean overlaps(TimeRange range)
do I overlap this other range at all?

Specified by:
overlaps in interface TimeRange
Parameters:
range - The time range to check for overlap.
Returns:
true if any time in range is in my range is in the other range, false if not

contains

public boolean contains(TimeRange range)
do I completely contain this other range?

Specified by:
contains in interface TimeRange
Parameters:
range - The time range to check for containment.
Returns:
true if range is within my time ramge

firstTime

public Time firstTime()
what is the first time range included?

Specified by:
firstTime in interface TimeRange
Returns:
the first time actually in the range

lastTime

public Time lastTime()
what is the last time range included?

Specified by:
lastTime in interface TimeRange
Returns:
the last time actually in the range

firstTime

public Time firstTime(long fudge)
what is the first time range included?

Specified by:
firstTime in interface TimeRange
Parameters:
fudge - How many ms to advance if the first is not included.
Returns:
the first time actually in the range

lastTime

public Time lastTime(long fudge)
what is the last time range included?

Specified by:
lastTime in interface TimeRange
Parameters:
fudge - How many ms to decrease if the first is not included.
Returns:
the last time actually in the range

toString

public String toString()
format the range

Returns:
a string representation of the time range

toStringHR

public String toStringHR()
format the range - human readable

Specified by:
toStringHR in interface TimeRange
Returns:
a string representation of the time range, human readable

equals

public boolean equals(Object obj)
equals to another time range


duration

public long duration()
compute the duration, in ms, of the time range

Specified by:
duration in interface TimeRange
Returns:
The duration.

parse

protected void parse(String str,
                     Time earliest,
                     Time latest)
parse from a string - resolve fully earliest ('!') and latest ('*') and durations ('=')

Parameters:
str - the string to parse
earliest - Time to substitute for any 'earliest' values
latest - the Time to use for 'latest'

shiftBackward

public void shiftBackward(long i)
Shift the time range back an intervel

Specified by:
shiftBackward in interface TimeRange
Parameters:
i - time intervel in ms

shiftForward

public void shiftForward(long i)
Shift the time range forward an intervel

Specified by:
shiftForward in interface TimeRange
Parameters:
i - time intervel in ms

zoom

public void zoom(double f)
Enlarge or shrink the time range by multiplying a zooming factor

Specified by:
zoom in interface TimeRange
Parameters:
f - zooming factor

adjust

public void adjust(TimeRange original,
                   TimeRange modified)
Adjust this time range based on the difference between the origRange and the modRange, if any

Specified by:
adjust in interface TimeRange
Parameters:
original - the original time range.
modified - the modified time range.

isSingleTime

public boolean isSingleTime()
check if the time range is really just a single time

Specified by:
isSingleTime in interface TimeRange
Returns:
true if the time range is a single time, false if it is not