com.twitter
Class HitHighlighter

java.lang.Object
  extended by com.twitter.HitHighlighter

public class HitHighlighter
extends Object

A class for adding HTML highlighting in Tweet text (such as would be returned from a Search)


Field Summary
static String DEFAULT_HIGHLIGHT_TAG
          Default HTML tag for highlight hits
protected  String highlightTag
          the current HTML tag used for hit highlighting
 
Constructor Summary
HitHighlighter()
          Create a new HitHighlighter object.
 
Method Summary
 String getHighlightTag()
          Get the current HTML tag used for phrase highlighting.
 String highlight(String text, List<List<Integer>> hits)
          Surround the hits in the provided text with an HTML tag.
 void setHighlightTag(String highlightTag)
          Set the current HTML tag used for phrase highlighting.
protected  String tag(boolean closeTag)
          Format the current highlightTag by adding < and >.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_HIGHLIGHT_TAG

public static final String DEFAULT_HIGHLIGHT_TAG
Default HTML tag for highlight hits

See Also:
Constant Field Values

highlightTag

protected String highlightTag
the current HTML tag used for hit highlighting

Constructor Detail

HitHighlighter

public HitHighlighter()
Create a new HitHighlighter object.

Method Detail

highlight

public String highlight(String text,
                        List<List<Integer>> hits)
Surround the 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.

Parameters:
text - of the Tweet to highlight
hits - A List of highlighting offsets (themselves lists of two elements)
Returns:
text with highlight HTML added

tag

protected String tag(boolean closeTag)
Format the current highlightTag by adding < and >. If closeTag is true then the tag returned will include a / to signify a closing tag.

Parameters:
true - if this is a closing tag, false otherwise

getHighlightTag

public String getHighlightTag()
Get the current HTML tag used for phrase highlighting.

Returns:
current HTML tag (without < or >)

setHighlightTag

public void setHighlightTag(String highlightTag)
Set the current HTML tag used for phrase highlighting.

Parameters:
new - HTML tag (without < or >)


Copyright © 2014. All Rights Reserved.