RecurrenceIterator createIterator ( Observance observance ) { List < RecurrenceIterator > inclusions = new ArrayList < RecurrenceIterator > ( ) ; List < RecurrenceIterator > exclusions = new ArrayList < RecurrenceIterator > ( ) ; ICalDate dtstart = getValue ( observance . getDateStart ( ) ) ; if ( dtstart != null ) { DateValue dtstartValue = convertFromRawComponents ( dtstart ) ; //add DTSTART property inclusions . add ( new DateValueRecurrenceIterator ( Arrays . asList ( dtstartValue ) ) ) ; //add RRULE properties for ( RecurrenceRule rrule : observance . getProperties ( RecurrenceRule . class ) ) { Recurrence recur = rrule . getValue ( ) ; if ( recur != null ) { inclusions . add ( RecurrenceIteratorFactory . createRecurrenceIterator ( recur , dtstartValue , utc ) ) ; } } //add EXRULE properties for ( ExceptionRule exrule : observance . getProperties ( ExceptionRule . class ) ) { Recurrence recur = exrule . getValue ( ) ; if ( recur != null ) { exclusions . add ( RecurrenceIteratorFactory . createRecurrenceIterator ( recur , dtstartValue , utc ) ) ; } } } //add RDATE properties List < ICalDate > rdates = new ArrayList < ICalDate > ( ) ; for ( RecurrenceDates rdate : observance . getRecurrenceDates ( ) ) { rdates . addAll ( rdate . getDates ( ) ) ; } Collections . sort ( rdates ) ; inclusions . add ( new DateRecurrenceIterator ( rdates ) ) ; //add EXDATE properties List < ICalDate > exdates = new ArrayList < ICalDate > ( ) ; for ( ExceptionDates exdate : observance . getProperties ( ExceptionDates . class ) ) { exdates . addAll ( exdate . getValues ( ) ) ; } Collections . sort ( exdates ) ; exclusions . add ( new DateRecurrenceIterator ( exdates ) ) ; RecurrenceIterator included = join ( inclusions ) ; if ( exclusions . isEmpty ( ) ) { return included ; } RecurrenceIterator excluded = join ( exclusions ) ; return RecurrenceIteratorFactory . except ( included , excluded ) ; }
Creates an iterator which iterates over each of the dates in an observance .