sunlabs.brazil.template
Class HighlightTemplate

java.lang.Object
  extended by sunlabs.brazil.template.Template
      extended by sunlabs.brazil.template.HighlightTemplate (view source)
All Implemented Interfaces:
Serializable, TemplateInterface

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.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class sunlabs.brazil.template.Template
debug
 
Constructor Summary
HighlightTemplate()
           
 
Method Summary
 boolean init(RewriteContext hr)
          This gets called at every page, at the beginning.
 void string(RewriteContext hr)
          Gets all text between tags - highlighting it appropriately.
 void tag_head(RewriteContext hr)
          Don't do highlight inside the following sections
 void tag_highlight(RewriteContext hr)
          The special entities highlight and nohighlight may be used to turn highlighting on or off in certain areas.
 void tag_nohighlight(RewriteContext hr)
           
 void tag_script(RewriteContext hr)
           
 void tag_server(RewriteContext hr)
           
 void tag_slash_head(RewriteContext hr)
           
 void tag_slash_highlight(RewriteContext hr)
           
 void tag_slash_nohighlight(RewriteContext hr)
           
 void tag_slash_script(RewriteContext hr)
           
 void tag_slash_server(RewriteContext hr)
           
 void tag_slash_style(RewriteContext hr)
           
 void tag_style(RewriteContext hr)
           
 
Methods inherited from class sunlabs.brazil.template.Template
done
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HighlightTemplate

public HighlightTemplate()
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.

Specified by:
init in interface TemplateInterface
Overrides:
init in class Template

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_slash_head

public void tag_slash_head(RewriteContext hr)

tag_script

public void tag_script(RewriteContext hr)

tag_slash_script

public void tag_slash_script(RewriteContext hr)

tag_style

public void tag_style(RewriteContext hr)

tag_slash_style

public void tag_slash_style(RewriteContext hr)

tag_server

public void tag_server(RewriteContext hr)

tag_slash_server

public void tag_slash_server(RewriteContext hr)

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_slash_highlight

public void tag_slash_highlight(RewriteContext hr)

tag_nohighlight

public void tag_nohighlight(RewriteContext hr)

tag_slash_nohighlight

public void tag_slash_nohighlight(RewriteContext hr)

Version Kenai-svn-r24, Generated 08/18/09
Copyright (c) 2001-2009, Sun Microsystems.