ilog.views.gantt
Class IlvTimeInterval

java.lang.Object
  extended by ilog.views.gantt.IlvTimeInterval
All Implemented Interfaces:
Serializable, Cloneable

public class IlvTimeInterval
extends Object
implements Cloneable, Serializable

The class IlvTimeInterval represents a specific time span, with millisecond precision. The time interval is defined by a start time and an end time. IlvTimeInterval maintains the invariant that its start time is always before or equal to its end time. This invariant is maintained quietly, swapping its start and end time values as needed.

See Also:
Serialized Form

Constructor Summary
IlvTimeInterval(Date startTime, Date endTime)
          Creates a new IlvTimeInterval with the specified start and end times.
IlvTimeInterval(Date startTime, IlvDuration duration)
          Creates a new IlvTimeInterval with the specified start time and duration.
 
Method Summary
 Object clone()
          Creates a copy of this time interval.
 boolean contains(Date time)
          Returns true if the time interval contains the given time.
 boolean equals(Object obj)
          Returns whether an object is logically equal to this interval.
 IlvDuration getDuration()
          Returns the duration between the interval start and end times.
 Date getEnd()
          Returns the interval end time.
 Date getStart()
          Returns the interval start time.
 int hashCode()
          Returns a hash code value for this interval.
 IlvTimeInterval intersection(IlvTimeInterval interval)
          Returns the intersection of the specified time interval with this one.
 boolean overlaps(IlvTimeInterval interval)
          Returns true if the specified time interval overlaps this one.
 void setDuration(IlvDuration duration)
          Sets the duration between the interval start and end times.
 void setEnd(Date t)
          Sets the interval end time.
 void setInterval(Date start, Date end)
          Sets the interval start and end times.
 void setInterval(Date start, IlvDuration duration)
          Sets the interval start time and duration.
 void setStart(Date t)
          Sets the interval start time.
 String toString()
          Returns a string representation of this time interval.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IlvTimeInterval

public IlvTimeInterval(Date startTime,
                       Date endTime)
Creates a new IlvTimeInterval with the specified start and end times.

Parameters:
startTime - The interval start time.
endTime - The interval end time.

IlvTimeInterval

public IlvTimeInterval(Date startTime,
                       IlvDuration duration)
Creates a new IlvTimeInterval with the specified start time and duration.

Parameters:
startTime - The interval start time.
duration - The interval duration.
Since:
JViews 3.5
Method Detail

clone

public Object clone()
Creates a copy of this time interval.

Overrides:
clone in class Object
Returns:
A copy of this time interval

getStart

public Date getStart()
Returns the interval start time.

Returns:
The start time.

setStart

public void setStart(Date t)
Sets the interval start time. The invariant is maintained that the interval start time must always be before or equal to its end time. Therefore, if t > getEnd() then t will actually become the interval's new end time and its previous end time will become its new start time.

Parameters:
t - The start time of the interval.

getEnd

public Date getEnd()
Returns the interval end time.

Returns:
The end time.

setEnd

public void setEnd(Date t)
Sets the interval end time. The invariant is maintained that the interval start time must always be before or equal to its end time. Therefore, if t < getStart() then t will actually become the interval's new start time and its previous start time will become its new end time.

Parameters:
t - The end time of the interval.

setInterval

public void setInterval(Date start,
                        Date end)
Sets the interval start and end times. The invariant is maintained that the interval start time must always be before or equal to its end time. Therefore, if end < start then the values will be silently swapped and start will actually become the interval's new end time and end will become the interval's new start time.

Parameters:
start - The start time of the interval.
end - The end time of the interval.

setInterval

public void setInterval(Date start,
                        IlvDuration duration)
Sets the interval start time and duration. The invariant is maintained that the interval start time must always be before or equal to its end time. Therefore, if duration < 0 then start will silently become the interval's new end time.

Parameters:
start - The start time of the interval.
duration - The duration of the interval.
Since:
JViews 3.5

getDuration

public IlvDuration getDuration()
Returns the duration between the interval start and end times.

Returns:
The duration.

setDuration

public void setDuration(IlvDuration duration)
Sets the duration between the interval start and end times. The invariant is maintained that the interval start time must always be before or equal to its end time. Therefore, if duration < 0 then the interval's current start time will silently become its end time.

Parameters:
duration - The duration of the interval.
Since:
JViews 3.5

equals

public boolean equals(Object obj)
Returns whether an object is logically equal to this interval. The result will be true if and only if the argument is an IlvTimeInterval object that represents the same period of time as this interval.

Overrides:
equals in class Object
Parameters:
obj - The object to compare with.
Returns:
true if the objects are the same; false otherwise

hashCode

public int hashCode()
Returns a hash code value for this interval.

Overrides:
hashCode in class Object
Returns:
The hash code value for this interval.
Since:
JViews 7.5

overlaps

public boolean overlaps(IlvTimeInterval interval)
Returns true if the specified time interval overlaps this one.

Parameters:
interval - The interval to test.
Returns:
Whether there is any overlap or intersection with the given interval.
See Also:
intersection(ilog.views.gantt.IlvTimeInterval)

intersection

public IlvTimeInterval intersection(IlvTimeInterval interval)
Returns the intersection of the specified time interval with this one. If there is no overlap, then null is returned.

Parameters:
interval - The interval to compute the intersection.
Returns:
The time interval intersection or null.
Since:
JViews 7.5
See Also:
overlaps(ilog.views.gantt.IlvTimeInterval)

contains

public boolean contains(Date time)
Returns true if the time interval contains the given time.

Parameters:
time - The time to test.
Returns:
Whether the interval contains the time.

toString

public String toString()
Returns a string representation of this time interval.

Overrides:
toString in class Object
Returns:
The string representation of this interval.
Since:
JViews 3.5


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.