You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+92-83Lines changed: 92 additions & 83 deletions
Original file line number
Diff line number
Diff line change
@@ -27,135 +27,144 @@ The iterator has support for [RSCALE](https://tools.ietf.org/html/rfc7529). At t
27
27
28
28
RSCALE is supported in all RFC2445 and RFC5545 modes.
29
29
30
-
## Example code
30
+
## Recurrence Set API
31
31
32
-
### Iterating instances
32
+
In addition to interpreting recurrence rules, this library provides a set of classes to determine the result of any combination of rrules, rdates and exdates (and exrules, for that matter) as specified in RFC 5545.
33
33
34
-
The basic use case is to iterate over all instances of a given rule starting on a specific day. Note that some rules may recur forever. In that case you must limit the number of instances in order to avoid an infinite loop.
34
+
Version 0.16.0 introduces a new API that is slightly different from the previous one. The new API fixes a few design issues that
35
+
made the code more complex than necessary.
35
36
36
-
The following code iterates over the instances of a recurrence rule:
37
+
There is a new interface called `RecurrenceSet` that is implemented by a couple of adapters, decorators and composites. A `RecurrenceSet`
38
+
represents the set of occurrences of a recurrence rule or list or any combination of them (including exclusions).
37
39
38
-
39
-
```java
40
-
DateTime start =RecurrenceRuleIterator it = rule.iterator(start);
40
+
`RecurrenceSet` extends the `Iterable` interface, so it can be used with any `Iterable` decorator from the jems2 library and in `for` loops.
41
41
42
-
int maxInstances =100; // limit instances for rules that recur forever
42
+
### Iterating RRules
43
43
44
-
while (it.hasNext() && (!rule.isInfinite() || maxInstances-->0))
45
-
{
46
-
DateTime nextInstance = it.nextDateTime();
47
-
// do something with nextInstance
48
-
}
49
-
```
44
+
The most common use case is probably just iterating the occurrences of recurrence rules. Although you still can do this using the `RecurrenceRuleIterator`
45
+
returned by `RecurrenceRule.iterator(DateTime)`, you may be better off using the `OfRule` adapter that implements the regular
46
+
`Iterable` interface.
50
47
51
-
###Iterating Recurrence Sets
48
+
#### Examples
52
49
53
-
This library also supports processing of EXRULEs, RDATEs and EXDATEs, i.e. complete recurrence sets.
Note, that `new FastForwarded(fastForwardTo, new OfRule(rrule, start))` and `new OfRule(rrule, fastForwardTo)` are not necessarily the same
153
+
set of occurrences.
154
+
155
+
147
156
148
-
####Dealing with infinite rules
157
+
### Dealing with infinite rules
149
158
150
-
Be aware that RRULEs are infinite if they specify neither `COUNT` nor `UNTIL`. This might easily result in an infinite loop when you just iterate over the recurrence set like above.
159
+
Be aware that RRULEs are infinite if they specify neither `COUNT` nor `UNTIL`. This might easily result in an infinite loop if not taken care of.
151
160
152
-
One way to address this is by adding a decorator like `First` from the `jems2` library:
161
+
As stated above, a simple way to deal with this is by applying a decorator like `First`or `While`from the jems2 library:
0 commit comments