Class PortRange


  • public class PortRange
    extends java.lang.Object
    Immutable class representing a port range.
    Author:
    Gerd Behrmann, Tigran Mkrtchyan
    • Constructor Summary

      Constructors 
      Constructor Description
      PortRange​(int port)
      Creates a port range containing a single port.
      PortRange​(int low, int high)
      Creates a port range with the given bounds (both inclusive).
    • Constructor Detail

      • PortRange

        public PortRange​(int low,
                         int high)
        Creates a port range with the given bounds (both inclusive).
        Parameters:
        low - start of port range
        high - end of port range
        Throws:
        java.lang.IllegalArgumentException - is either bound is not between 1 and 65535, or if high is lower than low.
      • PortRange

        public PortRange​(int port)
        Creates a port range containing a single port.
        Parameters:
        port - port
    • Method Detail

      • valueOf

        public static PortRange valueOf​(java.lang.String s)
                                 throws java.lang.IllegalArgumentException
        Parse a port range. A port range consists of either a single integer, or two integers separated by either a comma or a colon. The bounds must be between 1 and 65535, both inclusive.
        Parameters:
        s - either "number" or "number:number"
        Returns:
        The port range represented by s.
        Throws:
        java.lang.IllegalArgumentException
      • getLower

        public int getLower()
      • getUpper

        public int getUpper()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object