public class Template
extends java.lang.Object
Template is a template to format a text string. A Template contains
placeholders or variables which are to be substituted by their values. These
placeholders or variables are delimited with certain character sequences.
The default sequence is '##' on both sides of the placeholder name.
For example, a template might look like
First Name: ##firstname##
Last Name: ##lastname##
where ##firstname## and ##lastname## are two placeholders. The substitute
method will replace them with the given values. The name of the placeholder
is called field. It is OK for a field to contain certain Perl5 meta chars.
When a Template object is instantiated, the text is scanned for any pattern
of ##[^#]+## as the placeholders it may contain. In this case, a legal field
name is any sequence of characters that does not contain a hashsign.
In general, Template supports customized patterns for placeholders or
variables, such as \([^\(\)]+\) or \$\{[^\$\{\}]+\}, etc.
Template also provides the methods for the actual substitutions.
They require either a key-value pair or a Map with all key-value pairs.
- Author:
- yannanlu@yahoo.com