Class HostPatternsHolder
java.lang.Object
org.apache.sshd.client.config.hosts.HostPatternsHolder
- Direct Known Subclasses:
HostConfigEntry,KnownHostEntry
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final charUsed to negate a host patternstatic final charNon-standard port specification host pattern enclosure end delimiterstatic final charNon-standard port specification host pattern enclosure start delimiterstatic final StringThe available pattern charactersprivate Collection<HostPatternValue> static final charPort value separator if non-standard port pattern usedstatic final charUsed in a host pattern to denote any one characterstatic final charUsed in a host pattern to denote zero or more consecutive characters -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanisHostMatch(String host, int port) Checks if a given host name / address matches the entry's host pattern(s)static booleanisHostMatch(String host, int port, Collection<HostPatternValue> patterns) static booleanisHostMatch(String host, Pattern pattern) Checks if a given host name / address matches a host patternstatic booleanisPortMatch(int port1, int port2) static booleanisSpecificHostPattern(String pattern) static booleanisValidPatternChar(char ch) Checks if the given character is valid for a host pattern.static List<HostPatternValue> parsePatterns(CharSequence... patterns) static List<HostPatternValue> parsePatterns(Collection<? extends CharSequence> patterns) voidsetPatterns(Collection<HostPatternValue> patterns) static HostPatternValuetoPattern(CharSequence patternString) Converts a host pattern string to a regular expression matcher.
-
Field Details
-
WILDCARD_PATTERN
public static final char WILDCARD_PATTERNUsed in a host pattern to denote zero or more consecutive characters- See Also:
-
ALL_HOSTS_PATTERN
-
SINGLE_CHAR_PATTERN
public static final char SINGLE_CHAR_PATTERNUsed in a host pattern to denote any one character- See Also:
-
NEGATION_CHAR_PATTERN
public static final char NEGATION_CHAR_PATTERNUsed to negate a host pattern- See Also:
-
PATTERN_CHARS
The available pattern characters -
PORT_VALUE_DELIMITER
public static final char PORT_VALUE_DELIMITERPort value separator if non-standard port pattern used- See Also:
-
NON_STANDARD_PORT_PATTERN_ENCLOSURE_START_DELIM
public static final char NON_STANDARD_PORT_PATTERN_ENCLOSURE_START_DELIMNon-standard port specification host pattern enclosure start delimiter- See Also:
-
NON_STANDARD_PORT_PATTERN_ENCLOSURE_END_DELIM
public static final char NON_STANDARD_PORT_PATTERN_ENCLOSURE_END_DELIMNon-standard port specification host pattern enclosure end delimiter- See Also:
-
patterns
-
-
Constructor Details
-
HostPatternsHolder
protected HostPatternsHolder()
-
-
Method Details
-
getPatterns
-
setPatterns
-
isHostMatch
Checks if a given host name / address matches the entry's host pattern(s)- Parameters:
host- The host name / address - ignored ifnull/emptyport- The connection port- Returns:
trueif the name / address matches the pattern(s)- See Also:
-
isSpecificHostPattern
- Parameters:
pattern- The pattern to check - ignored ifnull/empty- Returns:
trueif the pattern is not empty and contains no wildcard characters- See Also:
-
isHostMatch
-
isPortMatch
public static boolean isPortMatch(int port1, int port2) - Parameters:
port1- 1st port value - if non-positive then assumed to beDEFAULT_PORTport2- 2nd port value - if non-positive then assumed to beDEFAULT_PORT- Returns:
trueif ports are effectively equal
-
isHostMatch
Checks if a given host name / address matches a host pattern- Parameters:
host- The host name / address - ignored ifnull/emptypattern- The hostPattern- ignored ifnull- Returns:
trueif the name / address matches the pattern
-
parsePatterns
-
parsePatterns
-
toPattern
Converts a host pattern string to a regular expression matcher. Note: pattern matching is case insensitive- Parameters:
patternString- The original pattern string - ignored ifnull/empty- Returns:
- The regular expression matcher
Patternand the indication whether it is a negating pattern or not -nullif no original string - See Also:
-
isValidPatternChar
public static boolean isValidPatternChar(char ch) Checks if the given character is valid for a host pattern. Valid characters are:- A-Z
- a-z
- 0-9
- Underscore (_)
- Hyphen (-)
- Dot (.)
- Colon (:)
- Percent (%) for scoped ipv6
- The
WILDCARD_PATTERN - The
SINGLE_CHAR_PATTERN
- Parameters:
ch- The character to validate- Returns:
trueif valid pattern character
-