@Test public void testGetRangeMatchesSimple() { String includes[] = { "fakeco" }; String excludes[] = null; BannedRefChecker checker = new BannedRefChecker(includes, excludes); List<Range> ranges = checker.getRangeMatches("import com.fakeco.common.Utils;", includes); Assert.assertNotNull("Should not have a null range", ranges); Assert.assertThat("Ranges.size()", ranges.size(), is(1)); Range range = ranges.get(0); Assert.assertThat("Range.start", range.start, is(11)); Assert.assertThat("Range.end", range.end, is(17)); Assert.assertThat("Range.match", range.match, is("fakeco")); }
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);  }