Package net.fortuna.ical4j.model
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 thejava.util.SortedSet
interface period lists will always be sorted according to natural ordering.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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<? extends Period> 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<Period>
iterator()
PeriodList
normalise()
Returns a normalised version of this period list.boolean
remove(Object 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()
<T> T[]
toArray(T[] arg0)
String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
spliterator
-
-
-
-
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
-
add
public final boolean add(Period period)
Add a period to the list.- Specified by:
add
in interfaceCollection<Period>
- Specified by:
add
in interfaceSet<Period>
- Parameters:
period
- the period to add- Returns:
- true
- See Also:
List.add(java.lang.Object)
-
remove
public final boolean remove(Object period)
Remove a period from the list.- Specified by:
remove
in interfaceCollection<Period>
- Specified by:
remove
in interfaceSet<Period>
- 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.
-
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)
-
clear
public void clear()
-
contains
public boolean contains(Object o)
-
containsAll
public boolean containsAll(Collection<?> arg0)
- Specified by:
containsAll
in interfaceCollection<Period>
- Specified by:
containsAll
in interfaceSet<Period>
-
isEmpty
public boolean isEmpty()
-
removeAll
public boolean removeAll(Collection<?> arg0)
-
retainAll
public boolean retainAll(Collection<?> arg0)
-
size
public int size()
-
toArray
public Object[] toArray()
-
toArray
public <T> T[] toArray(T[] arg0)
-
equals
public boolean equals(Object obj)
-
-