Compoze Software, Inc.

portlets.compoze.groupware.calendar
Class DateRange

java.lang.Object
  extended byportlets.compoze.groupware.calendar.DateRange
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class DateRange
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable

This class represents a duration in time, consisting of a start and an end date. Either date may be null, which indicates that the duration extends infinitely in time in that direction. It is always assured upon construction and modification of the starting and ending dates that the start is before the end.

See Also:
Serialized Form

Field Summary
static int OVERLAP_ADJACENT
          The combination of flags indicating that the second duration in time is adjacent to the first.
static int OVERLAP_ADJACENT_AFTER
          The flag indicating that the second duration in time occurs partially after the first duration.
static int OVERLAP_ADJACENT_BEFORE
          The flag indicating that the second duration in time occurs before the first duration, and its end is equal to the start of the first duration.
static int OVERLAP_ANY
          The combination of flags indicating that the second duration in time occurs partially before, within, equal to, encompassing, or partially after the first duration.
static int OVERLAP_EARLIER
          The combination of flags indicating that the second duration in time occurs either totally, adjacent to or partially before the first duration.
static int OVERLAP_ENCOMPASS
          The flag indicating that the second duration in time totally encompasses the first duration.
static int OVERLAP_EQUAL
          The flag indicating that the first and second durations are equal.
static int OVERLAP_LATER
          The combination of flags indicating that the second duration in time occurs either totally, adjacent to or partially after the first duration.
static int OVERLAP_NONE
          The combination of flags indicating that the second duration in time does not in any way overlap, or is merely adjacent to the first duration.
static int OVERLAP_PARTIALLY_AFTER
          The flag indicating that the second duration in time occurs partially after the first duration.
static int OVERLAP_PARTIALLY_BEFORE
          The flag indicating that the second duration in time occurs partially before the first duration.
static int OVERLAP_TOTALLY_AFTER
          The flag indicating that the second duration in time occurs totally after the first duration.
static int OVERLAP_TOTALLY_BEFORE
          The flag indicating that the second duration in time occurs totally before the first duration.
static int OVERLAP_WITHIN
          The flag indicating that the second duration in time occurs totally within the first duration.
 
Constructor Summary
DateRange(java.util.Date start, java.util.Date end)
          Constructor.
 
Method Summary
 long addDuration(DateRange duration)
          Adds this duration to another duration.
 java.util.Date addDurationToDate(java.util.Date start)
          Adds this duration to another date.
 void assignDuration(long lDuration)
          Sets the duration of the event by changing the end date if necessary.
 int compareTo(java.lang.Object o)
          Compares this date range with the specified date range for ordering.
 boolean equals(java.lang.Object o)
          Equals.
 long getDuration()
          Gets the duration between the starting and ending dates.
 java.util.Date getEnd()
          Gets the ending date.
 java.util.Date getStart()
          Gets the starting date.
 int overlap(DateRange duration)
          Evaluates the overlap between this and a second duration.
 void setEnd(java.util.Date end)
          Sets the ending date.
 void setStart(java.util.Date start)
          Sets the starting date.
 java.lang.String toString()
          Creates a string representation of the date range.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

OVERLAP_TOTALLY_BEFORE

public static final int OVERLAP_TOTALLY_BEFORE
The flag indicating that the second duration in time occurs totally before the first duration.

See Also:
Constant Field Values

OVERLAP_ADJACENT_BEFORE

public static final int OVERLAP_ADJACENT_BEFORE
The flag indicating that the second duration in time occurs before the first duration, and its end is equal to the start of the first duration.

See Also:
Constant Field Values

OVERLAP_PARTIALLY_BEFORE

public static final int OVERLAP_PARTIALLY_BEFORE
The flag indicating that the second duration in time occurs partially before the first duration.

See Also:
Constant Field Values

OVERLAP_WITHIN

public static final int OVERLAP_WITHIN
The flag indicating that the second duration in time occurs totally within the first duration.

See Also:
Constant Field Values

OVERLAP_EQUAL

public static final int OVERLAP_EQUAL
The flag indicating that the first and second durations are equal.

See Also:
Constant Field Values

OVERLAP_ENCOMPASS

public static final int OVERLAP_ENCOMPASS
The flag indicating that the second duration in time totally encompasses the first duration.

See Also:
Constant Field Values

OVERLAP_PARTIALLY_AFTER

public static final int OVERLAP_PARTIALLY_AFTER
The flag indicating that the second duration in time occurs partially after the first duration.

See Also:
Constant Field Values

OVERLAP_ADJACENT_AFTER

public static final int OVERLAP_ADJACENT_AFTER
The flag indicating that the second duration in time occurs partially after the first duration.

See Also:
Constant Field Values

OVERLAP_TOTALLY_AFTER

public static final int OVERLAP_TOTALLY_AFTER
The flag indicating that the second duration in time occurs totally after the first duration.

See Also:
Constant Field Values

OVERLAP_ANY

public static final int OVERLAP_ANY
The combination of flags indicating that the second duration in time occurs partially before, within, equal to, encompassing, or partially after the first duration.

See Also:
Constant Field Values

OVERLAP_NONE

public static final int OVERLAP_NONE
The combination of flags indicating that the second duration in time does not in any way overlap, or is merely adjacent to the first duration.

See Also:
Constant Field Values

OVERLAP_EARLIER

public static final int OVERLAP_EARLIER
The combination of flags indicating that the second duration in time occurs either totally, adjacent to or partially before the first duration.

See Also:
Constant Field Values

OVERLAP_LATER

public static final int OVERLAP_LATER
The combination of flags indicating that the second duration in time occurs either totally, adjacent to or partially after the first duration.

See Also:
Constant Field Values

OVERLAP_ADJACENT

public static final int OVERLAP_ADJACENT
The combination of flags indicating that the second duration in time is adjacent to the first.

See Also:
Constant Field Values
Constructor Detail

DateRange

public DateRange(java.util.Date start,
                 java.util.Date end)
Constructor.

Parameters:
start - the starting date
end - the ending date
Method Detail

setStart

public void setStart(java.util.Date start)
Sets the starting date.

Parameters:
start - the starting date

getStart

public java.util.Date getStart()
Gets the starting date.

Returns:
the starting date

setEnd

public void setEnd(java.util.Date end)
Sets the ending date.

Parameters:
end - the ending date

getEnd

public java.util.Date getEnd()
Gets the ending date.

Returns:
the ending date

assignDuration

public void assignDuration(long lDuration)
Sets the duration of the event by changing the end date if necessary. The starting date must not be null.

Parameters:
lDuration - the new duration

getDuration

public long getDuration()
Gets the duration between the starting and ending dates.

Returns:
the duration between the start and end (in milliseconds)
Throws:
java.lang.ArithmeticException - if the duration is infinite

addDurationToDate

public java.util.Date addDurationToDate(java.util.Date start)
Adds this duration to another date.

Returns:
a date representing the starting date plus this duration
Throws:
java.lang.ArithmeticException - if the duration is infinite

addDuration

public long addDuration(DateRange duration)
Adds this duration to another duration.

Parameters:
duration - the second duration
Returns:
the total duration (in milliseconds)
Throws:
java.lang.ArithmeticException - if the resulting duration is infinite

overlap

public int overlap(DateRange duration)
Evaluates the overlap between this and a second duration.

Parameters:
duration - the second duration
Returns:
see OVERLAP_ constants in this class

equals

public boolean equals(java.lang.Object o)
Equals.

Parameters:
o - duration to compare to
Returns:
true if the durations are equal (their start and end dates are equal)

compareTo

public int compareTo(java.lang.Object o)
Compares this date range with the specified date range for ordering. The start date is used for comparison.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the other date range
Returns:
a negative integer, zero, or a positive integer as this object is less then, equal to or greater than the specified object

toString

public java.lang.String toString()
Creates a string representation of the date range.

Returns:
the string representation of the date range

Compoze Software, Inc.

Copyright ©1999-2003 Compoze Software, Inc. All rights reserved.