Class PortRange

java.lang.Object
com.pervasive.datarush.io.PortRange
All Implemented Interfaces:
Iterable<Integer>

public class PortRange extends Object implements Iterable<Integer>
  • Constructor Details

    • PortRange

      public PortRange()
      Create an empty port range.
    • PortRange

      public PortRange(Set<Integer> rangeSet)
      Create a port range including all elements in a set.
      Parameters:
      rangeSet - the elements of the ranges
  • Method Details

    • createPortRange

      public static PortRange createPortRange(String ranges)
      This method can be used to create sets containing all the possible values in a multiple partial ranges. Creates a range set from a string in the form: ::= | - | , This is useful when handling port ranges.
      Parameters:
      ranges - a string with the required format
      Returns:
      a disjoint range containing all the possible values
    • size

      public int size()
      Returns the number of elements in the range.
      Returns:
      number of elements in this range
    • contains

      public boolean contains(int i)
      Returns true if this range contains the specified element.
      Parameters:
      i - element to be checked for containment in this range
      Returns:
      true if this range contains the element
    • getRandomElement

      public Integer getRandomElement()
      Returns a random element contained by the port range or null if the range is empty.
      Returns:
      a random element
    • iterator

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