com.sun.labs.minion
Class TextHighlighter

java.lang.Object
  extended by com.sun.labs.minion.TextHighlighter
All Implemented Interfaces:
PassageHighlighter

public class TextHighlighter
extends java.lang.Object
implements PassageHighlighter

A simple class for doing textual highlighting of a passage.


Constructor Summary
TextHighlighter()
           
 
Method Summary
 java.lang.String ellipsis()
          Produces a string that will be used as an ellipsis when removing text from overly long passages.
 java.lang.String endContext()
          Ends the context for the passage.
 java.lang.String endPassage()
          Ends the highlighting for the entire passage.
 java.lang.StringBuffer highlightMatching(java.lang.String t, int p, java.lang.StringBuffer sb, boolean htmlEncode)
          Highlights one of the actual matching terms in the query.
 java.lang.String startContext()
          Starts the context for the passage.
 java.lang.String startPassage()
          Starts the highlighting for the passage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextHighlighter

public TextHighlighter()
Method Detail

startContext

public java.lang.String startContext()
Description copied from interface: PassageHighlighter
Starts the context for the passage.

Specified by:
startContext in interface PassageHighlighter
Returns:
the starting context for the passage.

endContext

public java.lang.String endContext()
Description copied from interface: PassageHighlighter
Ends the context for the passage.

Specified by:
endContext in interface PassageHighlighter
Returns:
the tag to use for the end of the context for this passage.

startPassage

public java.lang.String startPassage()
Description copied from interface: PassageHighlighter
Starts the highlighting for the passage.

Specified by:
startPassage in interface PassageHighlighter
Returns:
The code for highlighting the start of the passage. This element will be added to the output passage.

endPassage

public java.lang.String endPassage()
Description copied from interface: PassageHighlighter
Ends the highlighting for the entire passage.

Specified by:
endPassage in interface PassageHighlighter
Returns:
The code for ending the highlight of the passage. This element will be added to the output passage.

ellipsis

public java.lang.String ellipsis()
Description copied from interface: PassageHighlighter
Produces a string that will be used as an ellipsis when removing text from overly long passages.

Specified by:
ellipsis in interface PassageHighlighter
Returns:
the string to be used as an ellipsis in the passage.

highlightMatching

public java.lang.StringBuffer highlightMatching(java.lang.String t,
                                                int p,
                                                java.lang.StringBuffer sb,
                                                boolean htmlEncode)
Description copied from interface: PassageHighlighter
Highlights one of the actual matching terms in the query.

Specified by:
highlightMatching in interface PassageHighlighter
Parameters:
t - The matching term.
p - The position of the matching term.
sb - A buffer to encode the term onto.
htmlEncode - If true the term must be html encoded before being added.
Returns:
The code for highlighting the term, including the term!