Class HostPatternsHolder

    • Field Detail

      • WILDCARD_PATTERN

        public static final char WILDCARD_PATTERN
        Used in a host pattern to denote zero or more consecutive characters
        See Also:
        Constant Field Values
      • ALL_HOSTS_PATTERN

        public static final java.lang.String ALL_HOSTS_PATTERN
      • SINGLE_CHAR_PATTERN

        public static final char SINGLE_CHAR_PATTERN
        Used in a host pattern to denote any one character
        See Also:
        Constant Field Values
      • NEGATION_CHAR_PATTERN

        public static final char NEGATION_CHAR_PATTERN
        Used to negate a host pattern
        See Also:
        Constant Field Values
      • PATTERN_CHARS

        public static final java.lang.String PATTERN_CHARS
        The available pattern characters
      • PORT_VALUE_DELIMITER

        public static final char PORT_VALUE_DELIMITER
        Port value separator if non-standard port pattern used
        See Also:
        Constant Field Values
      • NON_STANDARD_PORT_PATTERN_ENCLOSURE_START_DELIM

        public static final char NON_STANDARD_PORT_PATTERN_ENCLOSURE_START_DELIM
        Non-standard port specification host pattern enclosure start delimiter
        See Also:
        Constant Field Values
      • NON_STANDARD_PORT_PATTERN_ENCLOSURE_END_DELIM

        public static final char NON_STANDARD_PORT_PATTERN_ENCLOSURE_END_DELIM
        Non-standard port specification host pattern enclosure end delimiter
        See Also:
        Constant Field Values
    • Constructor Detail

      • HostPatternsHolder

        protected HostPatternsHolder()
    • Method Detail

      • setPatterns

        public void setPatterns​(java.util.Collection<HostPatternValue> patterns)
      • isHostMatch

        public boolean isHostMatch​(java.lang.String host,
                                   int port)
        Checks if a given host name / address matches the entry's host pattern(s)
        Parameters:
        host - The host name / address - ignored if null/empty
        port - The connection port
        Returns:
        true if the name / address matches the pattern(s)
        See Also:
        isHostMatch(String, Pattern)
      • isSpecificHostPattern

        public static boolean isSpecificHostPattern​(java.lang.String pattern)
        Parameters:
        pattern - The pattern to check - ignored if null/empty
        Returns:
        true if the pattern is not empty and contains no wildcard characters
        See Also:
        WILDCARD_PATTERN, SINGLE_CHAR_PATTERN, SINGLE_CHAR_PATTERN
      • isHostMatch

        public static boolean isHostMatch​(java.lang.String host,
                                          int port,
                                          java.util.Collection<HostPatternValue> patterns)
      • isPortMatch

        public static boolean isPortMatch​(int port1,
                                          int port2)
        Parameters:
        port1 - 1st port value - if non-positive then assumed to be DEFAULT_PORT
        port2 - 2nd port value - if non-positive then assumed to be DEFAULT_PORT
        Returns:
        true if ports are effectively equal
      • isHostMatch

        public static boolean isHostMatch​(java.lang.String host,
                                          java.util.regex.Pattern pattern)
        Checks if a given host name / address matches a host pattern
        Parameters:
        host - The host name / address - ignored if null/empty
        pattern - The host Pattern - ignored if null
        Returns:
        true if the name / address matches the pattern
      • parsePatterns

        public static java.util.List<HostPatternValue> parsePatterns​(java.lang.CharSequence... patterns)
      • parsePatterns

        public static java.util.List<HostPatternValue> parsePatterns​(java.util.Collection<? extends java.lang.CharSequence> patterns)
      • isValidPatternChar

        public static boolean isValidPatternChar​(char ch)
        Checks if the given character is valid for a host pattern. Valid characters are:
        Parameters:
        ch - The character to validate
        Returns:
        true if valid pattern character