@Test public void testGetRangeMatchesMulti() { String includes[] = { "fakeco" }; String excludes[] = null; BannedRefChecker checker = new BannedRefChecker(includes, excludes); List<Range> ranges = checker.getRangeMatches("import com.fakeco.internal.fakecommon.FakeCoFakeColocated;", includes); Assert.assertNotNull("Should not have a null range", ranges); Range expected[] = new Range[] { new Range(11, "fakeco"), new Range(27, "fakeco"), new Range(38, "FakeCo"), new Range(44, "FakeCo") }; Assert.assertThat("Ranges.size()", ranges.size(), is(expected.length)); for(int i=0; i<expected.length; i++) { Range actual = ranges.get(i); Assert.assertThat("Range.start", actual.start, is(expected[i].start)); Assert.assertThat("Range.end", actual.end, is(expected[i].end)); Assert.assertThat("Range.match", actual.match, is(expected[i].match)); } }
protected List<Range> getRangeMatches(String line, String[] words) { List<Range> ranges = new ArrayList<Range>(); if (words == null) { return ranges; } String lowerline = line.toLowerCase(); int idx = 0; int end = 0; for (String word : words) { idx = lowerline.indexOf(word, idx); while (idx >= 0) { end = idx + word.length(); ranges.add(new Range(idx, end, line.substring(idx, end))); idx = lowerline.indexOf(word, idx + word.length()); } } return ranges; }
BannedRefChecker { protected List<Range> getRangeMatches(String line, String[] words) { List<Range> ranges = new ArrayList<Range>(); if (words == null) { return ranges; } String lowerline = line.toLowerCase(); int idx = 0; int end = 0; for (String word : words) { idx = lowerline.indexOf(word, idx); while (idx >= 0) { end = idx + word.length(); ranges.add(new Range(idx, end, line.substring(idx, end))); idx = lowerline.indexOf(word, idx + word.length()); } } return ranges; } }
BannedRefChecker { protected List<Range> getRangeMatches(String line, String[] words) { List<Range> ranges = new ArrayList<Range>(); if (words == null) { return ranges; } String lowerline = line.toLowerCase(); int idx = 0; int end = 0; for (String word : words) { idx = lowerline.indexOf(word, idx); while (idx >= 0) { end = idx + word.length(); ranges.add(new Range(idx, end, line.substring(idx, end))); idx = lowerline.indexOf(word, idx + word.length()); } } return ranges; } BannedRefChecker(String included[], String excluded[]); }
BannedRefChecker { protected List<Range> getRangeMatches(String line, String[] words) { List<Range> ranges = new ArrayList<Range>(); if (words == null) { return ranges; } String lowerline = line.toLowerCase(); int idx = 0; int end = 0; for (String word : words) { idx = lowerline.indexOf(word, idx); while (idx >= 0) { end = idx + word.length(); ranges.add(new Range(idx, end, line.substring(idx, end))); idx = lowerline.indexOf(word, idx + word.length()); } } return ranges; } BannedRefChecker(String included[], String excluded[]); void check(Report report, File file); }
BannedRefChecker { protected List<Range> getRangeMatches(String line, String[] words) { List<Range> ranges = new ArrayList<Range>(); if (words == null) { return ranges; } String lowerline = line.toLowerCase(); int idx = 0; int end = 0; for (String word : words) { idx = lowerline.indexOf(word, idx); while (idx >= 0) { end = idx + word.length(); ranges.add(new Range(idx, end, line.substring(idx, end))); idx = lowerline.indexOf(word, idx + word.length()); } } return ranges; } BannedRefChecker(String included[], String excluded[]); void check(Report report, File file);  }