sunlabs.brazil.template

Class HighlightTemplate

public class HighlightTemplate extends Template implements Serializable

Template class for highlighting text that matches a regular expression. All text between html/xml entities is matched against a regular expression. For each portion of text that matches the expression, a pair of html/xml tags is added on either side of all matched text. Highlighting is automatically turned off inside of head, script, style, and server tags.

Properties. These are recomputed for every page that highlight changes.

highlight
A regular expression that with match any text between entities.
tag
the html/xml tag pair that will be added before and after all text maching "highlight", above. The default is "<font> ..... </font>
options
the set of name=value options that will be added to the starting tag of the tag pair, above. The default is "color=red".
matchCase
If specifies, matches are case sensitive. The default is to ignore case when matching.
substitute
The string to substitute for the matched text. This is for advanced uses. If specified, the values for tag and options are ignored. The default is: <${tag} ${options}>&</${tag}> The format of the string is a regular expression substitution string, which supports ${} style variable substitutions from the request properties.
mustHighlight
If not set, the entire document is surrounded by implicit highlight tags. If set no highlighting will take place until an actual highlight tag is present.
exit
If set, the template "init" method will return false, and no further processing will take place. This is useful if this template is used by itself.

The following html tags are processed:

highlight
/highlight
Only text between these tags is considered for highlighting.
nohighlight
/nohighlight
Temporarily undoes the effect of a highlight tag. In the current implementation, highlight and nohighlight don't nest.

Version: 2.1 HighlightTemplate.java %V% 0

Author: Stephen Uhler

Method Summary
booleaninit(RewriteContext hr)
This gets called at every page, at the beginning.
voidstring(RewriteContext hr)
Gets all text between tags - highlighting it appropriately.
voidtag_head(RewriteContext hr)
Don't do highlight inside the following sections
voidtag_highlight(RewriteContext hr)
The special entities highlight and nohighlight may be used to turn highlighting on or off in certain areas.
voidtag_nohighlight(RewriteContext hr)
voidtag_script(RewriteContext hr)
voidtag_server(RewriteContext hr)
voidtag_slash_head(RewriteContext hr)
voidtag_slash_highlight(RewriteContext hr)
voidtag_slash_nohighlight(RewriteContext hr)
voidtag_slash_script(RewriteContext hr)
voidtag_slash_server(RewriteContext hr)
voidtag_slash_style(RewriteContext hr)
voidtag_style(RewriteContext hr)

Method Detail

init

public boolean init(RewriteContext hr)
This gets called at every page, at the beginning. If this is our first time, get the config stuff out of the request properties.

string

public void string(RewriteContext hr)
Gets all text between tags - highlighting it appropriately. To restrict the tag set, define the entities and set the shouldHighlight flag appropriately.

tag_head

public void tag_head(RewriteContext hr)
Don't do highlight inside the following sections

tag_highlight

public void tag_highlight(RewriteContext hr)
The special entities highlight and nohighlight may be used to turn highlighting on or off in certain areas.

tag_nohighlight

public void tag_nohighlight(RewriteContext hr)

tag_script

public void tag_script(RewriteContext hr)

tag_server

public void tag_server(RewriteContext hr)

tag_slash_head

public void tag_slash_head(RewriteContext hr)

tag_slash_highlight

public void tag_slash_highlight(RewriteContext hr)

tag_slash_nohighlight

public void tag_slash_nohighlight(RewriteContext hr)

tag_slash_script

public void tag_slash_script(RewriteContext hr)

tag_slash_server

public void tag_slash_server(RewriteContext hr)

tag_slash_style

public void tag_slash_style(RewriteContext hr)

tag_style

public void tag_style(RewriteContext hr)