public class HitHighlighter
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_HIGHLIGHT_TAG
Default HTML tag for highlight hits
|
protected java.lang.String |
highlightTag
the current HTML tag used for hit highlighting
|
Constructor and Description |
---|
HitHighlighter()
Create a new HitHighlighter object.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getHighlightTag()
Get the current HTML tag used for phrase highlighting.
|
java.lang.String |
highlight(java.lang.String text,
java.util.List<java.util.List<java.lang.Integer>> hits)
Surround the
hits in the provided text with an HTML tag. |
void |
setHighlightTag(java.lang.String highlightTag)
Set the current HTML tag used for phrase highlighting.
|
protected java.lang.String |
tag(boolean closeTag)
Format the current
highlightTag by adding < and >. |
public static final java.lang.String DEFAULT_HIGHLIGHT_TAG
protected java.lang.String highlightTag
public java.lang.String highlight(java.lang.String text, java.util.List<java.util.List<java.lang.Integer>> hits)
hits
in the provided text
with an HTML tag.
This is used with offsets from the search API to support the highlighting of query terms.text
- of the Tweet to highlighthits
- A List of highlighting offsets (themselves lists of two elements)protected java.lang.String tag(boolean closeTag)
highlightTag
by adding < and >.
If closeTag
is true
then the tag returned will include a
/
to signify a closing tag.closeTag
- true if this is a closing tag, false otherwisepublic java.lang.String getHighlightTag()
public void setHighlightTag(java.lang.String highlightTag)
highlightTag
- sets highlighting tag