net.fortuna.ical4j.model

Class PeriodList

Implemented Interfaces:
Serializable

public class PeriodList
extends TreeSet
implements Serializable

$Id: PeriodList.java,v 1.23 2008/12/16 12:34:52 fortuna Exp $ [23-Apr-2004] Defines a list of iCalendar periods. NOTE: By implementing the java.util.SortedSet interface period lists will always be sorted according to natural ordering.

Constructor Summary

PeriodList()
Default constructor.
PeriodList(String aValue)
Parses the specified string representation to create a list of periods.
PeriodList(boolean utc)

Method Summary

boolean
add(Object arg0)
Overrides superclass to throw an IllegalArgumentException where argument is not a net.fortuna.ical4j.model.Period.
boolean
add(Period period)
Add a period to the list.
PeriodList
add(PeriodList periods)
A convenience method that adds all the periods in the specified list to this list.
TimeZone
getTimeZone()
boolean
isUtc()
Indicates whether this list is in local or UTC format.
PeriodList
normalise()
Returns a normalised version of this period list.
boolean
remove(Period period)
Remove a period from the list.
void
setTimeZone(TimeZone timeZone)
Applies the specified timezone to all dates in the list.
void
setUtc(boolean utc)
Sets whether this list is in UTC or local time format.
PeriodList
subtract(PeriodList subtractions)
Subtracts the intersection of this list with the specified list of periods from this list and returns the results as a new period list.
String
toString()

Constructor Details

PeriodList

public PeriodList()
Default constructor.

PeriodList

public PeriodList(String aValue)
            throws ParseException
Parses the specified string representation to create a list of periods.
Parameters:
aValue - a string representation of a list of periods

PeriodList

public PeriodList(boolean utc)
Parameters:
utc -

Method Details

add

public final boolean add(Object arg0)
Overrides superclass to throw an IllegalArgumentException where argument is not a net.fortuna.ical4j.model.Period.
See Also:
java.util.List.add(E)

add

public final boolean add(Period period)
Add a period to the list.
Parameters:
period - the period to add
Returns:
true
See Also:
java.util.List.add(java.lang.Object)

add

public final PeriodList add(PeriodList periods)
A convenience method that adds all the periods in the specified list to this list. Normalisation is also performed automatically after all periods have been added.
Parameters:
periods -

getTimeZone

public final TimeZone getTimeZone()
Returns:
Returns the timeZone.

isUtc

public final boolean isUtc()
Indicates whether this list is in local or UTC format.
Returns:
Returns true if in UTC format, otherwise false.

normalise

public final PeriodList normalise()
Returns a normalised version of this period list. Normalisation includes combining overlapping periods, removing periods contained by other periods, combining adjacent periods, and removing periods that consume no time. NOTE: If the period list is already normalised then this period list is returned.
Returns:
a period list

remove

public final boolean remove(Period period)
Remove a period from the list.
Parameters:
period - the period to remove
Returns:
true if the list contained the specified period
See Also:
java.util.List.remove(java.lang.Object)

setTimeZone

public final void setTimeZone(TimeZone timeZone)
Applies the specified timezone to all dates in the list. All dates added to this list will also have this timezone applied.
Parameters:

setUtc

public final void setUtc(boolean utc)
Sets whether this list is in UTC or local time format.
Parameters:
utc - The utc to set.

subtract

public final PeriodList subtract(PeriodList subtractions)
Subtracts the intersection of this list with the specified list of periods from this list and returns the results as a new period list. If no intersection is identified this list is returned.
Parameters:
Returns:
a period list

toString

public final String toString()
See Also:
java.util.AbstractCollection.toString()