com.sun.labs.minion
Interface PassageHighlighter

All Known Implementing Classes:
SimpleHighlighter, TextHighlighter

public interface PassageHighlighter

An interface for providing call back functions when doing passage highlighting. A passage consists of three parts:

  1. The context. This is the text before and after the actual passage. The size of the context is determined by the application. This interface provides callbacks for the beginning and end of the context.
  2. The passage. This is the actual passage that was determined from the document. This interface provides callbacks for the beginning and ending of the passage.
  3. The matching terms. These are the terms from the document that matched the terms in the query. This interface provides a callback that will be called each time a matching term is encountered.


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 b, 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.
 

Method Detail

startContext

java.lang.String startContext()
Starts the context for the passage.

Returns:
the starting context for the passage.

endContext

java.lang.String endContext()
Ends the context for the passage.

Returns:
the tag to use for the end of the context for this passage.

startPassage

java.lang.String startPassage()
Starts the highlighting for the passage.

Returns:
The code for highlighting the start of the passage. This element will be added to the output passage.

endPassage

java.lang.String endPassage()
Ends the highlighting for the entire passage.

Returns:
The code for ending the highlight of the passage. This element will be added to the output passage.

ellipsis

java.lang.String ellipsis()
Produces a string that will be used as an ellipsis when removing text from overly long passages.

Returns:
the string to be used as an ellipsis in the passage.

highlightMatching

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

Parameters:
term - The matching term.
pos - The position of the matching term.
b - 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!