com.miginfocom.calendar.activity.recurrence
Class CompositeRecurrence

java.lang.Object
  extended by com.miginfocom.calendar.activity.recurrence.CompositeRecurrence
All Implemented Interfaces:
Recurrence

public class CompositeRecurrence
extends java.lang.Object
implements Recurrence

A class that can contain a number of recurrence elements, both inclucive (RFC 2445: RRULE, RDATE) and excluding (RFC 2445: EXRULE, EXDATE).

RFC 2445


Constructor Summary
CompositeRecurrence()
           
 
Method Summary
 void addExcludingRange(ImmutableDateRange dateRange)
          Adds a range to always exclude from the recurring events.
 void addExcludingRecurrence(Recurrence recur)
          Adds a recurrence to always exclude to the recurring events.
 void addIncludingRange(ImmutableDateRange dateRange)
          Adds a ImmutableDateRange to always include to the recurring events.
 void addIncludingRecurrence(Recurrence recur)
          Adds a recurrence to always include to the recurring events.
 java.util.ArrayList getDateRanges(DateRangeI baseRange, DateRangeI withinRange, boolean optimizeRange)
          Returns the recurrence date ranges that has its start date within withinRange.
 java.util.ArrayList getExcludingRanges()
          Returns the excluding ImmutableDateRanges or null if no such ranges exists.
 java.util.ArrayList getExcludingRecurrencies()
          Returns the excluding Recurrences or null if no such recurrencies exists.
 java.util.ArrayList getIncludingRanges()
          Returns the including ImmutableDateRanges or null if no such ranges exists.
 java.util.ArrayList getIncludingRecurrencies()
          Returns the included Recurrences or null if no such recurrencies exists.
 java.lang.Long getLastRecurrenceMillis(DateRangeI baseRange, java.util.Calendar max)
          Returns the end date (millisecond inclusive) of the last recurrence or null if the recurrence will continue forever.
 boolean isIncludeBaseDateRange()
          Returns if the base date range is always included in the date ranges returned.
 boolean isRepeatingForever()
          Returns if this recurrence has no end limit and will thus be repeating forever.
protected  void mergeRanges(DateRangeI baseRange, java.util.ArrayList source, java.util.ArrayList dest)
          If there are any ranges that are to be included "on top" (RDATE) add them.
protected  java.util.ArrayList removeOverlappingRanges(java.util.ArrayList source, java.util.ArrayList dest)
          Removes from dest all date ranges that overlaps any date range in source.
 void setExcludingRanges(java.util.ArrayList dateRanges)
          Sets a number of ImmutableDateRanges to always exclude to the recurring events.
 void setExcludingRecurrencies(java.util.ArrayList recurs)
          Sets a number of Recurrences to always exclude to the recurring events.
 void setIncludeBaseDateRange(boolean b)
          Sets if the base date range is always included in the date ranges returned.
 void setIncludingRanges(java.util.ArrayList dateRanges)
          Sets a number of ImmutableDateRanges to always include to the recurring events.
 void setIncludingRecurrencies(java.util.ArrayList recurs)
          Sets a number of Recurrences to always include to the recurring events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeRecurrence

public CompositeRecurrence()
Method Detail

getDateRanges

public java.util.ArrayList getDateRanges(DateRangeI baseRange,
                                         DateRangeI withinRange,
                                         boolean optimizeRange)
Description copied from interface: Recurrence
Returns the recurrence date ranges that has its start date within withinRange. baseRange will be part of the returned list unless excluded by any of the contained excluding rules or not within withinRange.

Specified by:
getDateRanges in interface Recurrence
Parameters:
baseRange - The range on which to base the returned ranges. Called DTSTART/DTEND in RFC 2445 (iCalendar). This is the first dateRange in the recurrence.
withinRange - All returned ranges will have touch this range. Never null.
optimizeRange - Optimizes the recurrence rule for withinRange. Set to false if the recurrence is bugging. This is working in the tests but the algorithm is quite advanced and is a bit hard to find all possibilities for how this optimization works. Note that this value should not in any way change the returned values, it will only use less computations if set to true.
Returns:
The recurrence date ranges. Never null. The list will not be sorted. Will contain newly created and free to use MutableDateRanges

getLastRecurrenceMillis

public java.lang.Long getLastRecurrenceMillis(DateRangeI baseRange,
                                              java.util.Calendar max)
Description copied from interface: Recurrence
Returns the end date (millisecond inclusive) of the last recurrence or null if the recurrence will continue forever.

Specified by:
getLastRecurrenceMillis in interface Recurrence
Parameters:
baseRange - The range on which to base the recurrence on ranges. Called DTSTART/DTEND in RFC 2445 (iCalendar)
max - If not null the evaluation will never go after this date and this will thus be the latest date possible to return. Since the recurrences have to be evaluated in all to return the last recurrence this can be a safetynet to not make the evaluation take too much time.
Returns:
The end date (millisecond inclusive) of the last recurrence or null if the recurrence will continue forever.

isRepeatingForever

public boolean isRepeatingForever()
Description copied from interface: Recurrence
Returns if this recurrence has no end limit and will thus be repeating forever.

Specified by:
isRepeatingForever in interface Recurrence
Returns:
If this recurrence has no end limit and will thus be repeating forever.

mergeRanges

protected void mergeRanges(DateRangeI baseRange,
                           java.util.ArrayList source,
                           java.util.ArrayList dest)
If there are any ranges that are to be included "on top" (RDATE) add them. If they overlap with a range already in ranges make a union of them.

Parameters:
baseRange - The base range (A.k.a DTSTART in RFC 2445). Will serve as a time/duration template for source ranges that has DateRangeI.getHasTime() set to false or isn't spanning time, respectively. If set to null the source date ranges will not be corrected for time in any way.
source - The ranges that we already have. Of type DateRangeI
dest - The range list that will be added to. If any of the ranges in sources is overlapping any range in dest those are merged into one range instead if added.

removeOverlappingRanges

protected java.util.ArrayList removeOverlappingRanges(java.util.ArrayList source,
                                                      java.util.ArrayList dest)
Removes from dest all date ranges that overlaps any date range in source.

Parameters:
source - The date ranges to check against dest.
dest - The array to remove date ranges from. this instance won't be changed though, a new array or this one will be returned depending on if there was some removes or not.
Returns:
A list with source removed from dest. If nothing was overlapping, dest will be returned.

addIncludingRange

public void addIncludingRange(ImmutableDateRange dateRange)
Adds a ImmutableDateRange to always include to the recurring events. Compare to for instance RDATE in RFC 2445.

Parameters:
dateRange - A range to include. Not null and must be sorted.

isIncludeBaseDateRange

public boolean isIncludeBaseDateRange()
Returns if the base date range is always included in the date ranges returned.

Returns:
If the base date range is always included in the date ranges returned. Default is false.
Since:
6.0

setIncludeBaseDateRange

public void setIncludeBaseDateRange(boolean b)
Sets if the base date range is always included in the date ranges returned.

Parameters:
b - If the base date range is always included in the date ranges returned. Default is false.
Since:
6.0

setIncludingRanges

public void setIncludingRanges(java.util.ArrayList dateRanges)
Sets a number of ImmutableDateRanges to always include to the recurring events. Compare to for instance RDATE in RFC 2445.

Parameters:
dateRanges - A number of date ranges (ImmutableDateRange to include or null to clear. Reference is overtaken.

getIncludingRanges

public java.util.ArrayList getIncludingRanges()
Returns the including ImmutableDateRanges or null if no such ranges exists.

Returns:
The including ranges or null if no such ranges exists. The live array, can be modified but the recurrence itself is not synchronized in any way, so be careful.

addExcludingRange

public void addExcludingRange(ImmutableDateRange dateRange)
Adds a range to always exclude from the recurring events. Compare to for instance EXDATE in RFC 2445.

Parameters:
dateRange - A range to exclude. Not null and must be sorted.

setExcludingRanges

public void setExcludingRanges(java.util.ArrayList dateRanges)
Sets a number of ImmutableDateRanges to always exclude to the recurring events. Compare to for instance EXDATE in RFC 2445.

Parameters:
dateRanges - A number of date ranges (ImmutableDateRange to exclude or null to clear. Reference is overtaken.

getExcludingRanges

public java.util.ArrayList getExcludingRanges()
Returns the excluding ImmutableDateRanges or null if no such ranges exists.

Returns:
The excluding ranges or null if no such ranges exists. The live array, can be modified but the recurrence itself is not synchronized in any way so be careful.

addIncludingRecurrence

public void addIncludingRecurrence(Recurrence recur)
Adds a recurrence to always include to the recurring events. Compareable to RRULE in RFC 2445.

Parameters:
recur - A recurrence to add. Not null.

setIncludingRecurrencies

public void setIncludingRecurrencies(java.util.ArrayList recurs)
Sets a number of Recurrences to always include to the recurring events. Compareable to RRULE in RFC 2445.

Parameters:
recurs - A number of Recurrences to include or null to clear. Reference is overtaken.

getIncludingRecurrencies

public java.util.ArrayList getIncludingRecurrencies()
Returns the included Recurrences or null if no such recurrencies exists.

Returns:
The included Recurrences or null if no such recurrencies exists. The live array, can be modified but the recurrence itself is not synchronized in any way, so be careful.

addExcludingRecurrence

public void addExcludingRecurrence(Recurrence recur)
Adds a recurrence to always exclude to the recurring events. Compareable to EXRULE in RFC 2445.

Parameters:
recur - A recurrence to exclude. Not null.

setExcludingRecurrencies

public void setExcludingRecurrencies(java.util.ArrayList recurs)
Sets a number of Recurrences to always exclude to the recurring events. Compareable to EXRULE in RFC 2445.

Parameters:
recurs - A number of Recurrences to exclude or null to clear. Reference is overtaken.

getExcludingRecurrencies

public java.util.ArrayList getExcludingRecurrencies()
Returns the excluding Recurrences or null if no such recurrencies exists.

Returns:
The excluding Recurrences or null if no such recurrencies exists. The live array, can be modified but the recurrence itself is not synchronized in any way, so be careful.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.