List<String> (String line) { if (!line.endsWith("\n")) { line += '\n'; } Filter.Result result = myFilter.applyFilter(line, line.length()); if (result == null) return Collections.emptyList(); List<String> res = new ArrayList<>(); for (Filter.ResultItem item : result.getResultItems()) { res.add(line.substring(item.getHighlightStartOffset(), item.getHighlightEndOffset())); } return res; }