void () { FrameSearcher searcher; String prevPageText; String curPageText; String nextPageText; String tailText; char prefixSymbol; char postfixSymbol; long pagesAmount; int tailLength; long curPageNumber; ArrayList<SearchResult> allMatchesAtFrame; int index; searcher = createFrameSearcher(options, project); tailLength = getTailLength(options); try { /* preparing init data... */ pagesAmount = fileDataProviderForSearch.getPagesAmount(); curPageNumber = getPageNumberForBeginning(pagesAmount, options); /* checking if it is the end... */ if (isTheEndOfSearchingCycle(curPageNumber, pagesAmount, options)) { myCallback.tellSearchIsFinished(this, curPageNumber); return; } prevPageText = curPageNumber > 0 ? fileDataProviderForSearch.getPage_wait(curPageNumber - 1).getText() : ""; curPageText = fileDataProviderForSearch.getPage_wait(curPageNumber).getText(); nextPageText = curPageNumber < pagesAmount - 1 ? fileDataProviderForSearch.getPage_wait(curPageNumber + 1).getText() : ""; tailText = getTailFromPage(nextPageText, tailLength); prefixSymbol = getPrefixSymbol(prevPageText); postfixSymbol = getPostfixSymbol(nextPageText, tailLength); myCallback.tellSearchProgress(this, curPageNumber, pagesAmount); /* searching in start page... */ searcher.setFrame(curPageNumber, prefixSymbol, curPageText, tailText, postfixSymbol); allMatchesAtFrame = searcher.findAllMatchesAtFrame(); index = tryGetClosestResult(allMatchesAtFrame, options); if (index != -1) { myCallback.tellClosestResultFound(this, allMatchesAtFrame, index); return; } /* searching in next pages... */ while (true) { /* preparing data for searching in next page if it's possible*/ pagesAmount = fileDataProviderForSearch.getPagesAmount(); if (options.searchForwardDirection) { curPageNumber++; prevPageText = curPageText; curPageText = nextPageText; nextPageText = curPageNumber < pagesAmount - 1 ? fileDataProviderForSearch.getPage_wait(curPageNumber + 1).getText() : ""; } else { curPageNumber--; nextPageText = curPageText; curPageText = prevPageText; prevPageText = curPageNumber > 0 ? fileDataProviderForSearch.getPage_wait(curPageNumber - 1).getText() : ""; } /* checking if it is the end... */ if (isTheEndOfSearchingCycle(curPageNumber, pagesAmount, options)) { myCallback.tellSearchIsFinished(this, getPreviousPageNumber(curPageNumber, options)); return; } if (isShouldStop()) { myCallback.tellSearchWasStopped(this, curPageNumber); return; } /* preparing addictive data */ tailText = getTailFromPage(nextPageText, tailLength); prefixSymbol = getPrefixSymbol(prevPageText); postfixSymbol = getPostfixSymbol(nextPageText, tailLength); myCallback.tellSearchProgress(this, curPageNumber, pagesAmount); /* searching for result in current page */ searcher.setFrame(curPageNumber, prefixSymbol, curPageText, tailText, postfixSymbol); allMatchesAtFrame = searcher.findAllMatchesAtFrame(); if (allMatchesAtFrame.size() > 0) { myCallback.tellClosestResultFound(this, allMatchesAtFrame, options.searchForwardDirection ? 0 : allMatchesAtFrame.size() - 1); return; } } } catch (IOException e) { logger.warn(e); myCallback.tellSearchWasCatchedException(this, e); } }