com.sun.labs.minion
Class SimpleHighlighter

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

public class SimpleHighlighter
extends java.lang.Object
implements PassageHighlighter

A simple tag-based passage highlighter. Used when we just have start/end tags for the passage and matching terms.


Constructor Summary
SimpleHighlighter(java.lang.String pst, java.lang.String pet, java.lang.String wst, java.lang.String wet)
           
 
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 term, int pos, 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

SimpleHighlighter

public SimpleHighlighter(java.lang.String pst,
                         java.lang.String pet,
                         java.lang.String wst,
                         java.lang.String wet)
Method Detail

startContext

public java.lang.String startContext()
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()
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()
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()
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()
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 use to indicate an ellipsis in a passage.

highlightMatching

public java.lang.StringBuffer highlightMatching(java.lang.String term,
                                                int pos,
                                                java.lang.StringBuffer sb,
                                                boolean htmlEncode)
Highlights one of the actual matching terms in the query.

Specified by:
highlightMatching in interface PassageHighlighter
Parameters:
term - The matching term.
pos - The position of the matching term.
sb - a buffer into which we will encode the term
htmlEncode - If true the term must be html encoded before being added.
Returns:
The code for highlighting the term, including the term!