@Test(expected = IllegalArgumentException.class) public void testInvalidSpecWithTooManySlashes() throws UnknownHostException { InetAddressMatcher.forPattern("1.1.1.1/24/25"); }
public static InetAddressMatcher forPattern(String s) throws UnknownHostException { String hostAndMask[] = s.split("/"); checkArgument(hostAndMask.length < 3, "Invalid host specification: " + s); if (!isInetAddress(hostAndMask[0])) { checkArgument (hostAndMask.length == 1, "Invalid host specification (hostname with mask): " + s); if (s.indexOf('*') != -1 || s.indexOf('?') != -1) { return new RegexpNameMatcher(toRegExp(s)); } else { return new HostNameMatcher(s); } } InetAddress net = forString(hostAndMask[0]); if (hostAndMask.length == 2) { return new IpAddressMatcher(s, net, Integer.parseInt(hostAndMask[1])); } return new IpAddressMatcher(s, net); }
InetAddressMatcher implements Predicate<InetAddress> { public static InetAddressMatcher forPattern(String s) throws UnknownHostException { String hostAndMask[] = s.split("/"); checkArgument(hostAndMask.length < 3, "Invalid host specification: " + s); if (!isInetAddress(hostAndMask[0])) { checkArgument (hostAndMask.length == 1, "Invalid host specification (hostname with mask): " + s); if (s.indexOf('*') != -1 || s.indexOf('?') != -1) { return new RegexpNameMatcher(toRegExp(s)); } else { return new HostNameMatcher(s); } } InetAddress net = forString(hostAndMask[0]); if (hostAndMask.length == 2) { return new IpAddressMatcher(s, net, Integer.parseInt(hostAndMask[1])); } return new IpAddressMatcher(s, net); } }
InetAddressMatcher implements Predicate<InetAddress> { public static InetAddressMatcher forPattern(String s) throws UnknownHostException { String hostAndMask[] = s.split("/"); checkArgument(hostAndMask.length < 3, "Invalid host specification: " + s); if (!isInetAddress(hostAndMask[0])) { checkArgument (hostAndMask.length == 1, "Invalid host specification (hostname with mask): " + s); if (s.indexOf('*') != -1 || s.indexOf('?') != -1) { return new RegexpNameMatcher(toRegExp(s)); } else { return new HostNameMatcher(s); } } InetAddress net = forString(hostAndMask[0]); if (hostAndMask.length == 2) { return new IpAddressMatcher(s, net, Integer.parseInt(hostAndMask[1])); } return new IpAddressMatcher(s, net); } protected  InetAddressMatcher(String pattern); }
InetAddressMatcher implements Predicate<InetAddress> { public static InetAddressMatcher forPattern(String s) throws UnknownHostException { String hostAndMask[] = s.split("/"); checkArgument(hostAndMask.length < 3, "Invalid host specification: " + s); if (!isInetAddress(hostAndMask[0])) { checkArgument (hostAndMask.length == 1, "Invalid host specification (hostname with mask): " + s); if (s.indexOf('*') != -1 || s.indexOf('?') != -1) { return new RegexpNameMatcher(toRegExp(s)); } else { return new HostNameMatcher(s); } } InetAddress net = forString(hostAndMask[0]); if (hostAndMask.length == 2) { return new IpAddressMatcher(s, net, Integer.parseInt(hostAndMask[1])); } return new IpAddressMatcher(s, net); } protected  InetAddressMatcher(String pattern); boolean match(InetAddress addr); String getPattern(); @Override int hashCode(); @Override boolean equals(Object obj); static InetAddressMatcher forPattern(String s); }
InetAddressMatcher implements Predicate<InetAddress> { public static InetAddressMatcher forPattern(String s) throws UnknownHostException { String hostAndMask[] = s.split("/"); checkArgument(hostAndMask.length < 3, "Invalid host specification: " + s); if (!isInetAddress(hostAndMask[0])) { checkArgument (hostAndMask.length == 1, "Invalid host specification (hostname with mask): " + s); if (s.indexOf('*') != -1 || s.indexOf('?') != -1) { return new RegexpNameMatcher(toRegExp(s)); } else { return new HostNameMatcher(s); } } InetAddress net = forString(hostAndMask[0]); if (hostAndMask.length == 2) { return new IpAddressMatcher(s, net, Integer.parseInt(hostAndMask[1])); } return new IpAddressMatcher(s, net); } protected  InetAddressMatcher(String pattern); boolean match(InetAddress addr); String getPattern(); @Override int hashCode(); @Override boolean equals(Object obj); static InetAddressMatcher forPattern(String s);  }