Top Fields Constructors Methods
org.apache.sshd.client.config.hosts

public abstract Class HostPatternsHolder

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.sshd.client.config.hosts.KnownHostEntry, org.apache.sshd.client.config.hosts.HostConfigEntry
Imports
java.util.ArrayList, .Arrays, .Collection, .Collections, .LinkedList, .List, .Objects, java.util.regex.Matcher, .Pattern, org.apache.sshd.common.SshConstants, org.apache.sshd.common.util.GenericUtils, .ValidateUtils

Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
public static final String
public static final char
NEGATION_CHAR_PATTERN

Used to negate a host pattern

public static final char
NON_STANDARD_PORT_PATTERN_ENCLOSURE_END_DELIM

Non-standard port specification host pattern enclosure end delimiter

public static final char
NON_STANDARD_PORT_PATTERN_ENCLOSURE_START_DELIM

Non-standard port specification host pattern enclosure start delimiter

public static final String
PATTERN_CHARS

The available pattern characters

private Collection<HostPatternValue>
public static final char
PORT_VALUE_DELIMITER

Port value separator if non-standard port pattern used

public static final char
SINGLE_CHAR_PATTERN

Used in a host pattern to denote any one character

public static final char
WILDCARD_PATTERN

Used in a host pattern to denote zero or more consecutive characters

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public Collection<HostPatternValue>
public boolean

Returns:

true if the name / address matches the pattern(s)
isHostMatch
(String
The host name / address - ignored if null/empty
host
,
int
The connection port
port
)

Checks if a given host name / address matches the entry's host pattern(s)

public static boolean
isHostMatch(String host, int port, Collection<HostPatternValue> patterns)

public static boolean

Returns:

true if the name / address matches the pattern
isHostMatch
(String
The host name / address - ignored if null/empty
host
,
Pattern
The host Pattern - ignored if null
pattern
)

Checks if a given host name / address matches a host pattern

public static boolean

Returns:

true if ports are effectively equal
isPortMatch
(int
1st port value - if non-positive then assumed to be DEFAULT_PORT
port1
,
int
2nd port value - if non-positive then assumed to be DEFAULT_PORT
port2
)

public static boolean

Returns:

true if the pattern is not empty and contains no wildcard characters
isSpecificHostPattern
(String
The pattern to check - ignored if null/empty
pattern
)

public static boolean

Returns:

true if valid pattern character
isValidPatternChar
(char
The character to validate
ch
)

Checks if the given character is valid for a host pattern.

public static List<HostPatternValue>
public static List<HostPatternValue>
parsePatterns(Collection<? extends CharSequence> patterns)

public void
public static HostPatternValue

Returns:

The regular expression matcher Pattern and the indication whether it is a negating pattern or not - null if no original string
toPattern
(CharSequence
The original pattern string - ignored if null/empty
patternString
)

Converts a host pattern string to a regular expression matcher

Note

pattern matching is case insensitive

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALL_HOSTS_PATTERNback to summary
public static final String ALL_HOSTS_PATTERN
NEGATION_CHAR_PATTERNback to summary
public static final char NEGATION_CHAR_PATTERN

Used to negate a host pattern

NON_STANDARD_PORT_PATTERN_ENCLOSURE_END_DELIMback to summary
public static final char NON_STANDARD_PORT_PATTERN_ENCLOSURE_END_DELIM

Non-standard port specification host pattern enclosure end delimiter

NON_STANDARD_PORT_PATTERN_ENCLOSURE_START_DELIMback to summary
public static final char NON_STANDARD_PORT_PATTERN_ENCLOSURE_START_DELIM

Non-standard port specification host pattern enclosure start delimiter

PATTERN_CHARSback to summary
public static final String PATTERN_CHARS

The available pattern characters

patternsback to summary
private Collection<HostPatternValue> patterns
PORT_VALUE_DELIMITERback to summary
public static final char PORT_VALUE_DELIMITER

Port value separator if non-standard port pattern used

SINGLE_CHAR_PATTERNback to summary
public static final char SINGLE_CHAR_PATTERN

Used in a host pattern to denote any one character

WILDCARD_PATTERNback to summary
public static final char WILDCARD_PATTERN

Used in a host pattern to denote zero or more consecutive characters

Constructor Detail

HostPatternsHolderback to summary
protected HostPatternsHolder()

Method Detail

getPatternsback to summary
public Collection<HostPatternValue> getPatterns()
isHostMatchback to summary
public boolean isHostMatch(String host, int port)

Checks if a given host name / address matches the entry's host pattern(s)

Parameters
host:String

The host name / address - ignored if null/empty

port:int

The connection port

Returns:boolean

true if the name / address matches the pattern(s)

See Also
isHostMatch(String, Pattern)
isHostMatchback to summary
public static boolean isHostMatch(String host, int port, Collection<HostPatternValue> patterns)
isHostMatchback to summary
public static boolean isHostMatch(String host, Pattern pattern)

Checks if a given host name / address matches a host pattern

Parameters
host:String

The host name / address - ignored if null/empty

pattern:Pattern

The host Pattern - ignored if null

Returns:boolean

true if the name / address matches the pattern

isPortMatchback to summary
public static boolean isPortMatch(int port1, int port2)
Parameters
port1:int

1st port value - if non-positive then assumed to be DEFAULT_PORT

port2:int

2nd port value - if non-positive then assumed to be DEFAULT_PORT

Returns:boolean

true if ports are effectively equal

isSpecificHostPatternback to summary
public static boolean isSpecificHostPattern(String pattern)
Parameters
pattern:String

The pattern to check - ignored if null/empty

Returns:boolean

true if the pattern is not empty and contains no wildcard characters

See Also
WILDCARD_PATTERN, SINGLE_CHAR_PATTERN
isValidPatternCharback to summary
public static boolean isValidPatternChar(char ch)

Checks if the given character is valid for a host pattern. Valid characters are:

Parameters
ch:char

The character to validate

Returns:boolean

true if valid pattern character

parsePatternsback to summary
public static List<HostPatternValue> parsePatterns(CharSequence... patterns)
parsePatternsback to summary
public static List<HostPatternValue> parsePatterns(Collection<? extends CharSequence> patterns)
setPatternsback to summary
public void setPatterns(Collection<HostPatternValue> patterns)
toPatternback to summary
public static HostPatternValue toPattern(CharSequence patternString)

Converts a host pattern string to a regular expression matcher

Note

pattern matching is case insensitive

Parameters
patternString:CharSequence

The original pattern string - ignored if null/empty

Returns:HostPatternValue

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