net.fortuna.ical4j.model
Class PeriodList

java.lang.Object
  extended by net.fortuna.ical4j.model.PeriodList
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable, java.util.Collection, java.util.Set

public class PeriodList
extends java.lang.Object
implements java.util.Set, java.io.Serializable

$Id: PeriodList.java,v 1.33 2011/03/19 06:27:42 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.

Author:
Ben Fortuna
See Also:
Serialized Form

Constructor Summary
PeriodList()
          Default constructor.
PeriodList(boolean utc)
           
PeriodList(boolean utc, boolean unmodifiable)
           
PeriodList(java.lang.String aValue)
          Parses the specified string representation to create a list of periods.
 
Method Summary
 boolean add(java.lang.Object period)
          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 combines all the periods in the specified list to this list.
 boolean addAll(java.util.Collection arg0)
          
 void clear()
          
 boolean contains(java.lang.Object o)
          
 boolean containsAll(java.util.Collection arg0)
          
 boolean equals(java.lang.Object obj)
           
 TimeZone getTimeZone()
           
 int hashCode()
           
 boolean isEmpty()
          
 boolean isUtc()
          Indicates whether this list is in local or UTC format.
 java.util.Iterator iterator()
          
 PeriodList normalise()
          Returns a normalised version of this period list.
 boolean remove(java.lang.Object o)
          
 boolean remove(Period period)
          Remove a period from the list.
 boolean removeAll(java.util.Collection arg0)
          
 boolean retainAll(java.util.Collection arg0)
          
 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.
 int size()
          
 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.
 java.lang.Object[] toArray()
          
 java.lang.Object[] toArray(java.lang.Object[] arg0)
          
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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(java.lang.String aValue)
           throws java.text.ParseException
Parses the specified string representation to create a list of periods.

Parameters:
aValue - a string representation of a list of periods
Throws:
java.text.ParseException - thrown when an invalid string representation of a period list is specified
Method Detail

toString

public final java.lang.String toString()

Overrides:
toString in class java.lang.Object

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(java.lang.Object period)
Overrides superclass to throw an IllegalArgumentException where argument is not a net.fortuna.ical4j.model.Period.

Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.Set
Parameters:
period - a period to add to the list
Returns:
true if the period was added, otherwise false
See Also:
java.util.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, 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.

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(java.util.Collection arg0)

Specified by:
addAll in interface java.util.Collection
Specified by:
addAll in interface java.util.Set

clear

public void clear()

Specified by:
clear in interface java.util.Collection
Specified by:
clear in interface java.util.Set

contains

public boolean contains(java.lang.Object o)

Specified by:
contains in interface java.util.Collection
Specified by:
contains in interface java.util.Set

containsAll

public boolean containsAll(java.util.Collection arg0)

Specified by:
containsAll in interface java.util.Collection
Specified by:
containsAll in interface java.util.Set

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface java.util.Collection
Specified by:
isEmpty in interface java.util.Set

iterator

public java.util.Iterator iterator()

Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Specified by:
iterator in interface java.util.Set

remove

public boolean remove(java.lang.Object o)

Specified by:
remove in interface java.util.Collection
Specified by:
remove in interface java.util.Set

removeAll

public boolean removeAll(java.util.Collection arg0)

Specified by:
removeAll in interface java.util.Collection
Specified by:
removeAll in interface java.util.Set

retainAll

public boolean retainAll(java.util.Collection arg0)

Specified by:
retainAll in interface java.util.Collection
Specified by:
retainAll in interface java.util.Set

size

public int size()

Specified by:
size in interface java.util.Collection
Specified by:
size in interface java.util.Set

toArray

public java.lang.Object[] toArray()

Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.Set

toArray

public java.lang.Object[] toArray(java.lang.Object[] arg0)

Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.Set

equals

public boolean equals(java.lang.Object obj)
Specified by:
equals in interface java.util.Collection
Specified by:
equals in interface java.util.Set
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection
Specified by:
hashCode in interface java.util.Set
Overrides:
hashCode in class java.lang.Object


Copyright © 2004-2011 Modularity. All Rights Reserved.