FindResult (String frameText, int offset, FindModel ijFindModel) { String where = frameText.substring(offset); String what = ijFindModel.getStringToFind(); int relativeIndex = where.indexOf(what); if (relativeIndex < 0) { return new FindResult(0, 0) { @Override public boolean isStringFound() { return false; } }; } else { return new FindResult(offset + relativeIndex, offset + relativeIndex + what.length()) { @Override public boolean isStringFound() { return true; } }; } }