Class HostPatternsHolder
- java.lang.Object
-
- org.apache.sshd.client.config.hosts.HostPatternsHolder
-
- Direct Known Subclasses:
HostConfigEntry
,KnownHostEntry
public abstract class HostPatternsHolder extends Object
- Author:
- Apache MINA SSHD Project
-
-
Field Summary
Fields Modifier and Type Field Description static String
ALL_HOSTS_PATTERN
static char
NEGATION_CHAR_PATTERN
Used to negate a host patternstatic char
NON_STANDARD_PORT_PATTERN_ENCLOSURE_END_DELIM
Non-standard port specification host pattern enclosure end delimiterstatic char
NON_STANDARD_PORT_PATTERN_ENCLOSURE_START_DELIM
Non-standard port specification host pattern enclosure start delimiterstatic String
PATTERN_CHARS
The available pattern charactersstatic char
PORT_VALUE_DELIMITER
Port value separator if non-standard port pattern usedstatic char
SINGLE_CHAR_PATTERN
Used in a host pattern to denote any one characterstatic char
WILDCARD_PATTERN
Used in a host pattern to denote zero or more consecutive characters
-
Constructor Summary
Constructors Modifier Constructor Description protected
HostPatternsHolder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static List<HostConfigEntry>
findMatchingEntries(String host, Collection<? extends HostConfigEntry> entries)
Locates all the matching entries for a give host name / addressstatic List<HostConfigEntry>
findMatchingEntries(String host, HostConfigEntry... entries)
Locates all the matching entries for a give host name / addressCollection<HostPatternValue>
getPatterns()
boolean
isHostMatch(String host, int port)
Checks if a given host name / address matches the entry's host pattern(s)static boolean
isHostMatch(String host, int port, Collection<HostPatternValue> patterns)
static boolean
isHostMatch(String host, Pattern pattern)
Checks if a given host name / address matches a host patternstatic boolean
isSpecificHostPattern(String pattern)
static boolean
isValidPatternChar(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)
void
setPatterns(Collection<HostPatternValue> patterns)
static HostPatternValue
toPattern(CharSequence patternString)
Converts a host pattern string to a regular expression matcher.
-
-
-
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 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 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
-
-
Method Detail
-
getPatterns
public Collection<HostPatternValue> getPatterns()
-
setPatterns
public void setPatterns(Collection<HostPatternValue> patterns)
-
isHostMatch
public boolean isHostMatch(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 ifnull
/emptyport
- The connection port- Returns:
true
if the name / address matches the pattern(s)- See Also:
isHostMatch(String, Pattern)
-
isSpecificHostPattern
public static boolean isSpecificHostPattern(String pattern)
- Parameters:
pattern
- The pattern to check - ignored ifnull
/empty- Returns:
true
if the pattern is not empty and contains no wildcard characters- See Also:
WILDCARD_PATTERN
,SINGLE_CHAR_PATTERN
,SINGLE_CHAR_PATTERN
-
findMatchingEntries
public static List<HostConfigEntry> findMatchingEntries(String host, HostConfigEntry... entries)
Locates all the matching entries for a give host name / address- Parameters:
host
- The host name / address - ignored ifnull
/emptyentries
- TheHostConfigEntry
-ies to scan - ignored ifnull
/empty- Returns:
- A
List
of all the matching entries - See Also:
isHostMatch(String, int)
-
findMatchingEntries
public static List<HostConfigEntry> findMatchingEntries(String host, Collection<? extends HostConfigEntry> entries)
Locates all the matching entries for a give host name / address- Parameters:
host
- The host name / address - ignored ifnull
/emptyentries
- TheHostConfigEntry
-ies to scan - ignored ifnull
/empty- Returns:
- A
List
of all the matching entries - See Also:
isHostMatch(String, int)
-
isHostMatch
public static boolean isHostMatch(String host, int port, Collection<HostPatternValue> patterns)
-
isHostMatch
public static boolean isHostMatch(String host, Pattern pattern)
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:
true
if the name / address matches the pattern
-
parsePatterns
public static List<HostPatternValue> parsePatterns(CharSequence... patterns)
-
parsePatterns
public static List<HostPatternValue> parsePatterns(Collection<? extends CharSequence> patterns)
-
toPattern
public static HostPatternValue toPattern(CharSequence patternString)
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
Pattern
and the indication whether it is a negating pattern or not -null
if no original string - See Also:
NON_STANDARD_PORT_PATTERN_ENCLOSURE_START_DELIM
,NON_STANDARD_PORT_PATTERN_ENCLOSURE_END_DELIM
,WILDCARD_PATTERN
,SINGLE_CHAR_PATTERN
,NEGATION_CHAR_PATTERN
-
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 (.)
- The
WILDCARD_PATTERN
- The
SINGLE_CHAR_PATTERN
- Parameters:
ch
- The character to validate- Returns:
true
if valid pattern character
-
-