Class MultiRange

java.lang.Object
uk.ac.diamond.scisoft.analysis.MultiRange

public class MultiRange extends Object
A multi-range is specified by a string comprising comma-separated (or semicolon-separated) sub-ranges. Each sub-range can be a single integer or two integers (start/end) separated by a colon. Integers can be negative to imply a count from the end of the range. The end integer must be greater than the start integer. The end integer of sub-ranges is inclusive. Also the last sub-range can omit the end integer. Finally, each sub-range can be excluded with an exclamation mark prefix; if any exclamation mark appears in a multi-range string then the default is that the entire range is included and specified sub-ranges with "!" are excluded.

Some example sub-ranges:

"1"
second item (items are labelled from 0)
"-1"
last item
"-2"
second last item
"2:5" or "2 : 5"
third to sixth inclusive
"-3:-1" or "-3 : -1"
third last to last inclusive
"!3"
all bar fourth item
"!5:-2"
sixth to second last excluded
  • Method Details

    • createMultiRange

      public static MultiRange createMultiRange(String multiRangeSpec)
      Parameters:
      multiRangeSpec -
      Returns:
      multi-range
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getMinimum

      public long getMinimum()
      Returns:
      minimum integer specified
    • getMaximum

      public long getMaximum()
      Returns:
      maximum integer specified
    • contains

      public boolean contains(int size, int i)
      Parameters:
      size -
      i -
      Returns:
      true if given value is in multi-range
    • parseMultiRange

      public void parseMultiRange(String multiRangeSpec)
      Parse given specifier for a multi-range
      Parameters:
      multiRangeSpec -