net.fortuna.ical4j.model
Class PeriodList

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractSet
          extended byjava.util.TreeSet
              extended bynet.fortuna.ical4j.model.PeriodList
All Implemented Interfaces:
Cloneable, Collection, Serializable, Set, SortedSet

public class PeriodList
extends TreeSet
implements Serializable

Defines a list of iCalendar periods. NOTE: By implementing the java.util.SortedSet interface period lists will always be sorted according to natural ordering.

Author:
Ben Fortuna
See Also:
Serialized Form

Constructor Summary
PeriodList()
          Default constructor.
PeriodList(String aValue)
          Parses the specified string representation to create a list of periods.
 
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.
 PeriodList normalise()
          Returns a normalised version of this period list.
 boolean remove(Period period)
          Remove a period from the list.
 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()
           
 
Methods inherited from class java.util.TreeSet
addAll, clear, clone, comparator, contains, first, headSet, isEmpty, iterator, last, remove, size, subSet, tailSet
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
 

Constructor Detail

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
Throws:
ParseException - thrown when an invalid string representation of a period list is specified
Method Detail

toString

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

add

public final boolean add(Period period)
Add a period to the list.

Parameters:
period - the period to add
Returns:
true
See Also:
List.add(java.lang.Object)

add

public final boolean add(Object arg0)
Overrides superclass to throw an IllegalArgumentException where argument is not a net.fortuna.ical4j.model.Period.

Specified by:
add in interface Set
See Also:
List#add(E)

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:
List.remove(java.lang.Object)

normalise

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

Returns:
a period list

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 -

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.

Returns:
a period list