gov.nasa.gsfc.spdf.cdas
Class TimeInterval

java.lang.Object
  extended by gov.nasa.gsfc.spdf.cdas.TimeInterval
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable

public class TimeInterval
extends java.lang.Object
implements java.lang.Comparable, java.lang.Cloneable

This class represents a time interval. That is, a continuous interval of time from a beginning time to an end time.

Version:
$Revision: 1.2 $
Author:
B. Harris

Constructor Summary
TimeInterval()
          Default constructor to satisfy JAX-RPC.
TimeInterval(java.util.Date start, java.util.Date end)
          Constructs a TimeInterval from the given start and end time values.
 
Method Summary
 java.lang.Object clone()
           
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 java.util.Date getEnd()
          Provides the end Date of this time interval.
 long getIntervalMilliseconds()
          Provides the number of milliseconds in this time interval.
 java.util.Date getStart()
          Provides the start Date of this time interval.
static void main(java.lang.String[] args)
          Provides a method of testing this class.
 boolean overlaps(TimeInterval value)
          Determines if the given TimeInterval overlaps in time with this TimeInterval.
 void setEnd(java.util.Date value)
          Sets the end Date of this time interval.
 void setStart(java.util.Date value)
          Sets the start Date of this time interval.
 java.lang.String toString()
          Returns a String object representing this TimeInterval's value.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimeInterval

public TimeInterval()
Default constructor to satisfy JAX-RPC.


TimeInterval

public TimeInterval(java.util.Date start,
                    java.util.Date end)
Constructs a TimeInterval from the given start and end time values.

Parameters:
start - beginning Date of time interval
end - ending Date of time interval
Method Detail

getStart

public java.util.Date getStart()
Provides the start Date of this time interval.

Returns:
start Date of time interval
See Also:
setStart(java.util.Date)

setStart

public void setStart(java.util.Date value)
Sets the start Date of this time interval.

Parameters:
value - start Date of time interval
See Also:
getStart()

getEnd

public java.util.Date getEnd()
Provides the end Date of this time interval.

Returns:
end Date of time interval. May be null.
See Also:
setEnd(java.util.Date)

setEnd

public void setEnd(java.util.Date value)
Sets the end Date of this time interval.

Parameters:
value - end Date of time interval.
See Also:
getEnd()

getIntervalMilliseconds

public long getIntervalMilliseconds()
Provides the number of milliseconds in this time interval.

Returns:
number of milliseconds in this time interval. Zero if the start or end of the interval is infinite.

compareTo

public int compareTo(java.lang.Object o)
              throws java.lang.ClassCastException,
                     java.lang.UnsupportedOperationException
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
java.lang.UnsupportedOperationException - if both the start time of this interval and the start time of the given interval are infinite (null).
java.lang.ClassCastException - if the specified object's type prevents it from being compared to this Object.

toString

public java.lang.String toString()
Returns a String object representing this TimeInterval's value. The value consists of the String represention of the TimeInterval's start and end time.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this TimeInterval.
See Also:
Date.toString()

overlaps

public boolean overlaps(TimeInterval value)
Determines if the given TimeInterval overlaps in time with this TimeInterval.

Parameters:
value - the TimeInterval to evaluate.
Returns:
true if the given value overlaps this time interval.

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Provides a method of testing this class.

Parameters:
args - command-line arguments. Currently ignored.
Throws:
java.lang.Exception - if any Exception occurs


CDAS Feedback.

Copyright © 2003-2007 United States Government as represented by the National Aeronautics and Space Administration. No copyright is claimed in the United States under Title 17, U.S.Code. All Other Rights Reserved.