com.uwyn.rife.template
Interface Template

All Superinterfaces:
Cloneable
All Known Implementing Classes:
AbstractTemplate

public interface Template
extends Cloneable

A template is used to construct, manipulate and produce text content.

Templates can be used for a variety of text types, including XHTML, plain text, XML, SQL and even Java source. Each template type has similar features, the biggest difference is the syntax of the invisible tag which takes the form of a comment in the corresponding language (<!-- --> for XHTML and XML, /* -* / for Java and SQL, ...).

Using templates

Templates are most commonly used to produce web pages, which is why a method like ElementSupport.getXhtmlTemplate(String) is used. By obtaining a template instance from the active Element, features that are related to the web engine are added. To print a template for page output, ElementSupport.print(Template) is usually used. However, the content of any template instance can be retrieved with the getContent() method which produces a regular String that is usable anywhere.

Components of a template

Templates are controlled by external code (usually a RIFE element), but communication is bidirectional between a template and the logic that controls it. A template can provide content to the controller through blocks, and the controller can insert or replace text in the template through template values. The controller can also provide the template with expression variables and resource bundles.

Values

A value is the simplest concept in a template. It is the placeholder for text somewhere in a block or in the page itself. In a HTML template, a value called "name" is created using a declaration like:

<!--!V 'name'/-->

The controller can then fill this value with any of the setValue and appendValue methods.

Values are mainly a one-way communication channel from the logic to the template. However, values may contain a default value which can be read by the controller:

<!--V 'name'-->Some default<!--/V-->

Values are automatically filled in many ways aside from calling setValue(java.lang.String, java.util.List) and appendValue(java.lang.String, java.lang.Object) directly. We will discuss this later.

Blocks

Blocks represent the other direction of communication between a controller and a template. A HTML template can define a block called "greeting" like this:

<!--B 'greeting'-->Welcome, <!--V 'name'/--><!--/B-->

The literal text in the block is not accessible by the controller. It is evaluated when the block is used. For example by reading it from the controller, assigning it to a value or appending it to a value in the template itself. The evaluation is based on the values that are currently present in the template. If a block contains a value that hasn't been set yet, the value placeholder will be remembered, unpopulated. It will be evaluated against another value context the next time the content of the block is used.

As soon as value placeholders exist when a block is used, they are captured from the template and replaced with their available content. They will become immutable in the result of the operation that used the block. This means that repeated calls to appendBlock(java.lang.String, java.lang.String) can append a block to a value multiple times with different values each time. This feature allows blocks to be used for producing repeating constructs such as tables, using a pattern like this:

template.removeValue("people", "");
Iterator it = people.iterator();
while (it.hasNext()) {
    Person person = (Person)it.next();
    template.setValue("name", person.getName());
    template.setValue("age", person.getAge());
    template.appendBlock("people", "person");
}

Nested loops and corresponding nested blocks may be used to produce more complex constructs.

Expressions

Templates may contain small boolean expressions that are written in JVM scripting languages like OGNL, Groovy, or Janino. These expressions will be automatically evaluated and allow certain blocks to be assigned automatically to a value according to the scripted conditions. The controller does not execute the scripts itself, but it may provide variables to which the scripts have access, using the setExpressionVar method. For example, if a template contains:

<!--V 'GROOVY:welcome'--><!--/V-->
<!--V 'GROOVY:welcome:[[ showWelcome ]]'-->Welcome,
<!--V 'name'/--><!--/V-->

A controller could decide whether the welcome block should be shown using:

template.setExpressionVar("showWelcome", person != null);

Apart from the expression variables, each expression is evaluated against a current root object whose methods and properties you can access using the regular scripting language syntax. This root object is by default the template instance that you are processing.

To make it easy to write expressions against commonly used contexts, RIFE also provides specialized scripted tags that set different root objects. Currently the language:ROLEUSER and language:CONFIG tags are provided.

Localization

It's possible to easily localize templates through the standard ResourceBundle mechanism that is available in Java. The strings that are localized are automatically filtered and replace values tags. The format for localized values is:

<!--V 'L10N:key'-->default value<!--/V-->

Of course, before replacement, the template instance has to know where to look for the key. Therefore, the addResourceBundle(ResourceBundle) method needs to be called to make the template aware of it.

For example, consider the following resource bundles:

text_nl.properties

hello = Hallo

text_fr.properties

hello = Bonjour

and the following template:

Hey mister, I said: <!--V 'L10N:hello'/-->!"

The following Java code:

Template template_html = TemplateFactory.HTML.get("text");
ResourceBundle bundle = Localization.getResourceBundle("text", "fr");
template_html.addResourceBundle(bundle);
System.out.println(template.getContent());

will output:

Hey mister, I said: "Bonjour!"

Just replacing the second line with the following:

...
ResourceBundle bundle = Localization.getResourceBundle("text", "nl");
...

will output:

Hey mister, I said: "Hallo!"

Very often, resourcebundle are used for the whole application. Therefore, application-wide default resource bundles can be specified for each template type through the RIFE configuration, for example:

<list name="TEMPLATE_DEFAULT_RESOURCEBUNDLES_ENGINEHTML">
    <item>l10n/graphics</item>
    <item>l10n/text</item>
    <item>l10n/descriptions</item>
</list>

This will automatically add these resourcebundles to any template instance of the corresponding type, calling addResourceBundle(ResourceBundle) is thus not needed anymore and localization will happen without any intervention from the controller.

While resource bundles offer a good method to isolate localized text snippets, it's sometimes interesting to be able to conditionally display parts of templates with lots of markup. For this purpose, resource bundles are actually awkward to use. Templates are therefore able to set blocks automatically to values, according to the default localization language (L10N_DEFAULT_LANGUAGE configuration parameter). This can be done with the <!--B 'LANG:id:language'--> block syntax.

For example:

<!--V 'LANG:value1'-->default<!--/V--> [!V 'LANG:value2'/]
<!--B 'LANG:value1:nl'-->ja ja<!--/B-->
[!B 'LANG:value2:fr']oui oui[!/B]
[!B 'LANG:value2:en ']yes yes[!/B]

will display this when the default language is 'en':

default yes yes

or this when the default language is 'fr':

default oui oui

or this when the default language is 'nl':

ja ja [!V 'LANG:value2'/]

Value renderers

Besides the main manipulation logic of a template, value content needs to be sometimes created that is solely presentation related. This doesn't actually have its place in elements and sometimes even creates a burden. For these purposes, we created the ValueRenderer interface. Classes that implement this interface can be specified in any template like this:

<!--V 'RENDER:pakkage.classname'/-->

An instance of the class will be created and the ValueRenderer.render(com.uwyn.rife.template.Template, java.lang.String, java.lang.String) method will be called if the value hasn't been set yet. This has as side-effect that if you have several occurances of this value ID, they will all have the same renderer value and the renderer will only be called once.

If you need to have different results of the same renderer, you need to use a differentiator, like this:

<!--V 'RENDER:pakkage.classname:differentiator'/-->

Encoding

Templates automatically encode values to the appropriate format (HTML, XHTML, etc.) when using forms, configuration tags, localization tags, and when setting values from bean properties. However, in many cases it is necessary to encode values manually, to prevent malicious content from being inserted into your site, or simply to display text correctly if it may contain illegal characters (like < in HTML). You can encode text using the template's encoder after calling the getEncoder() method.

Other features

Templates are powerful and some features are not described here. The Templates wiki page describes several other features, including filtered values, alternative means of localization, and other forms of templates.

Since:
1.0
Version:
$Revision: 3643 $
Author:
Keith Lea <keith[remove] at cs dot oswego dot edu>, Geert Bevin (gbevin[remove] at uwyn dot com)

Method Summary
 void addResourceBundle(ResourceBundle resourceBundle)
          Adds a resource bundle to this template.
 void appendBlock(String valueId, String blockId)
          Appends the content of a block to a value.
 void appendValue(String id, boolean value)
          Appends "true" or "false" to the specified value in this template, depending on the given value.
 void appendValue(String id, char value)
          Appends the single specified character to the specified value in this template.
 void appendValue(String id, char[] value)
          Appends the given characters to the specified value in this template.
 void appendValue(String id, char[] value, int offset, int count)
          Appends the specified range of the given character string to the specified value in this template.
 void appendValue(String id, double value)
          Appends the given double precision floating point value to the specified value in this template.
 void appendValue(String id, float value)
          Appends the given floating point value to the specified value in this template.
 void appendValue(String id, int value)
          Appends the given integer to the specified value in this template.
 void appendValue(String id, long value)
          Appends the given long to the specified value in this template.
 void appendValue(String id, Object value)
          Appends the result of calling String.valueOf on the given value to the specified value in this template.
 void appendValue(String id, String value)
          Appends the given string, or an empty string if value is null, to the specified value in this template.
 void blankValue(String id)
          Set the content of the specified value to an empte string.
 void cacheObject(String key, Object value)
          Stores the given value in a cache, associated with the given key.
 void clear()
          Resets all values in this template and removes any resource bundles.
 Object clone()
          Returns a shallow copy of this template, with the same values, expression variables, and so on.
 int countValues()
          Returns the number of values in this template which have been set.
 InternalValue createInternalValue()
          Returns an anonymous value that can be used to construct complex content for use within this template.
 List<String> evaluateConfigTags()
          Fills all values in this template which match "CONFIG:key", where "key" is a configuration value name in the Config instance returned by Config.getRepInstance().
 List<String> evaluateExpressionConfigTags(String id)
          Evaluates the specified OGNL, Groovy, or Janino configuration expression tag.
 List<String> evaluateExpressionTags(String id)
          Evaluates the specified OGNL, Groovy, or Janino expression tag.
 List<String> evaluateL10nTags()
          Fills all values in this template which match "L10N:key", where "key" is a key in a resource bundle registered for this template.
 List<String> evaluateLangTags(String id)
          Fills the value "LANG:id" with the value of the block "LANG:id:langid", where "id" is the given ID, and "langid" is this template's current language ID.
 List<String> evaluateRenderTags()
          Evalutes all values in this template with ID's of the form "RENDER:class" or "RENDER:class:differentiator", where "class" is the fully-qualified name of a class which extends ValueRenderer, the result of calling ValueRenderer.render on a new instance of the class.
 String[] getAvailableValueIds()
          Returns a list of the ID's of all values present in this template, including set and unset values.
 BeanHandler getBeanHandler()
          Returns this template's bean handler.
 String getBlock(String id)
          Returns the evaluated content of the specified block as a text.
 Object getCacheObject(String key)
          Returns the value corresponding to the given key in this template's cache, or null if no such cached object exists.
 String getContent()
          Returns the entire content of the template and finalize all non evaluated values.
 String getDefaultContentType()
          Returns this template's default content type, for example text/html.
 String getDefaultValue(String id)
          Returns the original text of the specified value, before any modification that may have been made using setValue(java.lang.String, java.util.List) or similar methods.
 List<CharSequence> getDeferredBlock(String id)
          Returns the content of the specified block as a list with all the individual parts.
 List<CharSequence> getDeferredContent()
          Returns the content of this template as a list with all the individual parts.
 Map<URL,Long> getDependencies()
          Returns a list of URL's that this template depends on, and their last modification dates (in milliseconds since the Unix epoch).
 TemplateEncoder getEncoder()
          Returns the encoder that this template uses to convert strings to values in the template's generated text output.
 Map<String,Object> getExpressionVars()
          Returns the name and value of all of the expression variables which have been set in this template.
 List<String[]> getFilteredBlocks(String filter)
          Each template type supports a set of special block tags that are used for adding automated features like localization, block value scripting, config value setting, ...
 List<String[]> getFilteredValues(String filter)
          Each template type supports a set of special value tags that are used for adding automated features like embedded elements, localization, block value scripting, config value setting, ...
 String getFullName()
          Returns this template's full name, as it was used to instantiate it by a template factory.
 String getLanguage()
          Returns this template's current 2-letter language code.
 long getModificationTime()
          Returns when the file corresponding to this template was modified, in milliseconds since the Unix epoch.
 String getName()
          Returns this template's name, without path information or file extension.
 Collection<ResourceBundle> getResourceBundles()
          Returns a list of the resource bundles used by this template.
 Collection<String> getUnsetValueIds()
          Returns a list of the ID's of all values in this template which have not been set.
 String getValue(String id)
          Returns the current content of the specified value as a string.
 boolean hasBlock(String id)
          Returns whether this template contains a block with the given ID.
 boolean hasDefaultValue(String id)
          Returns whether a default value was specified in this template for the specified value.
 boolean hasFilteredBlocks(String filter)
          Returns whether any block matched a particular filter at template compilation.
 boolean hasFilteredValues(String filter)
          Returns whether any value matched a particular filter at template compilation.
 boolean hasResourceBundles()
          Returns whether this template has any resource bundles registered.
 boolean hasValueId(String id)
          Returns whether this template contains a value with the given ID.
 boolean isValueSet(String id)
          Returns whether the specified value has been set.
 void removeBean(Object bean)
          Reverts all values to their defaults when the identifiers match properties of the given bean, whether or not those values were set with a previous call to setBean.
 void removeBean(Object bean, String prefix)
          Reverts all values to their defaults when the identifiers match properties of the given bean preceded by the given prefix, whether or not those values were set with a previous call to setBean.
 void removeValue(String id)
          Reverts the specified value back to its default value.
 void removeValues(List<String> ids)
          Reverts the specified values back to their default value.
 void setBean(Object bean)
          Sets all values in this template whose identifiers match names of properties in the given bean.
 void setBean(Object bean, String prefix)
          Sets all values in this template whose names match names of properties in the given bean, preceded by the given prefix.
 void setBean(Object bean, String prefix, boolean encode)
          Sets all values in this template whose names match names of properties in the given bean, preceded by the given prefix, if present.
 void setBlock(String valueId, String blockId)
          Replaces the specified value with the content of the specified block.
 void setExpressionVar(String name, Object value)
          Sets a variable which can be accessed by expression tags in OGNL, Groovy, or Janino.
 void setExpressionVars(Map<String,Object> map)
          Sets the given variables to the given corresponding values, for use in expression tags.
 void setLanguage(String lang)
          Sets this template's current language code, such as "en".
 void setValue(String id, boolean value)
          Sets the specified value in this template to true or false depending on the given value.
 void setValue(String id, char value)
          Sets the specified value in this template to the single specified character.
 void setValue(String id, char[] value)
          Sets the specified value in this template to the given characters.
 void setValue(String id, char[] value, int offset, int count)
          Sets the specified value in this template to the specified range of the given character string.
 void setValue(String id, CharSequence value)
          Sets the specified value in this template to the given character sequence, or an empty character sequence if value is null.
 void setValue(String id, double value)
          Sets the specified value in this template to the given double precision floating point value.
 void setValue(String id, float value)
          Sets the specified value in this template to the given floating point value.
 void setValue(String id, int value)
          Sets the specified value in this template to the given integer.
 void setValue(String id, InternalValue internalValue)
          Sets the specified value in this template to the value of the given internal value.
 void setValue(String id, List<CharSequence> deferredContent)
          Sets the specified value in this template to content that's structured in the internal format.
 void setValue(String id, long value)
          Sets the specified value in this template to the given long.
 void setValue(String id, Object value)
          Sets the specified value in this template to the result of calling String.valueOf on the given value.
 void setValue(String id, String value)
          Sets the specified value in this template to the given string, or an empty string if value is null.
 void setValue(String id, Template template)
          Sets the specified value in this template to the current content of the given template.
 void write(OutputStream out)
          This method is a shorthand for writeContent(OutputStream).
 void writeBlock(String id, OutputStream out)
          Writes the evaluated contents of the specified block to the given output stream, using UTF-8 encoding.
 void writeContent(OutputStream out)
          Writes the complete evaluated template content to the given stream, using UTF-8 encoding.
 void writeContent(OutputStream out, String charsetName)
          Writes the complete evaluated template content to the given stream, using the specified charset for encoding.
 

Method Detail

appendBlock

void appendBlock(String valueId,
                 String blockId)
                 throws TemplateException
Appends the content of a block to a value. The values used by the block will be captured when this method is called, so any future changes to template values will not affect text which was appended when this method is called.

Parameters:
valueId - the ID of the value
blockId - the ID of the block
Throws:
TemplateException - when the valueId or blockId aren't known
Since:
1.0
See Also:
setBlock(java.lang.String, java.lang.String), getBlock(java.lang.String), getContent(), hasBlock(java.lang.String)

setBlock

void setBlock(String valueId,
              String blockId)
              throws TemplateException
Replaces the specified value with the content of the specified block. The values used by the block will be captured when this method is called, so any future changes to template values will not affect the specified value text.

Parameters:
valueId - the ID of the value
blockId - the ID of the block
Throws:
TemplateException - when the valueId or blockId aren't known
Since:
1.0
See Also:
appendBlock(java.lang.String, java.lang.String), getBlock(java.lang.String), getContent(), hasBlock(java.lang.String)

getBlock

String getBlock(String id)
                throws TemplateException
Returns the evaluated content of the specified block as a text.

Parameters:
id - the ID of the block in the template
Returns:
the evaluated textual content of the specified block
Throws:
TemplateException - when the block ID isn't known
Since:
1.0
See Also:
appendBlock(java.lang.String, java.lang.String), setBlock(java.lang.String, java.lang.String), getContent(), hasBlock(java.lang.String)

getContent

String getContent()
                  throws TemplateException
Returns the entire content of the template and finalize all non evaluated values. The content is the root block with has an empty string as identifier.

Values without content will either use their default value if it has been provided, or the tag that was used to declare the value will be output as-is.

All specialized tags will also be evaluated (resourcebundle localization, block localization, value renderers, expressions, ...).

Returns:
the entire textual content of the template
Throws:
TemplateException - when an error occurred during the processing of the specialized tags
Since:
1.0
See Also:
appendBlock(java.lang.String, java.lang.String), setBlock(java.lang.String, java.lang.String), getBlock(java.lang.String), hasBlock(java.lang.String)

writeBlock

void writeBlock(String id,
                OutputStream out)
                throws IOException,
                       TemplateException
Writes the evaluated contents of the specified block to the given output stream, using UTF-8 encoding.

Parameters:
id - the ID of the block
out - the stream to write to
Throws:
IOException - when errors occur during the manipulation of the output stream
TemplateException - when the block ID isn't known
Since:
1.0
See Also:
writeContent(OutputStream), writeContent(OutputStream, String), write(java.io.OutputStream)

writeContent

void writeContent(OutputStream out)
                  throws IOException,
                         TemplateException
Writes the complete evaluated template content to the given stream, using UTF-8 encoding.

Parameters:
out - the stream to which the template contents should be written
Throws:
IOException - when errors occur during the manipulation of the output stream
TemplateException - when an error occurs during the template content evaluation
Since:
1.0
See Also:
writeBlock(java.lang.String, java.io.OutputStream), writeContent(OutputStream, String), write(java.io.OutputStream)

writeContent

void writeContent(OutputStream out,
                  String charsetName)
                  throws IOException,
                         TemplateException
Writes the complete evaluated template content to the given stream, using the specified charset for encoding.

Parameters:
out - the stream to which the template contents should be written
charsetName - the name of the charset to use
Throws:
IOException - when errors occur during the manipulation of the output stream; or

when the character set isn't valid

TemplateException - when an error occurs during the template content evaluation
Since:
1.0
See Also:
writeBlock(java.lang.String, java.io.OutputStream), writeContent(OutputStream), write(java.io.OutputStream)

write

void write(OutputStream out)
           throws IOException,
                  TemplateException
This method is a shorthand for writeContent(OutputStream).

Parameters:
out - the stream to which the template contents should be written
Throws:
IOException - when errors occur during the manipulation of the output stream; or

when the character set isn't valid

TemplateException - when an error occurs during the template content evaluation
Since:
1.0
See Also:
writeBlock(java.lang.String, java.io.OutputStream), writeContent(OutputStream), writeContent(OutputStream, String)

getDeferredBlock

List<CharSequence> getDeferredBlock(String id)
                                    throws TemplateException
Returns the content of the specified block as a list with all the individual parts.

This list is the internal representation of all content with placeholders for the values that aren't filled in yet. This structure is mainly used internally by the framework. The list structure also makes it possible to optimize performance and memory usage.

Parameters:
id - the ID of a block in this template
Returns:
a list of the contents of the specified block
Throws:
TemplateException - if no such block exists; or

if an error occurred during the retrieval

Since:
1.0
See Also:
getDeferredContent()

getDeferredContent

List<CharSequence> getDeferredContent()
                                      throws TemplateException
Returns the content of this template as a list with all the individual parts.

This list is the internal representation of all content with placeholders for the values that aren't filled in yet. This structure is mainly used internally by the framework. The list structure also makes it possible to optimize performance and memory usage.

Returns:
a list of the contents of this template
Throws:
TemplateException - if an error occurred during the retrieval
Since:
1.0
See Also:
getDeferredBlock(java.lang.String)

createInternalValue

InternalValue createInternalValue()
Returns an anonymous value that can be used to construct complex content for use within this template. See InternalValue for details.

The returned internal value is tied closely to the template it was obtained from, methods like InternalValue.appendBlock reference blocks within this template.

Returns:
a new internal value instance for constructing more complex parts of this template
Since:
1.0
See Also:
InternalValue

setValue

void setValue(String id,
              List<CharSequence> deferredContent)
              throws TemplateException
Sets the specified value in this template to content that's structured in the internal format.

Parameters:
id - the ID of the value in this template
deferredContent - content in the internal format
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
appendValue(java.lang.String, java.lang.Object), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

setValue

void setValue(String id,
              InternalValue internalValue)
              throws TemplateException
Sets the specified value in this template to the value of the given internal value.

Parameters:
id - the ID of the value in this template
internalValue - an internal value, null set the value content to blank content
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
appendValue(java.lang.String, java.lang.Object), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

setValue

void setValue(String id,
              Object value)
              throws TemplateException
Sets the specified value in this template to the result of calling String.valueOf on the given value.

Parameters:
id - the ID of the value in this template
value - an object
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
appendValue(java.lang.String, java.lang.Object), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

setValue

void setValue(String id,
              boolean value)
              throws TemplateException
Sets the specified value in this template to true or false depending on the given value.

Parameters:
id - the ID of the value in this template
value - a boolean value
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
appendValue(java.lang.String, java.lang.Object), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

setValue

void setValue(String id,
              char value)
              throws TemplateException
Sets the specified value in this template to the single specified character.

Parameters:
id - the ID of the value in this template
value - a character
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
appendValue(java.lang.String, java.lang.Object), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

setValue

void setValue(String id,
              char[] value)
              throws TemplateException
Sets the specified value in this template to the given characters. The given value must not be null.

Parameters:
id - the ID of the value in this template
value - a string of characters
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
appendValue(java.lang.String, java.lang.Object), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

setValue

void setValue(String id,
              char[] value,
              int offset,
              int count)
              throws TemplateException
Sets the specified value in this template to the specified range of the given character string. The specified number of bytes from value will be used, starting at the character specified by offset.

Parameters:
id - the ID of the value in this template
value - a character string
offset - the index in value of the first character to use
count - the number of characters to use
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
appendValue(java.lang.String, java.lang.Object), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

setValue

void setValue(String id,
              double value)
              throws TemplateException
Sets the specified value in this template to the given double precision floating point value. This method uses the String.valueOf method to print the given value, which probably prints more digits than you like. You probably want String.format or NumberFormat instead.

Parameters:
id - the ID of the value in this template
value - a floating point value
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
appendValue(java.lang.String, java.lang.Object), isValueSet(java.lang.String), removeValue(java.lang.String), blankValue(java.lang.String), hasValueId(java.lang.String)

setValue

void setValue(String id,
              float value)
              throws TemplateException
Sets the specified value in this template to the given floating point value. This method uses the String.valueOf method to print the given value, which probably prints more digits than you like. You probably want String.format or NumberFormat instead.

Parameters:
id - the ID of the value in this template
value - a floating point value
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
appendValue(java.lang.String, java.lang.Object), isValueSet(java.lang.String), removeValue(java.lang.String), blankValue(java.lang.String), hasValueId(java.lang.String)

setValue

void setValue(String id,
              int value)
              throws TemplateException
Sets the specified value in this template to the given integer.

Parameters:
id - the ID of the value in this template
value - an integer
Throws:
TemplateException - if the specified value does not exist in this template
Since:
1.0
See Also:
appendValue(java.lang.String, java.lang.Object), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

setValue

void setValue(String id,
              long value)
              throws TemplateException
Sets the specified value in this template to the given long.

Parameters:
id - the ID of the value in this template
value - a long
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
appendValue(java.lang.String, java.lang.Object), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

setValue

void setValue(String id,
              String value)
              throws TemplateException
Sets the specified value in this template to the given string, or an empty string if value is null.

Parameters:
id - the ID of the value in this template
value - a string, or null
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
appendValue(java.lang.String, java.lang.Object), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

setValue

void setValue(String id,
              CharSequence value)
              throws TemplateException
Sets the specified value in this template to the given character sequence, or an empty character sequence if value is null.

Parameters:
id - the ID of the value in this template
value - a character sequence, or null
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.5
See Also:
appendValue(java.lang.String, java.lang.Object), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

setValue

void setValue(String id,
              Template template)
              throws TemplateException
Sets the specified value in this template to the current content of the given template. The given template's value will be evaluated immediately, instead of being stored to be evaluated later.

If the given template is null, the specified value will be set to an empty string.

Parameters:
id - the ID of the value in this template
template - a template
Throws:
TemplateException - if the specified value ID does not exist in this template; or

if an error occurred during the evaluation of the template parameter

Since:
1.0
See Also:
appendValue(java.lang.String, java.lang.Object), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

setBean

void setBean(Object bean)
             throws TemplateException
Sets all values in this template whose identifiers match names of properties in the given bean.

For example, given a class:

 class Person {
   private String first;
   private String last;

   public String getFirstName() { return first; }
   public void setFirstName(String name) { this.first = name; }

   public String getLastName() { return last; }
   public void setLastName(String name) { this.last = name; }
 

And given a template:

 Hello <!--V 'firstName'/--> <!--V 'lastName'/-->.
 

Calling this method with an instance of Person where first was "Jim" and last was "James", would produce:

Hello Jim James.

Calling this method is equivalent to calling setValue individually for each property of the bean.

This method uses this template's encoder to encode the bean properties before setting the values. To prevent this, use the other form of setBean.

Only bean properties will be considered for insertion in the template. This means only properties with a getter and a setter will be considered.

Parameters:
bean - a bean whose properties will be used to fill in values in the template
Throws:
TemplateException - if this template has no bean handling capability; or

an error occurred during the introspection of the bean

Since:
1.0
See Also:
removeBean(java.lang.Object)

setBean

void setBean(Object bean,
             String prefix)
             throws TemplateException
Sets all values in this template whose names match names of properties in the given bean, preceded by the given prefix.

For example, given a class:

 class Person {
   private String first;
   private String last;

   public String getFirstName() { return first; }
   public void setFirstName(String name) { this.first = name; }

   public String getLastName() { return last; }
   public void setLastName(String name) { this.last = name; }
 

And given a template:

 Hello <!--V 'NAME:firstName'/--> <!--V 'NAME:lastName'/-->.
 

Calling this method with an instance of Person where first was "Jim" and last was "James", and the prefix "NAME:", would produce:

Hello Jim James.

Calling this method is equivalent to calling setValue individually for each property of the bean prefixed with the given prefix.

This method uses this template's encoder to encode the bean properties before setting the values. To prevent this, use the other form of setBean.

Only bean properties will be considered for insertion in the template. This means only properties with a getter and a setter will be considered.

Parameters:
bean - a bean whose properties will be used to fill in values in the template
prefix - the prefix of values which will be filled with the given bean's property values
Throws:
TemplateException - if this template has no bean handling capability; or

an error occurred during the introspection of the bean

Since:
1.0
See Also:
removeBean(java.lang.Object)

setBean

void setBean(Object bean,
             String prefix,
             boolean encode)
             throws TemplateException
Sets all values in this template whose names match names of properties in the given bean, preceded by the given prefix, if present. If the given prefix is null, it is ignored.

For example, given a class:

 class Person {
   private String first;
   private String last;

   public String getFirstName() { return first; }
   public void setFirstName(String name) { this.first = name; }

   public String getLastName() { return last; }
   public void setLastName(String name) { this.last = name; }
 

And given a template:

 Hello <!--V 'NAME:firstName'/--> <!--V 'NAME:lastName'/-->.
 

Calling this method with an instance of Person where first was "Jim" and last was "James", and the prefix "NAME:", would produce:

Hello Jim James.

Calling this method is equivalent to calling setValue individually for each property of the bean prefixed with the given prefix.

If encode is true, this method will use this template's encoder to encode the bean properties before setting the values.

Only bean properties will be considered for insertion in the template. This means only properties with a getter and a setter will be considered.

Parameters:
bean - a bean whose properties will be used to fill in values in the template
prefix - the prefix of values which will be filled with the given bean's property values
encode - true if the bean poroperty values have to be encoded; or

false otherwise

Throws:
TemplateException - if this template has no bean handling capability; or

an error occurred during the introspection of the bean

Since:
1.0
See Also:
removeBean(java.lang.Object)

removeBean

void removeBean(Object bean)
                throws TemplateException
Reverts all values to their defaults when the identifiers match properties of the given bean, whether or not those values were set with a previous call to setBean. The values of the bean's properties are ignored.

Calling this method is equivalent to calling removeValue once for the name of each property of the given bean.

Parameters:
bean - a bean
Throws:
TemplateException - if this template has no bean handling capability; or

an error occurred during the introspection of the bean

Since:
1.0
See Also:
setBean(java.lang.Object)

removeBean

void removeBean(Object bean,
                String prefix)
                throws TemplateException
Reverts all values to their defaults when the identifiers match properties of the given bean preceded by the given prefix, whether or not those values were set with a previous call to setBean. The values of the bean's properties are ignored.

Calling this method is equivalent to calling removeValue once for the name of each property of the given bean, prefixed with the given prefix.

Parameters:
bean - a bean whose properties will be used to determine which values to remove from the template
prefix - a prefix
Throws:
TemplateException - if this template has no bean handling capability; or

an error occurred during the introspection of the bean

Since:
1.0
See Also:
setBean(java.lang.Object)

appendValue

void appendValue(String id,
                 Object value)
                 throws TemplateException
Appends the result of calling String.valueOf on the given value to the specified value in this template.

Parameters:
id - the ID of the value in this template
value - an object
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
setValue(java.lang.String, java.util.List), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

appendValue

void appendValue(String id,
                 boolean value)
                 throws TemplateException
Appends "true" or "false" to the specified value in this template, depending on the given value.

Parameters:
id - the ID of the value in this template
value - a boolean value
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
setValue(java.lang.String, java.util.List), isValueSet(java.lang.String), removeValue(java.lang.String), blankValue(java.lang.String), hasValueId(java.lang.String)

appendValue

void appendValue(String id,
                 char value)
                 throws TemplateException
Appends the single specified character to the specified value in this template.

Parameters:
id - the ID of the value in this template
value - a character
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
setValue(java.lang.String, java.util.List), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

appendValue

void appendValue(String id,
                 char[] value)
                 throws TemplateException
Appends the given characters to the specified value in this template. The given value must not be null.

Parameters:
id - the ID of the value in this template
value - a string of characters
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
setValue(java.lang.String, java.util.List), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

appendValue

void appendValue(String id,
                 char[] value,
                 int offset,
                 int count)
                 throws TemplateException
Appends the specified range of the given character string to the specified value in this template. The specified number of bytes from value will be used, starting at the character specified by offset.

Parameters:
id - the ID of the value in this template
value - a character string
offset - the index in value of the first character to use
count - the number of characters to use
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
setValue(java.lang.String, java.util.List), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

appendValue

void appendValue(String id,
                 double value)
                 throws TemplateException
Appends the given double precision floating point value to the specified value in this template. This method uses the String.valueOf method to print the given value, which probably prints more digits than you like. You probably want String.format or NumberFormat instead.

Parameters:
id - the ID of the value in this template
value - a floating point value
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
setValue(java.lang.String, java.util.List), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

appendValue

void appendValue(String id,
                 float value)
                 throws TemplateException
Appends the given floating point value to the specified value in this template. This method uses the String.valueOf method to print the given value, which probably prints more digits than you like. You probably want String.format or NumberFormat instead.

Parameters:
id - the ID of the value in this template
value - a floating point value
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
setValue(java.lang.String, java.util.List), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

appendValue

void appendValue(String id,
                 int value)
                 throws TemplateException
Appends the given integer to the specified value in this template.

Parameters:
id - the ID of the value in this template
value - an integer
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
setValue(java.lang.String, java.util.List), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

appendValue

void appendValue(String id,
                 long value)
                 throws TemplateException
Appends the given long to the specified value in this template.

Parameters:
id - the ID of the value in this template
value - a long
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
setValue(java.lang.String, java.util.List), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

appendValue

void appendValue(String id,
                 String value)
                 throws TemplateException
Appends the given string, or an empty string if value is null, to the specified value in this template.

Parameters:
id - the ID of the value in this template
value - a string, or null
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
setValue(java.lang.String, java.util.List), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

getValue

String getValue(String id)
                throws TemplateException
Returns the current content of the specified value as a string.

Parameters:
id - the ID of a value in this template
Returns:
the current content value of the specified value
Throws:
TemplateException - if the specified value ID does not exist in this template
Since:
1.0
See Also:
setValue(java.lang.String, java.util.List), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

getDefaultValue

String getDefaultValue(String id)
Returns the original text of the specified value, before any modification that may have been made using setValue(java.lang.String, java.util.List) or similar methods.

If no default value was specified for the given value, this method will return null.

Parameters:
id - the ID of a value in this template, or null
Returns:
the original text value of the specified value
Since:
1.0
See Also:
hasDefaultValue(java.lang.String)

hasDefaultValue

boolean hasDefaultValue(String id)
Returns whether a default value was specified in this template for the specified value.

Parameters:
id - the ID of a value in this template
Returns:
whether the specified value has a default value
Since:
1.0
See Also:
getDefaultValue(java.lang.String)

getFilteredBlocks

List<String[]> getFilteredBlocks(String filter)
Each template type supports a set of special block tags that are used for adding automated features like localization, block value scripting, config value setting, ... Instead of having to parse all template block identifiers each time these features are used, RIFE filters them out at template compilation and keeps them available in a separate collection.

This method is mainly used by the framework itself, the supported filter regular expressions are available from TemplateFactory and TemplateFactoryEngineTypes.

Parameters:
filter - a template factory regular expression
Returns:
a list of captured groups for matching block ID's
Since:
1.0
See Also:
hasFilteredBlocks(java.lang.String)

hasFilteredBlocks

boolean hasFilteredBlocks(String filter)
Returns whether any block matched a particular filter at template compilation.

Parameters:
filter - a template factory regular expression
Returns:
whether any matching blocks exist in this template
Since:
1.0
See Also:
getFilteredBlocks(java.lang.String)

getFilteredValues

List<String[]> getFilteredValues(String filter)
Each template type supports a set of special value tags that are used for adding automated features like embedded elements, localization, block value scripting, config value setting, ... Instead of having to parse all template value identifiers each time these features are used, RIFE filters them out at template compilation and keeps them available in a separate collection.

This method is mainly used by the framework itself, the supported filter regular expressions are available from TemplateFactory and TemplateFactoryEngineTypes.

Parameters:
filter - a template factory regular expression
Returns:
a list of captured groups for matching value ID's
Since:
1.0
See Also:
hasFilteredValues(java.lang.String)

hasFilteredValues

boolean hasFilteredValues(String filter)
Returns whether any value matched a particular filter at template compilation.

Parameters:
filter - a template factory regular expression
Returns:
whether any matching values exist in this template
Since:
1.0
See Also:
getFilteredValues(java.lang.String)

evaluateL10nTags

List<String> evaluateL10nTags()
Fills all values in this template which match "L10N:key", where "key" is a key in a resource bundle registered for this template. Each value will be filled with the value in the resource bundle with the corresponding key.

This method is normally called automatically during template initialization. You should call it if you wish to re-evaluate the tags at any time during the template's life.

Returns:
the list of names of the template values that were generated
Since:
1.0

evaluateConfigTags

List<String> evaluateConfigTags()
Fills all values in this template which match "CONFIG:key", where "key" is a configuration value name in the Config instance returned by Config.getRepInstance(). Each valuev will be filled with the value of the configuration option with the corresponding key.

This method is normally called automatically during template initialization. You should call it if you wish to re-evaluate the tags at any time during the template's life.

Returns:
the list of names of the template values that were generated
Since:
1.0

evaluateLangTags

List<String> evaluateLangTags(String id)
Fills the value "LANG:id" with the value of the block "LANG:id:langid", where "id" is the given ID, and "langid" is this template's current language ID.

If no matching block for the current language is found, the content of the specified value will not be modified.

This method is called automatically when the output is generated (such as when calling getContent()). You can manually call this method to force evaluation of the tags earlier than that.

Parameters:
id - the ID whose language tag should be filled with the appropriate block
Returns:
the list of names of the template values that were generated
Since:
1.0

evaluateExpressionTags

List<String> evaluateExpressionTags(String id)
Evaluates the specified OGNL, Groovy, or Janino expression tag. For example, if a value exists with ID "OGNL:id:[[script]]", where "id" is the given ID and "script" is some OGNL expression, this method will replace this value with the value of the evaluated OGNL expression, using the current set of expression variables.

The prefix for OGNL is "OGNL:", the prefix for Groovy is "GROOVY:" and the prefix for Janino is "JANINO:".

This method is called automatically when the output is generated (such as when calling getContent()). You can manually call this method to force evaluation of the tags earlier than that.

Parameters:
id - the ID whose expression tag will be replaced with the value of the evaluated expression in the tag ID
Returns:
the list of names of the template values that were generated
Since:
1.0

evaluateExpressionConfigTags

List<String> evaluateExpressionConfigTags(String id)
Evaluates the specified OGNL, Groovy, or Janino configuration expression tag. For example, if a value exists with ID "OGNL:CONFIG:id:[[script]]", where "id" is the given ID and "script" is some OGNL expression, this method will replace this value with the value of the evaluated OGNL expression, using the current set of expression variables.

The prefix for OGNL is "OGNL:", the prefix for Groovy is "GROOVY:" and the prefix for Janino is "JANINO:".

The context for the expressions will be the Config object returned by Config.getRepInstance().

Expression config tags are evaluated automatically when the output is generated (such as when calling getContent()). You can manually call this method to force evaluation of the tags earlier than that.

Parameters:
id - the ID whose expression tag will be replaced with the value of the evaluated expression in the tag ID
Returns:
the list of names of the template values that were generated
Since:
1.0

evaluateRenderTags

List<String> evaluateRenderTags()
                                throws TemplateException
Evalutes all values in this template with ID's of the form "RENDER:class" or "RENDER:class:differentiator", where "class" is the fully-qualified name of a class which extends ValueRenderer, the result of calling ValueRenderer.render on a new instance of the class. The class must contain a zero-argument ("no-arg") constructor.

For example, given a class MyRenderer in the package "org.rifers.something", which extends ValueRenderer, a value "RENDER:org.rifers.something.MyRenderer:test" would create a new instance of MyRenderer (using its no-arg constructor), call render(this, "RENDER:org.rifers.something.MyRenderer:test", "test"), and set the value in this template to whatever value the call returns.

Value renderer tags are evaluated automatically when the output is generated (such as when calling getContent()). You can manually call this method to force evaluation of the tags earlier than that.

Returns:
the list of names of the template values that were generated
Throws:
TemplateException - if a class in a render tag cannot be instantiated
Since:
1.0

hasBlock

boolean hasBlock(String id)
Returns whether this template contains a block with the given ID.

Parameters:
id - the prospective ID of a block
Returns:
whether this template contains a block with the given ID
Since:
1.0
See Also:
appendBlock(java.lang.String, java.lang.String), setBlock(java.lang.String, java.lang.String), getBlock(java.lang.String), getContent()

isValueSet

boolean isValueSet(String id)
Returns whether the specified value has been set. If this method returns false, the value has its original default value.

If no such value exists in this template, this method will not throw an exception, it will return false.

Parameters:
id - the ID of a value in this template
Returns:
whether the specified value has been set
Since:
1.0
See Also:
appendValue(java.lang.String, java.lang.Object), setValue(java.lang.String, java.util.List), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

countValues

int countValues()
Returns the number of values in this template which have been set.

Returns:
the number of values in this template which have been set
Since:
1.0

removeValue

void removeValue(String id)
Reverts the specified value back to its default value.

Parameters:
id - the ID of a value in this template
Since:
1.0
See Also:
appendValue(java.lang.String, java.lang.Object), setValue(java.lang.String, java.util.List), isValueSet(java.lang.String), hasValueId(java.lang.String)

removeValues

void removeValues(List<String> ids)
Reverts the specified values back to their default value.

Parameters:
ids - the IDs of values in this template
Since:
1.6
See Also:
appendValue(java.lang.String, java.lang.Object), setValue(java.lang.String, java.util.List), * @see #removeValue, hasValueId(java.lang.String)

blankValue

void blankValue(String id)
Set the content of the specified value to an empte string.

Parameters:
id - the ID of a value in this template
Since:
1.4
See Also:
appendValue(java.lang.String, java.lang.Object), setValue(java.lang.String, java.util.List), isValueSet(java.lang.String), hasValueId(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List)

clear

void clear()
Resets all values in this template and removes any resource bundles. Configuration and localization tags are re-evaluated.

Since:
1.0

getAvailableValueIds

String[] getAvailableValueIds()
Returns a list of the ID's of all values present in this template, including set and unset values.

Returns:
a list of ID's of all set and unset value
Since:
1.0

getUnsetValueIds

Collection<String> getUnsetValueIds()
Returns a list of the ID's of all values in this template which have not been set.

Returns:
a list of ID's of values in this template which have not been set
Since:
1.0

hasValueId

boolean hasValueId(String id)
Returns whether this template contains a value with the given ID.

Parameters:
id - the potential ID of a value in this template
Returns:
whether this template contains a value with the given ID
Since:
1.0
See Also:
appendValue(java.lang.String, java.lang.Object), setValue(java.lang.String, java.util.List), isValueSet(java.lang.String), removeValue(java.lang.String), removeValues(java.util.List), blankValue(java.lang.String), hasValueId(java.lang.String)

getModificationTime

long getModificationTime()
Returns when the file corresponding to this template was modified, in milliseconds since the Unix epoch.

Returns:
the time at which the underlying template file was modified
Since:
1.0

getBeanHandler

BeanHandler getBeanHandler()
Returns this template's bean handler. The bean handler is used for filling bean values into template values, and for building forms.

Returns:
this template's bean handler
Since:
1.0

getEncoder

TemplateEncoder getEncoder()
Returns the encoder that this template uses to convert strings to values in the template's generated text output. In an HTML template, for example, this encoder may be used to convert text which may contain HTML special characters like <> to corresponding escaped strings.

Returns:
this template's encoder
Since:
1.0

addResourceBundle

void addResourceBundle(ResourceBundle resourceBundle)
Adds a resource bundle to this template. Resource bundles are used in many places, including when generating labels for forms, generating options for <select> tags, and using localized text.

Parameters:
resourceBundle - a resource bundle
Since:
1.0
See Also:
getResourceBundles(), hasResourceBundles()

getResourceBundles

Collection<ResourceBundle> getResourceBundles()
Returns a list of the resource bundles used by this template. This will contain any bundles added through addResourceBundle as well as any default resource bundles.

Returns:
a list of this template's resource bundles
Since:
1.0
See Also:
addResourceBundle(java.util.ResourceBundle), hasResourceBundles()

hasResourceBundles

boolean hasResourceBundles()
Returns whether this template has any resource bundles registered.

Returns:
whether this template contains any resource bundles
Since:
1.0
See Also:
addResourceBundle(java.util.ResourceBundle), getResourceBundles()

setLanguage

void setLanguage(String lang)
Sets this template's current language code, such as "en".

This is used when filling localized text values.

Parameters:
lang - a 2-letter language code for the language to be used by this template
Since:
1.0
See Also:
getLanguage()

getLanguage

String getLanguage()
Returns this template's current 2-letter language code. This code is used when filling localized text values. If the language has not been set, it defaults to the language set by the RIFE configuration parameter "L10N_DEFAULT_LANGUAGE".

Returns:
the 2-letter language code currently used by this template
Since:
1.0
See Also:
setLanguage(java.lang.String)

setExpressionVar

void setExpressionVar(String name,
                      Object value)
Sets a variable which can be accessed by expression tags in OGNL, Groovy, or Janino.

Parameters:
name - the name of the variable
value - the value to associate with the given variable name
Since:
1.0
See Also:
setExpressionVars(java.util.Map), getExpressionVars()

setExpressionVars

void setExpressionVars(Map<String,Object> map)
Sets the given variables to the given corresponding values, for use in expression tags. Calling this method is equivalent to calling setExpressionVar for each entry in the given map.

Parameters:
map - a map from variable name to variable value
Since:
1.0
See Also:
setExpressionVar(java.lang.String, java.lang.Object), getExpressionVars()

getExpressionVars

Map<String,Object> getExpressionVars()
Returns the name and value of all of the expression variables which have been set in this template.

Returns:
the expression variables currently set in this template
Since:
1.0
See Also:
setExpressionVar(java.lang.String, java.lang.Object), setExpressionVars(java.util.Map)

cacheObject

void cacheObject(String key,
                 Object value)
Stores the given value in a cache, associated with the given key. This is mainly used by OGNL, Groovy, and Janino expression evaluation system to store caches to classes. You should probably not use the template caching system to avoid conflicting with the expression evaluation system.

Parameters:
key - a name under which the given value should be stored
value - an object
Since:
1.0

getCacheObject

Object getCacheObject(String key)
Returns the value corresponding to the given key in this template's cache, or null if no such cached object exists. As noted in cacheObject(java.lang.String, java.lang.Object), you should probably not use this method to avoid conflicting with RIFE's internal use of the cache.

Parameters:
key - a key whose associated cached object should be returned
Returns:
the value associated with the given key, or null if none exists
Since:
1.0

getDependencies

Map<URL,Long> getDependencies()
Returns a list of URL's that this template depends on, and their last modification dates (in milliseconds since the Unix epoch). This method should return templates which are included by this template, and any other resources which are required to fully render the template.

Returns:
a list of URL's and last modification dates of resources on which this template depends
Since:
1.0

getName

String getName()
Returns this template's name, without path information or file extension. For example, for /Users/me/Something/templates/xyz.html, this method will return "xyz".

Returns:
this template's name, without path or file extension
Since:
1.0

getFullName

String getFullName()
Returns this template's full name, as it was used to instantiate it by a template factory.

Returns:
this template's full name
Since:
1.6

getDefaultContentType

String getDefaultContentType()
Returns this template's default content type, for example text/html.

Returns:
this template's default content type; or

null if no default content type is known for this template instance

Since:
1.3

clone

Object clone()
Returns a shallow copy of this template, with the same values, expression variables, and so on.

Returns:
a shallow copy of this template
Since:
1.0


Copyright © 2001-2007 Uwyn sprl/bvba. All Rights Reserved.