Enum PortType

  • All Implemented Interfaces:
    PortRange, java.io.Serializable, java.lang.Comparable<PortType>

    public enum PortType
    extends java.lang.Enum<PortType>
    implements PortRange
    Port types
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      ANY
      Any port
      DYNAMIC
      The dynamic ports (aka private or ephemeral ports), these are ports 49152 to 65535 which are never assigned by the IANA
      OS_ALLOCATED
      Port 0 i.e.
      SYSTEM
      The system (aka well known or privileged ports), these are ports 1 to 1023 and usually require adminstrative privileges
      USER
      The user ports (aka registered ports), these are ports 1024 to 49151 and which may be registered and assigned by the IANA
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int max  
      private int min  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private PortType​(int min, int max)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contains​(PortRange other)
      Gets whether the port range contains another port range i.e.
      int getMaximumPort()
      Gets the maximum port
      int getMinimumPort()
      Gets the minimum port
      boolean inRange​(int port)
      Gets whether a port falls within the range
      static java.lang.String toRangesString​(java.util.Set<PortRange> acceptablePorts)
      Gets a string denoting all the acceptable port ranges
      java.lang.String toString()  
      static PortType valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static PortType[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • ANY

        public static final PortType ANY
        Any port
      • OS_ALLOCATED

        public static final PortType OS_ALLOCATED
        Port 0 i.e. the special port that has the OS allocate an available port
      • SYSTEM

        public static final PortType SYSTEM
        The system (aka well known or privileged ports), these are ports 1 to 1023 and usually require adminstrative privileges
      • USER

        public static final PortType USER
        The user ports (aka registered ports), these are ports 1024 to 49151 and which may be registered and assigned by the IANA
      • DYNAMIC

        public static final PortType DYNAMIC
        The dynamic ports (aka private or ephemeral ports), these are ports 49152 to 65535 which are never assigned by the IANA
    • Field Detail

      • min

        private final int min
      • max

        private final int max
    • Constructor Detail

      • PortType

        private PortType​(int min,
                         int max)
    • Method Detail

      • values

        public static PortType[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (PortType c : PortType.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static PortType valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • getMinimumPort

        public int getMinimumPort()
        Description copied from interface: PortRange
        Gets the minimum port
        Specified by:
        getMinimumPort in interface PortRange
        Returns:
        Minimum port
      • getMaximumPort

        public int getMaximumPort()
        Description copied from interface: PortRange
        Gets the maximum port
        Specified by:
        getMaximumPort in interface PortRange
        Returns:
        Maximum port
      • inRange

        public boolean inRange​(int port)
        Description copied from interface: PortRange
        Gets whether a port falls within the range
        Specified by:
        inRange in interface PortRange
        Parameters:
        port - Port
        Returns:
        True if in range, false otherwise
      • contains

        public boolean contains​(PortRange other)
        Description copied from interface: PortRange
        Gets whether the port range contains another port range i.e. does this cover at least the same range of ports as the other
        Specified by:
        contains in interface PortRange
        Parameters:
        other - Other port type
        Returns:
        True if this covers at least the same range of ports as the other, false otherwise
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Enum<PortType>
      • toRangesString

        public static java.lang.String toRangesString​(java.util.Set<PortRange> acceptablePorts)
        Gets a string denoting all the acceptable port ranges
        Parameters:
        acceptablePorts - Port types
        Returns:
        String detailing acceptable ranges