@Test public void test_ipv6_matcher() { DividedStringPatternMatcher matcherToTest = new DividedStringPatternMatcher("2001:DB8:0:0:8:800:200C:*", ':'); assertFalse(matcherToTest.isMatching("2002:db8:0:0:8:800:200C:417A")); assertFalse(matcherToTest.isMatching("0:::417A")); assertFalse(matcherToTest.isMatching("2001:DB8:0:0:8:800:200C:")); assertFalse(matcherToTest.isMatching("2001:DB8::8:800:200C:417A")); assertTrue(matcherToTest.isMatching("2001:DB8:0:0:8:800:200C:417A")); assertTrue(matcherToTest.isMatching("2001:DB8:0:0:8:800:200C:417B")); }
public boolean isMatching(String given ) { if (given==null) { return false; } String target = given.toLowerCase(); String[] targetPart = splitByDivider(target); if (targetPart == null) { return false; } if (targetPart.length != patternParts.length) { return false; } boolean accepted = true; for (int i = 0; i < patternParts.length && accepted; i++) { accepted = patternParts[i].equals("*") || patternParts[i].equals(targetPart[i]); } return accepted; }
DividedStringPatternMatcher { public boolean isMatching(String given ) { if (given==null) { return false; } String target = given.toLowerCase(); String[] targetPart = splitByDivider(target); if (targetPart == null) { return false; } if (targetPart.length != patternParts.length) { return false; } boolean accepted = true; for (int i = 0; i < patternParts.length && accepted; i++) { accepted = patternParts[i].equals("*") || patternParts[i].equals(targetPart[i]); } return accepted; } }
DividedStringPatternMatcher { public boolean isMatching(String given ) { if (given==null) { return false; } String target = given.toLowerCase(); String[] targetPart = splitByDivider(target); if (targetPart == null) { return false; } if (targetPart.length != patternParts.length) { return false; } boolean accepted = true; for (int i = 0; i < patternParts.length && accepted; i++) { accepted = patternParts[i].equals("*") || patternParts[i].equals(targetPart[i]); } return accepted; } DividedStringPatternMatcher(String pattern, char divider); }
DividedStringPatternMatcher { public boolean isMatching(String given ) { if (given==null) { return false; } String target = given.toLowerCase(); String[] targetPart = splitByDivider(target); if (targetPart == null) { return false; } if (targetPart.length != patternParts.length) { return false; } boolean accepted = true; for (int i = 0; i < patternParts.length && accepted; i++) { accepted = patternParts[i].equals("*") || patternParts[i].equals(targetPart[i]); } return accepted; } DividedStringPatternMatcher(String pattern, char divider); String[] getPatternParts(); boolean isMatching(String given ); }
DividedStringPatternMatcher { public boolean isMatching(String given ) { if (given==null) { return false; } String target = given.toLowerCase(); String[] targetPart = splitByDivider(target); if (targetPart == null) { return false; } if (targetPart.length != patternParts.length) { return false; } boolean accepted = true; for (int i = 0; i < patternParts.length && accepted; i++) { accepted = patternParts[i].equals("*") || patternParts[i].equals(targetPart[i]); } return accepted; } DividedStringPatternMatcher(String pattern, char divider); String[] getPatternParts(); boolean isMatching(String given );  }