class SearchEngine
{
    private static final Logger LOG = LogManager.getLogger(SearchEngine.class);

    private final Document document;
    private final Highlighter highlighter;
    private final Highlighter.HighlightPainter painter;

    /**
     * Constructor.
     * @param textComponent JTextComponent that is to be searched.
     * @param painter Highlighter.HighlightPainter instance to paint the highlights.
     */
    SearchEngine(JTextComponent textComponent, Highlighter.HighlightPainter painter)
    {
        this.document = textComponent.getDocument();
        this.highlighter = textComponent.getHighlighter();
        this.painter = painter;
    }

    /**
     * Search the word.
     * @param searchKey String. Search word.
     * @param isCaseSensitive boolean. If search is case sensitive.
     * @return ArrayList<Highlighter.Highlight>.
     */
    public List<Highlighter.Highlight> search(String searchKey, boolean isCaseSensitive)
    {<FILL_FUNCTION_BODY>}
}

        List<Highlighter.Highlight> highlights = new ArrayList<>();

        if (searchKey != null)
        {
            highlighter.removeAllHighlights();

            if (searchKey.isEmpty())
            {
                return highlights;
            }

            String textContent;

            try
            {
                textContent = document.getText(0, document.getLength());
            }
            catch (BadLocationException e)
            {
                LOG.error(e.getMessage(), e);
                return highlights;
            }
            if (!isCaseSensitive)
            {
                textContent = textContent.toLowerCase();
                searchKey = searchKey.toLowerCase();
            }

            int searchKeyLength = searchKey.length();
            int startAt = 0;
            int resultantOffset;
            int indexOfHighLight = 0;

            while ((resultantOffset = textContent.indexOf(searchKey, startAt)) != -1)
            {
                try
                {
                    highlighter.addHighlight(resultantOffset, resultantOffset + searchKeyLength, painter);
                    highlights.add(highlighter.getHighlights()[indexOfHighLight++]);
                    startAt = resultantOffset + searchKeyLength;
                }
                catch (BadLocationException e)
                {
                    LOG.error(e.getMessage(), e);
                }
            }
        }
        return highlights;
    
<no_super_class>