Package digilib.util

Class NumRange

java.lang.Object
digilib.util.NumRange
All Implemented Interfaces:
Iterable<Integer>

public class NumRange extends Object implements Iterable<Integer>
Class that parses String with intervals into Iterable sequence of integers. Intervals are separated by comma ','. An interval is a range represented by two numbers and a hyphen e.g. "3-6". If the second number is omitted the interval goes to maxnum. An interval can also consist of a single number e.g. "7". Valid NumRanges: "1-10,13-20", "3,5,9", "1-".
Author:
casties
  • Constructor Details

    • NumRange

      public NumRange(Integer start, Integer end)
      Parameters:
      start - the start
      end - the end
    • NumRange

      public NumRange(String range)
      Parameters:
      range - the range
    • NumRange

      public NumRange(String range, Integer max)
      Parameters:
      range - the range
      max - the maximum
  • Method Details

    • parseString

      public void parseString(String pages)
      Parameters:
      pages - the pages
    • getStart

      public int getStart()
      Returns:
      the start
    • getEnd

      public int getEnd()
      Returns:
      the end
    • iterator

      public Iterator<Integer> iterator()
      Specified by:
      iterator in interface Iterable<Integer>
    • setMaxnum

      public void setMaxnum(Integer maxnum)
      Parameters:
      maxnum - the max num