public static List<HostPatternValue> parsePatterns(CharSequence... patterns) { return parsePatterns(GenericUtils.isEmpty(patterns) ? Collections.emptyList() : Arrays.asList(patterns)); }
/** * Checks if a given host name / address matches the entry's host pattern(s) * * @param host The host name / address - ignored if {@code null}/empty * @param port The connection port * @return {@code true} if the name / address matches the pattern(s) * @see #isHostMatch(String, Pattern) */ public boolean isHostMatch(String host, int port) { return isHostMatch(host, port, getPatterns()); }
public static List<HostPatternValue> parsePatterns(Collection<? extends CharSequence> patterns) { if (GenericUtils.isEmpty(patterns)) { return Collections.emptyList(); } List<HostPatternValue> result = new ArrayList<>(patterns.size()); for (CharSequence p : patterns) { result.add(ValidateUtils.checkNotNull(toPattern(p), "No pattern for %s", p)); } return result; }
@Override public boolean isHostMatch(String host, int port) { if (super.isHostMatch(host, port)) { return true; } KnownHostHashValue hash = getHashedEntry(); return (hash != null) && hash.isHostMatch(host); }
/** * Locates all the matching entries for a give host name / address * * @param host The host name / address - ignored if {@code null}/empty * @param entries The {@link HostConfigEntry}-ies to scan - ignored if {@code null}/empty * @return A {@link List} of all the matching entries * @see #isHostMatch(String, int) */ public static List<HostConfigEntry> findMatchingEntries(String host, HostConfigEntry... entries) { // TODO in Java-8 use Stream(s) + predicate if (GenericUtils.isEmpty(host) || GenericUtils.isEmpty(entries)) { return Collections.emptyList(); } else { return findMatchingEntries(host, Arrays.asList(entries)); } }
for (int curPos = 0; curPos < patternLen; curPos++) { char ch = pattern.charAt(curPos); ValidateUtils.checkTrue(isValidPatternChar(ch), "Invalid host pattern char in %s", pattern);
@Override public boolean isHostMatch(String host, int port) { if (super.isHostMatch(host, port)) { return true; } KnownHostHashValue hash = getHashedEntry(); return (hash != null) && hash.isHostMatch(host, port); }
/** * Locates all the matching entries for a give host name / address * * @param host The host name / address - ignored if {@code null}/empty * @param entries The {@link HostConfigEntry}-ies to scan - ignored if {@code null}/empty * @return A {@link List} of all the matching entries * @see #isHostMatch(String, int) */ public static List<HostConfigEntry> findMatchingEntries(String host, HostConfigEntry... entries) { // TODO in Java-8 use Stream(s) + predicate if (GenericUtils.isEmpty(host) || GenericUtils.isEmpty(entries)) { return Collections.emptyList(); } else { return findMatchingEntries(host, Arrays.asList(entries)); } }
for (int curPos = 0; curPos < patternLen; curPos++) { char ch = pattern.charAt(curPos); ValidateUtils.checkTrue(isValidPatternChar(ch), "Invalid host pattern char in %s", pattern);
/** * Checks if a given host name / address matches the entry's host pattern(s) * * @param host The host name / address - ignored if {@code null}/empty * @param port The connection port * @return {@code true} if the name / address matches the pattern(s) * @see #isHostMatch(String, Pattern) */ public boolean isHostMatch(String host, int port) { return isHostMatch(host, port, getPatterns()); }
public static List<HostPatternValue> parsePatterns(CharSequence... patterns) { return parsePatterns(GenericUtils.isEmpty(patterns) ? Collections.emptyList() : Arrays.asList(patterns)); }
if (!isHostMatch(host, pv.getPattern())) { continue;
public static List<HostPatternValue> parsePatterns(Collection<? extends CharSequence> patterns) { if (GenericUtils.isEmpty(patterns)) { return Collections.emptyList(); } List<HostPatternValue> result = new ArrayList<>(patterns.size()); for (CharSequence p : patterns) { result.add(ValidateUtils.checkNotNull(toPattern(p), "No pattern for %s", p)); } return result; }
private static Collection<HostPatternValue> parsePatterns(String text) { if (text.isEmpty()) { return null; } List<String> items = Arrays.stream(text.split(",")) //$NON-NLS-1$ .filter(item -> item != null && !item.isEmpty()).map(item -> { if (NON_STANDARD_PORT_PATTERN_ENCLOSURE_START_DELIM == item .charAt(0)) { return item; } int firstColon = item.indexOf(':'); if (firstColon < 0) { return item; } int secondColon = item.indexOf(':', firstColon + 1); if (secondColon > 0) { // Assume an IPv6 address (without port). return item; } // We have "host:port", should be "[host]:port" return NON_STANDARD_PORT_PATTERN_ENCLOSURE_START_DELIM + item.substring(0, firstColon) + NON_STANDARD_PORT_PATTERN_ENCLOSURE_END_DELIM + item.substring(firstColon); }).collect(Collectors.toList()); return items.isEmpty() ? null : HostPatternsHolder.parsePatterns(items); } }
if (!isHostMatch(host, pv.getPattern())) { continue;