Class RecurrenceRuleIterator

java.lang.Object
org.dmfs.rfc5545.recur.RecurrenceRuleIterator

public final class RecurrenceRuleIterator extends Object
An iterator for recurrence rules.

Note: Some rules may recur forever, so be sure to add some limitation to your code that stops iterating after a certain number of instances or at a certain date.

  • Method Details

    • nextMillis

      public long nextMillis()
      Get the next instance. The instances are guaranteed to be strictly increasing in time.
      Returns:
      A time stamp of the next instance.
    • nextDateTime

      public org.dmfs.rfc5545.DateTime nextDateTime()
      Get the next instance. The instances are guaranteed to be strictly increasing in time.
      Returns:
      A DateTime object for the next instance.
    • hasNext

      public boolean hasNext()
    • peekMillis

      public long peekMillis()
      Peek at the next instance to be returned by nextMillis() without actually iterating it. Calling this method (even multiple times) won't affect the instances returned by nextMillis().
      Returns:
      the upcoming instance or null if there are no more instances.
    • peekDateTime

      public org.dmfs.rfc5545.DateTime peekDateTime()
      Peek at the next instance to be returned by nextDateTime() without actually iterating it. Calling this method (even multiple times) won't affect the instances returned by nextDateTime().
      Returns:
      the upcoming instance or null if there are no more instances.
    • skip

      public void skip(int skip)
      Skip the given number of instances.

      Note: After calling this method you should call hasNext() before you continue because there might be less than skip instances left when you call this.

      Parameters:
      skip - The number of instances to skip.
    • fastForward

      public void fastForward(long until)
      Skip all instances up to a specific date.

      Note: After calling this method you should call hasNext() before you continue because there might no more instances left if there is an UNTIL or COUNT part in the rule.

      Parameters:
      until - The time stamp of earliest date to be returned by the next call to nextMillis() or nextDateTime().
    • fastForward

      public void fastForward(org.dmfs.rfc5545.DateTime until)
      Skip all instances up to a specific date.

      Note: After calling this method you should call hasNext() before you continue because there might no more instances left if there is an UNTIL or COUNT part in the rule.

      Parameters:
      until - The earliest date to be returned by the next call to nextMillis() or nextDateTime().
    • skipAllButLast

      public void skipAllButLast()
      Skips all instances except for the last one. Ensure to call hasNext() before calling nextMillis() or nextDateTime() after you called this.

      Note: At present this will loop infinitely when called on an infinite rule. So better check RecurrenceRule.isInfinite() first.