com.caucho.util
Class TimeIntervalElement

java.lang.Object
  extended by com.caucho.util.TimeIntervalElement
All Implemented Interfaces:
ComparableElement<TimeInterval>, TimeInterval, TimeIntervalEntry, java.lang.Comparable<TimeInterval>, java.util.Comparator<TimeInterval>

public class TimeIntervalElement
extends java.lang.Object
implements TimeInterval

Implements the TimeInterval interface.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.caucho.util.TimeInterval
TimeInterval.Comparison
 
Constructor Summary
TimeIntervalElement(long starts, long stops)
           
 
Method Summary
 int compare(TimeInterval interval1, TimeInterval interval2)
           
 int compareTo(TimeInterval interval)
          The recommended implementation of this method is: public int compareTo(E element) { return comparison(element).value(); }
 TimeInterval.Comparison compareWith(TimeInterval other)
          Returns a result that provides a ComparableElement.Comparison of this element with that of the element parameter.
 boolean current()
          Returns true if the interval is current.
 boolean current(long time)
          Returns true if the interval is current at the time specified.
 long duration()
          Returns the duration of the interval in milliseconds.
 boolean equals(java.lang.Object other)
           
 TimeInterval getTimeInterval()
          Returns the current time interval.
 int hashCode()
          Returns the hashCode that was calculated when this immutable instance was instantiated.
protected  long intervalNow()
          Provides the current time for use by the interval.
 long startTime()
          Returns the time that the interval starts in milliseconds.
 long stopTime()
          Returns the time that the interval ends in milliseconds.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimeIntervalElement

public TimeIntervalElement(long starts,
                           long stops)
Method Detail

startTime

public final long startTime()
Description copied from interface: TimeInterval
Returns the time that the interval starts in milliseconds.

Specified by:
startTime in interface TimeInterval

stopTime

public final long stopTime()
Description copied from interface: TimeInterval
Returns the time that the interval ends in milliseconds.

Specified by:
stopTime in interface TimeInterval
Returns:

duration

public final long duration()
Description copied from interface: TimeInterval
Returns the duration of the interval in milliseconds.

Note that an internval with a duration of 0 is valid, and can be used to represent a moment in time.

Specified by:
duration in interface TimeInterval

current

public final boolean current()
Description copied from interface: TimeInterval
Returns true if the interval is current.

Specified by:
current in interface TimeInterval

current

public final boolean current(long time)
Description copied from interface: TimeInterval
Returns true if the interval is current at the time specified.

Specified by:
current in interface TimeInterval

equals

public final boolean equals(java.lang.Object other)
Specified by:
equals in interface java.util.Comparator<TimeInterval>
Overrides:
equals in class java.lang.Object

hashCode

public final int hashCode()
Returns the hashCode that was calculated when this immutable instance was instantiated.

Overrides:
hashCode in class java.lang.Object

compareTo

public final int compareTo(TimeInterval interval)
Description copied from interface: ComparableElement
The recommended implementation of this method is: public int compareTo(E element) { return comparison(element).value(); }

Specified by:
compareTo in interface ComparableElement<TimeInterval>
Specified by:
compareTo in interface java.lang.Comparable<TimeInterval>

compare

public final int compare(TimeInterval interval1,
                         TimeInterval interval2)
Specified by:
compare in interface java.util.Comparator<TimeInterval>

compareWith

public final TimeInterval.Comparison compareWith(TimeInterval other)
Description copied from interface: ComparableElement
Returns a result that provides a ComparableElement.Comparison of this element with that of the element parameter.

Specified by:
compareWith in interface ComparableElement<TimeInterval>
Parameters:
other - to be compared with.
Returns:
the Comparison

intervalNow

protected long intervalNow()
Provides the current time for use by the interval.


getTimeInterval

public TimeInterval getTimeInterval()
Description copied from interface: TimeIntervalEntry
Returns the current time interval.

Specified by:
getTimeInterval in interface TimeIntervalEntry

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object