public static Collection<String> getMatchingIpv4Addresses(final AddressMatcher addressMatcher) { if (addressMatcher.isIPv6()) { throw new IllegalArgumentException("Cannot wildcard matching for IPv6: " + addressMatcher); } final Collection<String> addresses = new HashSet<String>(); final String first3 = addressMatcher.address[0] + '.' + addressMatcher.address[1] + '.' + addressMatcher.address[2]; final String lastPart = addressMatcher.address[3]; final int dashPos; if ("*".equals(lastPart)) { for (int j = 0; j <= NUMBER_OF_ADDRESSES; j++) { addresses.add(first3 + '.' + j); } } else if (lastPart.indexOf('-') > 0) { dashPos = lastPart.indexOf('-'); final int start = Integer.parseInt(lastPart.substring(0, dashPos)); final int end = Integer.parseInt(lastPart.substring(dashPos + 1)); for (int j = start; j <= end; j++) { addresses.add(first3 + '.' + j); } } else { addresses.add(addressMatcher.getAddress()); } return addresses; }
public static Collection<String> getMatchingIpv4Addresses(final AddressMatcher addressMatcher) { if (addressMatcher.isIPv6()) { throw new IllegalArgumentException("Cannot wildcard matching for IPv6: " + addressMatcher); } final Collection<String> addresses = new HashSet<String>(); final String first3 = addressMatcher.address[0] + '.' + addressMatcher.address[1] + '.' + addressMatcher.address[2]; final String lastPart = addressMatcher.address[3]; final int dashPos; if ("*".equals(lastPart)) { for (int j = 0; j <= NUMBER_OF_ADDRESSES; j++) { addresses.add(first3 + '.' + j); } } else if (lastPart.indexOf('-') > 0) { dashPos = lastPart.indexOf('-'); final int start = Integer.parseInt(lastPart.substring(0, dashPos)); final int end = Integer.parseInt(lastPart.substring(dashPos + 1)); for (int j = start; j <= end; j++) { addresses.add(first3 + '.' + j); } } else { addresses.add(addressMatcher.getAddress()); } return addresses; }
@Override public boolean match(final AddressMatcher matcher) { if (matcher.isIPv6()) { return false; } final String[] mask = this.address; final String[] input = ((Ip4AddressMatcher) matcher).address; return match(mask, input, DECIMAL_RADIX); }
@Override public boolean match(final AddressMatcher matcher) { if (matcher.isIPv6()) { return false; } final String[] mask = this.address; final String[] input = ((Ip4AddressMatcher) matcher).address; return match(mask, input, DECIMAL_RADIX); }