net.fortuna.ical4j.model
Class PeriodList

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

public class PeriodList
extends Object
implements Set, 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.

Author:
Ben Fortuna
See Also:
Serialized Form

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

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

Specified by:
add in interface Collection
Specified by:
add in interface 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

isUnmodifiable

public final boolean isUnmodifiable()

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 final boolean addAll(Collection arg0)

Specified by:
addAll in interface Collection
Specified by:
addAll in interface Set

clear

public final void clear()

Specified by:
clear in interface Collection
Specified by:
clear in interface Set

contains

public final boolean contains(Object o)

Specified by:
contains in interface Collection
Specified by:
contains in interface Set

containsAll

public final boolean containsAll(Collection arg0)

Specified by:
containsAll in interface Collection
Specified by:
containsAll in interface Set

isEmpty

public final boolean isEmpty()

Specified by:
isEmpty in interface Collection
Specified by:
isEmpty in interface Set

iterator

public final Iterator iterator()

Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Specified by:
iterator in interface Set

remove

public final boolean remove(Object o)

Specified by:
remove in interface Collection
Specified by:
remove in interface Set

removeAll

public final boolean removeAll(Collection arg0)

Specified by:
removeAll in interface Collection
Specified by:
removeAll in interface Set

retainAll

public final boolean retainAll(Collection arg0)

Specified by:
retainAll in interface Collection
Specified by:
retainAll in interface Set

size

public final int size()

Specified by:
size in interface Collection
Specified by:
size in interface Set

toArray

public final Object[] toArray()

Specified by:
toArray in interface Collection
Specified by:
toArray in interface Set

toArray

public final Object[] toArray(Object[] arg0)

Specified by:
toArray in interface Collection
Specified by:
toArray in interface Set

equals

public final boolean equals(Object obj)
Specified by:
equals in interface Collection
Specified by:
equals in interface Set
Overrides:
equals in class Object

hashCode

public final int hashCode()
Specified by:
hashCode in interface Collection
Specified by:
hashCode in interface Set
Overrides:
hashCode in class Object


Copyright © 2004-2012 Micronode. All Rights Reserved.