edu.usc.bg.validator
Class Interval<Type>

java.lang.Object
  extended by edu.usc.bg.validator.Interval<Type>
Type Parameters:
Type - The type of data being stored.
All Implemented Interfaces:
java.lang.Comparable<Interval<Type>>

public class Interval<Type>
extends java.lang.Object
implements java.lang.Comparable<Interval<Type>>

The Interval class maintains an interval with some associated data.

Author:
Kevin Dolan

Constructor Summary
Interval(long start, long end, Type data)
           
 
Method Summary
 int compareTo(Interval<Type> other)
          Return -1 if this interval's start time is less than the other, 1 if greater In the event of a tie, -1 if this interval's end time is less than the other, 1 if greater, 0 if same
 boolean contains(long time)
           
 Type getData()
           
 long getEnd()
           
 long getStart()
           
 boolean intersects(Interval<?> other)
           
 void setData(Type data)
           
 void setEnd(long end)
           
 void setStart(long start)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Interval

public Interval(long start,
                long end,
                Type data)
Method Detail

getStart

public long getStart()

setStart

public void setStart(long start)

getEnd

public long getEnd()

setEnd

public void setEnd(long end)

getData

public Type getData()

setData

public void setData(Type data)

contains

public boolean contains(long time)
Parameters:
time -
Returns:
true if this interval contains time (invlusive)

intersects

public boolean intersects(Interval<?> other)
Parameters:
other -
Returns:
return true if this interval intersects other

compareTo

public int compareTo(Interval<Type> other)
Return -1 if this interval's start time is less than the other, 1 if greater In the event of a tie, -1 if this interval's end time is less than the other, 1 if greater, 0 if same

Specified by:
compareTo in interface java.lang.Comparable<Interval<Type>>
Parameters:
other -
Returns:
1 or -1