Class PeriodList

java.lang.Object
net.fortuna.ical4j.model.PeriodList
All Implemented Interfaces:
Serializable, Iterable<Period>, Collection<Period>, Set<Period>

public class PeriodList extends Object implements Set<Period>, Serializable
$Id$ [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.
See Also:
  • Constructor Details

    • PeriodList

      public PeriodList()
      Default constructor.
    • PeriodList

      public PeriodList(boolean utc)
      Parameters:
      utc - indicates whether the period list is in UTC time
    • PeriodList

      public PeriodList(boolean utc, boolean unmodifiable)
      Parameters:
      utc - indicates whether the period list is in UTC time
    • 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 Details

    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • add

      public final boolean add(Period period)
      Add a period to the list.
      Specified by:
      add in interface Collection<Period>
      Specified by:
      add in interface Set<Period>
      Parameters:
      period - the period to add
      Returns:
      true
      See Also:
    • remove

      public final boolean remove(Object period)
      Remove a period from the list.
      Specified by:
      remove in interface Collection<Period>
      Specified by:
      remove in interface Set<Period>
      Parameters:
      period - the period to remove
      Returns:
      true if the list contained the specified period
      See Also:
    • 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
    • add

      public final PeriodList add(PeriodList periods)
      A convenience method that combines all the periods in the specified list to this list. The result returned is a new PeriodList instance, except where no periods are specified in the arguments. In such cases this instance is returned. Normalisation is also performed automatically after all periods have been added.
      Parameters:
      periods - a list of periods to add
      Returns:
      a period list instance
    • 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:
      subtractions - a list of periods to subtract from this list
      Returns:
      a period list
    • isUtc

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

      public boolean isUnmodifiable()
    • setUtc

      public final void setUtc(boolean utc)
      Sets whether this list is in UTC or local time format.
      Parameters:
      utc - The utc to set.
    • 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:
      timeZone - the timezone for the period list
    • getTimeZone

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

      public boolean addAll(Collection<? extends Period> arg0)
      Specified by:
      addAll in interface Collection<Period>
      Specified by:
      addAll in interface Set<Period>
    • clear

      public void clear()
      Specified by:
      clear in interface Collection<Period>
      Specified by:
      clear in interface Set<Period>
    • contains

      public boolean contains(Object o)
      Specified by:
      contains in interface Collection<Period>
      Specified by:
      contains in interface Set<Period>
    • containsAll

      public boolean containsAll(Collection<?> arg0)
      Specified by:
      containsAll in interface Collection<Period>
      Specified by:
      containsAll in interface Set<Period>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Collection<Period>
      Specified by:
      isEmpty in interface Set<Period>
    • iterator

      public Iterator<Period> iterator()
      Specified by:
      iterator in interface Collection<Period>
      Specified by:
      iterator in interface Iterable<Period>
      Specified by:
      iterator in interface Set<Period>
    • removeAll

      public boolean removeAll(Collection<?> arg0)
      Specified by:
      removeAll in interface Collection<Period>
      Specified by:
      removeAll in interface Set<Period>
    • retainAll

      public boolean retainAll(Collection<?> arg0)
      Specified by:
      retainAll in interface Collection<Period>
      Specified by:
      retainAll in interface Set<Period>
    • size

      public int size()
      Specified by:
      size in interface Collection<Period>
      Specified by:
      size in interface Set<Period>
    • toArray

      public Object[] toArray()
      Specified by:
      toArray in interface Collection<Period>
      Specified by:
      toArray in interface Set<Period>
    • toArray

      public <T> T[] toArray(T[] arg0)
      Specified by:
      toArray in interface Collection<Period>
      Specified by:
      toArray in interface Set<Period>
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Collection<Period>
      Specified by:
      equals in interface Set<Period>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Collection<Period>
      Specified by:
      hashCode in interface Set<Period>
      Overrides:
      hashCode in class Object