public class HtmlHighlighter extends Highlighter
Represents a search result highlighter that highlights search results in an entire document text formatted in HTML.
Learn more
The example demonstrates a typical usage of the class.
String indexFolder = "c:\\MyIndex\\";
String documentsFolder = "c:\\MyDocuments\\";
// Creating an index
Index index = new Index(indexFolder);
// Indexing documents from the specified folder
index.add(documentsFolder);
// Search for the phase 'Theory of Relativity'
SearchResult result = index.search("\"Theory of Relativity\"");
// Highlighting found words in the text of a document
FoundDocument document = result.getFoundDocument(0);
OutputAdapter outputAdapter = new FileOutputAdapter("Highlighted.html");
Highlighter highlighter = new HtmlHighlighter(outputAdapter);
index.highlight(document, highlighter);
Constructor and Description |
---|
HtmlHighlighter(OutputAdapter outputAdapter)
Initializes a new instance of the
HtmlHighlighter class. |
Modifier and Type | Method and Description |
---|---|
protected Object |
createResultBuilder(TextOptions options) |
OutputAdapter |
getOutputAdapter()
Gets the output adapter passed in the constructor.
|
createResultBuilder
public HtmlHighlighter(OutputAdapter outputAdapter)
Initializes a new instance of the HtmlHighlighter
class.
outputAdapter
- The output adapter transferring a result of the highlighting.public final OutputAdapter getOutputAdapter()
Gets the output adapter passed in the constructor.
protected Object createResultBuilder(TextOptions options)
createResultBuilder
in class ResultBuilderFactory