org.gcube.accounting.common
Class TimeRange

java.lang.Object
  extended by org.gcube.accounting.common.TimeRange

public class TimeRange
extends Object


Constructor Summary
TimeRange(Calendar from, Calendar to)
          The constructor guarantees that 'from' is always before 'to'.
 
Method Summary
 void constrainTo(TimeRange otherRange)
          Force this time range to be within the given time range
 boolean endsWithin(TimeRange other)
          Check whether this time range ends within the given time range
 long getElapsed()
          The range extension, in milliseconds
 Calendar getFrom()
          Getter for 'from'
 Calendar getTo()
          Getter for 'to'
 boolean isAfter(TimeRange range)
          Whether this range starts before 'range' ends
 boolean isBefore(TimeRange range)
          Whether this range ends before 'range' starts
 boolean isClosed()
          Check if from and to are set
 boolean isOutside(TimeRange otherRange)
          Check whether this time range enrirely falls outside the the given time range
 boolean isUndefined()
           
 boolean isWithin(TimeRange range)
          Whether this range is entirely within 'range'
 boolean startsWithin(TimeRange other)
          Check whether this time range starts within the given time range
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeRange

public TimeRange(Calendar from,
                 Calendar to)
The constructor guarantees that 'from' is always before 'to'. Furthermore, at least the 'left' end of the range must be defined

Parameters:
from -
to -
Method Detail

getFrom

public Calendar getFrom()
Getter for 'from'

Returns:

getTo

public Calendar getTo()
Getter for 'to'

Returns:

isClosed

public boolean isClosed()
Check if from and to are set

Returns:

isUndefined

public boolean isUndefined()

endsWithin

public boolean endsWithin(TimeRange other)
Check whether this time range ends within the given time range

Parameters:
other -
Returns:

startsWithin

public boolean startsWithin(TimeRange other)
Check whether this time range starts within the given time range

Parameters:
other -
Returns:

isOutside

public boolean isOutside(TimeRange otherRange)
Check whether this time range enrirely falls outside the the given time range

Parameters:
other -
Returns:

constrainTo

public void constrainTo(TimeRange otherRange)
Force this time range to be within the given time range

Parameters:
from -
to -

isWithin

public boolean isWithin(TimeRange range)
Whether this range is entirely within 'range'

Parameters:
range -
Returns:

isBefore

public boolean isBefore(TimeRange range)
Whether this range ends before 'range' starts

Parameters:
range -
Returns:

isAfter

public boolean isAfter(TimeRange range)
Whether this range starts before 'range' ends

Parameters:
range -
Returns:

getElapsed

public long getElapsed()
The range extension, in milliseconds

Returns:


Copyright © 2013. All Rights Reserved.