Class IdRange

java.lang.Object
com.icegreen.greenmail.imap.commands.IdRange

public class IdRange extends Object
Represents a range of UID values.

From rfc3501 :

seq-number = nz-number / "*" ; message sequence number (COPY, FETCH, STORE ; commands) or unique identifier (UID COPY, ; UID FETCH, UID STORE commands). ; * represents the largest number in use. In ; the case of message sequence numbers, it is ; the number of messages in a non-empty mailbox. ; In the case of unique identifiers, it is the ; unique identifier of the last message in the ; mailbox or, if the mailbox is empty, the ; mailbox's current UIDNEXT value. ; The server should respond with a tagged BAD ; response to a command that uses a message ; sequence number greater than the number of ; messages in the selected mailbox. This ; includes "*" if the selected mailbox is empty.

seq-range = seq-number ":" seq-number ; two seq-number values and all values between ; these two regardless of order. ; Example: 2:4 and 4:2 are equivalent and indicate ; values 2, 3, and 4. ; Example: a unique identifier sequence range of ; 3291:* includes the UID of the last message in ; the mailbox, even if that value is less than 3291.

sequence-set = (seq-number / seq-range) *("," sequence-set) ; set of seq-number values, regardless of order. ; Servers MAY coalesce overlaps and/or execute the ; sequence in any order. ; Example: a message sequence number set of ; 2,4:7,9,12:* for a mailbox with 15 messages is ; equivalent to 2,4,5,6,7,9,12,13,14,15 ; Example: a message sequence number set of *:4,5:7 ; for a mailbox with 10 messages is equivalent to ; 10,9,8,7,6,5,4,5,6,7 and MAY be reordered and ; overlap coalesced to be 4,5,6,7,8,9,10.

  • Field Details

    • SEQUENCE

      public static final Pattern SEQUENCE
      Matches a sequence of a single id or id range
    • VALUE_WILDCARD

      public static final long VALUE_WILDCARD
      See Also:
  • Constructor Details

    • IdRange

      public IdRange(long singleVal)
    • IdRange

      public IdRange(long lowVal, long highVal)
  • Method Details

    • getLowVal

      public long getLowVal()
    • getHighVal

      public long getHighVal()
    • includes

      public boolean includes(long uid)
    • parseRangeSequence

      public static List<IdRange> parseRangeSequence(String idRangeSequence)
      Parses an uid sequence, a comma separated list of uid ranges. Note that the wildcard '*' denotes the largest number in use.

      Example: 1,2:5,8:*

      Parameters:
      idRangeSequence - the sequence
      Returns:
      a list of ranges, never null.
    • parseRange

      public static IdRange parseRange(String range)
      Parses a single id range, eg "1" or "1:2" or "4:*".
      Parameters:
      range - the range.
      Returns:
      the parsed id range.
    • convertUidsToIdRangeArray

      public static IdRange[] convertUidsToIdRangeArray(List<Long> uids)
    • uidsToRangeString

      public static String uidsToRangeString(List<Long> uids)
    • idRangeToString

      public static String idRangeToString(IdRange idRange)
    • idRangesToString

      public static String idRangesToString(IdRange[] idRanges)
    • containsUid

      public static boolean containsUid(IdRange[] idRanges, long uid)
      Checks if ranges contain the uid
      Parameters:
      idRanges - the id ranges
      uid - the uid
      Returns:
      true, if ranges contain given uid
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object