com.uwyn.rife.template
Class AbstractTemplate

java.lang.Object
  extended by com.uwyn.rife.template.AbstractTemplate
All Implemented Interfaces:
Template, Cloneable

public abstract class AbstractTemplate
extends Object
implements Template


Field Summary
protected  BeanHandler mBeanHandler
           
protected  Map<String,Object> mCache
           
protected  Map<String,InternalValue> mConstructedValues
           
protected  String mDefaultContentType
           
protected  List<ResourceBundle> mDefaultResourceBundles
           
protected  TemplateEncoder mEncoder
           
protected  Map<String,Object> mExpressionVars
           
protected  Map<String,InternalString> mFixedValues
           
protected  TemplateInitializer mInitializer
           
protected  String mLanguage
           
protected  List<ResourceBundle> mResourceBundles
           
 
Constructor Summary
protected AbstractTemplate()
           
 
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.
protected abstract  boolean appendBlockExternalForm(String id, ExternalValue result)
           
protected abstract  boolean appendBlockInternalForm(String id, InternalValue result)
           
protected abstract  boolean appendDefaultValueExternalForm(String id, ExternalValue result)
           
protected abstract  boolean appendDefaultValueInternalForm(String id, InternalValue result)
           
protected  void appendTextInternal(InternalValue value, CharSequence text)
           
 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.
protected  void appendValueExternalForm(String id, String tag, ExternalValue result)
           
protected  void appendValueInternalForm(String id, String tag, InternalValue result)
           
 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.
 Template 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.
abstract  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.
abstract  String getDefaultValue(String id)
          Returns the original text of the specified value, before any modification that may have been made using Template.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.
 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.
abstract  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, ...
abstract  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 getLanguage()
          Returns this template's current 2-letter language code.
abstract  long getModificationTime()
          Returns when the file corresponding to this template was modified, in milliseconds since the Unix epoch.
 Collection<ResourceBundle> getResourceBundles()
          Returns a list of the resource bundles used by this template.
abstract  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.
abstract  boolean hasFilteredBlocks(String filter)
          Returns whether any block matched a particular filter at template compilation.
abstract  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.
abstract  boolean hasValueId(String id)
          Returns whether this template contains a value with the given ID.
protected  void increasePartsCapacityInternal(InternalValue value, int size)
           
protected  void increaseValuesCapacityInternal(InternalValue value, int size)
           
protected static boolean isTemplateClassModified(URL templateResource, long templateModificationTime, Map templateDependencies, String templateModificationState, ResourceFinder resourceFinder, String modificationState)
           
 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 setDefaultContentType(String defaultContentType)
           
 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 Template.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 writeBlock(String id, OutputStream out, String charsetName)
           
 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.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.uwyn.rife.template.Template
getDependencies, getFullName, getName
 

Field Detail

mInitializer

protected TemplateInitializer mInitializer

mFixedValues

protected Map<String,InternalString> mFixedValues

mConstructedValues

protected Map<String,InternalValue> mConstructedValues

mBeanHandler

protected BeanHandler mBeanHandler

mEncoder

protected TemplateEncoder mEncoder

mDefaultResourceBundles

protected List<ResourceBundle> mDefaultResourceBundles

mResourceBundles

protected List<ResourceBundle> mResourceBundles

mExpressionVars

protected Map<String,Object> mExpressionVars

mLanguage

protected String mLanguage

mCache

protected Map<String,Object> mCache

mDefaultContentType

protected String mDefaultContentType
Constructor Detail

AbstractTemplate

protected AbstractTemplate()
Method Detail

appendBlock

public final void appendBlock(String valueId,
                              String blockId)
                       throws TemplateException
Description copied from interface: Template
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.

Specified by:
appendBlock in interface Template
Parameters:
valueId - the ID of the value
blockId - the ID of the block
Throws:
TemplateException - when the valueId or blockId aren't known
See Also:
Template.setBlock(java.lang.String, java.lang.String), Template.getBlock(java.lang.String), Template.getContent(), Template.hasBlock(java.lang.String)

setBlock

public final void setBlock(String valueId,
                           String blockId)
                    throws TemplateException
Description copied from interface: Template
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.

Specified by:
setBlock in interface Template
Parameters:
valueId - the ID of the value
blockId - the ID of the block
Throws:
TemplateException - when the valueId or blockId aren't known
See Also:
Template.appendBlock(java.lang.String, java.lang.String), Template.getBlock(java.lang.String), Template.getContent(), Template.hasBlock(java.lang.String)

getBlock

public String getBlock(String id)
                throws TemplateException
Description copied from interface: Template
Returns the evaluated content of the specified block as a text.

Specified by:
getBlock in interface Template
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
See Also:
Template.appendBlock(java.lang.String, java.lang.String), Template.setBlock(java.lang.String, java.lang.String), Template.getContent(), Template.hasBlock(java.lang.String)

getContent

public final String getContent()
                        throws TemplateException
Description copied from interface: Template
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, ...).

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

writeBlock

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

Specified by:
writeBlock in interface Template
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
See Also:
Template.writeContent(OutputStream), Template.writeContent(OutputStream, String), Template.write(java.io.OutputStream)

writeBlock

public void writeBlock(String id,
                       OutputStream out,
                       String charsetName)
                throws IOException,
                       TemplateException
Throws:
IOException
TemplateException

writeContent

public final void writeContent(OutputStream out)
                        throws IOException,
                               TemplateException
Description copied from interface: Template
Writes the complete evaluated template content to the given stream, using UTF-8 encoding.

Specified by:
writeContent in interface Template
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
See Also:
Template.writeBlock(java.lang.String, java.io.OutputStream), Template.writeContent(OutputStream, String), Template.write(java.io.OutputStream)

writeContent

public final void writeContent(OutputStream out,
                               String charsetName)
                        throws IOException,
                               TemplateException
Description copied from interface: Template
Writes the complete evaluated template content to the given stream, using the specified charset for encoding.

Specified by:
writeContent in interface Template
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
See Also:
Template.writeBlock(java.lang.String, java.io.OutputStream), Template.writeContent(OutputStream), Template.write(java.io.OutputStream)

write

public final void write(OutputStream out)
                 throws IOException,
                        TemplateException
Description copied from interface: Template
This method is a shorthand for Template.writeContent(OutputStream).

Specified by:
write in interface Template
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
See Also:
Template.writeBlock(java.lang.String, java.io.OutputStream), Template.writeContent(OutputStream), Template.writeContent(OutputStream, String)

getDeferredBlock

public final List<CharSequence> getDeferredBlock(String id)
                                          throws TemplateException
Description copied from interface: Template
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.

Specified by:
getDeferredBlock in interface Template
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

See Also:
Template.getDeferredContent()

getDeferredContent

public final List<CharSequence> getDeferredContent()
                                            throws TemplateException
Description copied from interface: Template
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.

Specified by:
getDeferredContent in interface Template
Returns:
a list of the contents of this template
Throws:
TemplateException - if an error occurred during the retrieval
See Also:
Template.getDeferredBlock(java.lang.String)

evaluateRenderTags

public List<String> evaluateRenderTags()
                                throws TemplateException
Description copied from interface: Template
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 Template.getContent()). You can manually call this method to force evaluation of the tags earlier than that.

Specified by:
evaluateRenderTags in interface Template
Returns:
the list of names of the template values that were generated
Throws:
TemplateException - if a class in a render tag cannot be instantiated

evaluateConfigTags

public List<String> evaluateConfigTags()
Description copied from interface: Template
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.

Specified by:
evaluateConfigTags in interface Template
Returns:
the list of names of the template values that were generated

evaluateL10nTags

public List<String> evaluateL10nTags()
Description copied from interface: Template
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.

Specified by:
evaluateL10nTags in interface Template
Returns:
the list of names of the template values that were generated

evaluateLangTags

public List<String> evaluateLangTags(String id)
Description copied from interface: Template
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 Template.getContent()). You can manually call this method to force evaluation of the tags earlier than that.

Specified by:
evaluateLangTags in interface Template
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

evaluateExpressionTags

public List<String> evaluateExpressionTags(String id)
Description copied from interface: Template
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 Template.getContent()). You can manually call this method to force evaluation of the tags earlier than that.

Specified by:
evaluateExpressionTags in interface Template
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

evaluateExpressionConfigTags

public List<String> evaluateExpressionConfigTags(String id)
Description copied from interface: Template
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 Template.getContent()). You can manually call this method to force evaluation of the tags earlier than that.

Specified by:
evaluateExpressionConfigTags in interface Template
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

createInternalValue

public final InternalValue createInternalValue()
Description copied from interface: Template
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.

Specified by:
createInternalValue in interface Template
Returns:
a new internal value instance for constructing more complex parts of this template
See Also:
InternalValue

setValue

public final void setValue(String id,
                           List<CharSequence> deferredContent)
                    throws TemplateException
Description copied from interface: Template
Sets the specified value in this template to content that's structured in the internal format.

Specified by:
setValue in interface Template
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
See Also:
Template.appendValue(java.lang.String, java.lang.Object), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

setValue

public final void setValue(String id,
                           InternalValue internalValue)
                    throws TemplateException
Description copied from interface: Template
Sets the specified value in this template to the value of the given internal value.

Specified by:
setValue in interface Template
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
See Also:
Template.appendValue(java.lang.String, java.lang.Object), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

setValue

public final void setValue(String id,
                           Template template)
                    throws TemplateException
Description copied from interface: Template
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.

Specified by:
setValue in interface Template
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

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

setValue

public final void setValue(String id,
                           Object value)
                    throws TemplateException
Description copied from interface: Template
Sets the specified value in this template to the result of calling String.valueOf on the given value.

Specified by:
setValue in interface 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
See Also:
Template.appendValue(java.lang.String, java.lang.Object), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

setValue

public final void setValue(String id,
                           boolean value)
                    throws TemplateException
Description copied from interface: Template
Sets the specified value in this template to true or false depending on the given value.

Specified by:
setValue in interface Template
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
See Also:
Template.appendValue(java.lang.String, java.lang.Object), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

setValue

public final void setValue(String id,
                           char value)
                    throws TemplateException
Description copied from interface: Template
Sets the specified value in this template to the single specified character.

Specified by:
setValue in interface 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
See Also:
Template.appendValue(java.lang.String, java.lang.Object), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

setValue

public final void setValue(String id,
                           char[] value)
                    throws TemplateException
Description copied from interface: Template
Sets the specified value in this template to the given characters. The given value must not be null.

Specified by:
setValue in interface Template
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
See Also:
Template.appendValue(java.lang.String, java.lang.Object), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

setValue

public final void setValue(String id,
                           char[] value,
                           int offset,
                           int count)
                    throws TemplateException
Description copied from interface: Template
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.

Specified by:
setValue in interface Template
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
See Also:
Template.appendValue(java.lang.String, java.lang.Object), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

setValue

public final void setValue(String id,
                           double value)
                    throws TemplateException
Description copied from interface: Template
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.

Specified by:
setValue in interface Template
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
See Also:
Template.appendValue(java.lang.String, java.lang.Object), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

setValue

public final void setValue(String id,
                           float value)
                    throws TemplateException
Description copied from interface: Template
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.

Specified by:
setValue in interface Template
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
See Also:
Template.appendValue(java.lang.String, java.lang.Object), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

setValue

public final void setValue(String id,
                           int value)
                    throws TemplateException
Description copied from interface: Template
Sets the specified value in this template to the given integer.

Specified by:
setValue in interface Template
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
See Also:
Template.appendValue(java.lang.String, java.lang.Object), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

setValue

public final void setValue(String id,
                           long value)
                    throws TemplateException
Description copied from interface: Template
Sets the specified value in this template to the given long.

Specified by:
setValue in interface 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
See Also:
Template.appendValue(java.lang.String, java.lang.Object), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

setValue

public final void setValue(String id,
                           String value)
                    throws TemplateException
Description copied from interface: Template
Sets the specified value in this template to the given string, or an empty string if value is null.

Specified by:
setValue in interface 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
See Also:
Template.appendValue(java.lang.String, java.lang.Object), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

setValue

public final void setValue(String id,
                           CharSequence value)
                    throws TemplateException
Description copied from interface: Template
Sets the specified value in this template to the given character sequence, or an empty character sequence if value is null.

Specified by:
setValue in interface Template
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
See Also:
Template.appendValue(java.lang.String, java.lang.Object), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

setBean

public void setBean(Object bean)
             throws TemplateException
Description copied from interface: Template
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.

Specified by:
setBean in interface Template
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

See Also:
Template.removeBean(java.lang.Object)

setBean

public void setBean(Object bean,
                    String prefix)
             throws TemplateException
Description copied from interface: Template
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.

Specified by:
setBean in interface Template
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

See Also:
Template.removeBean(java.lang.Object)

setBean

public void setBean(Object bean,
                    String prefix,
                    boolean encode)
             throws TemplateException
Description copied from interface: Template
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.

Specified by:
setBean in interface Template
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

See Also:
Template.removeBean(java.lang.Object)

removeBean

public void removeBean(Object bean)
                throws TemplateException
Description copied from interface: Template
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.

Specified by:
removeBean in interface Template
Parameters:
bean - a bean
Throws:
TemplateException - if this template has no bean handling capability; or

an error occurred during the introspection of the bean

See Also:
Template.setBean(java.lang.Object)

removeBean

public void removeBean(Object bean,
                       String prefix)
                throws TemplateException
Description copied from interface: Template
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.

Specified by:
removeBean in interface Template
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

See Also:
Template.setBean(java.lang.Object)

appendValue

public final void appendValue(String id,
                              Object value)
                       throws TemplateException
Description copied from interface: Template
Appends the result of calling String.valueOf on the given value to the specified value in this template.

Specified by:
appendValue in interface 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
See Also:
Template.setValue(java.lang.String, java.util.List), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

appendValue

public final void appendValue(String id,
                              boolean value)
                       throws TemplateException
Description copied from interface: Template
Appends "true" or "false" to the specified value in this template, depending on the given value.

Specified by:
appendValue in interface Template
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
See Also:
Template.setValue(java.lang.String, java.util.List), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

appendValue

public final void appendValue(String id,
                              char value)
                       throws TemplateException
Description copied from interface: Template
Appends the single specified character to the specified value in this template.

Specified by:
appendValue in interface 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
See Also:
Template.setValue(java.lang.String, java.util.List), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

appendValue

public final void appendValue(String id,
                              char[] value)
                       throws TemplateException
Description copied from interface: Template
Appends the given characters to the specified value in this template. The given value must not be null.

Specified by:
appendValue in interface Template
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
See Also:
Template.setValue(java.lang.String, java.util.List), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

appendValue

public final void appendValue(String id,
                              char[] value,
                              int offset,
                              int count)
                       throws TemplateException
Description copied from interface: Template
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.

Specified by:
appendValue in interface Template
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
See Also:
Template.setValue(java.lang.String, java.util.List), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

appendValue

public final void appendValue(String id,
                              double value)
                       throws TemplateException
Description copied from interface: Template
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.

Specified by:
appendValue in interface Template
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
See Also:
Template.setValue(java.lang.String, java.util.List), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

appendValue

public final void appendValue(String id,
                              float value)
                       throws TemplateException
Description copied from interface: Template
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.

Specified by:
appendValue in interface Template
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
See Also:
Template.setValue(java.lang.String, java.util.List), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

appendValue

public final void appendValue(String id,
                              int value)
                       throws TemplateException
Description copied from interface: Template
Appends the given integer to the specified value in this template.

Specified by:
appendValue in interface 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
See Also:
Template.setValue(java.lang.String, java.util.List), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

appendValue

public final void appendValue(String id,
                              long value)
                       throws TemplateException
Description copied from interface: Template
Appends the given long to the specified value in this template.

Specified by:
appendValue in interface 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
See Also:
Template.setValue(java.lang.String, java.util.List), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

appendValue

public final void appendValue(String id,
                              String value)
                       throws TemplateException
Description copied from interface: Template
Appends the given string, or an empty string if value is null, to the specified value in this template.

Specified by:
appendValue in interface 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
See Also:
Template.setValue(java.lang.String, java.util.List), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

getValue

public final String getValue(String id)
                      throws TemplateException
Description copied from interface: Template
Returns the current content of the specified value as a string.

Specified by:
getValue in interface Template
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
See Also:
Template.setValue(java.lang.String, java.util.List), Template.isValueSet(java.lang.String), Template.removeValue(java.lang.String), Template.removeValues(java.util.List), Template.blankValue(java.lang.String), Template.hasValueId(java.lang.String)

getDefaultValue

public abstract String getDefaultValue(String id)
Description copied from interface: Template
Returns the original text of the specified value, before any modification that may have been made using Template.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.

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

hasDefaultValue

public boolean hasDefaultValue(String id)
Description copied from interface: Template
Returns whether a default value was specified in this template for the specified value.

Specified by:
hasDefaultValue in interface Template
Parameters:
id - the ID of a value in this template
Returns:
whether the specified value has a default value
See Also:
Template.getDefaultValue(java.lang.String)

getFilteredBlocks

public abstract List<String[]> getFilteredBlocks(String filter)
Description copied from interface: Template
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.

Specified by:
getFilteredBlocks in interface Template
Parameters:
filter - a template factory regular expression
Returns:
a list of captured groups for matching block ID's
See Also:
Template.hasFilteredBlocks(java.lang.String)

hasFilteredBlocks

public abstract boolean hasFilteredBlocks(String filter)
Description copied from interface: Template
Returns whether any block matched a particular filter at template compilation.

Specified by:
hasFilteredBlocks in interface Template
Parameters:
filter - a template factory regular expression
Returns:
whether any matching blocks exist in this template
See Also:
Template.getFilteredBlocks(java.lang.String)

getFilteredValues

public abstract List<String[]> getFilteredValues(String filter)
Description copied from interface: Template
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.

Specified by:
getFilteredValues in interface Template
Parameters:
filter - a template factory regular expression
Returns:
a list of captured groups for matching value ID's
See Also:
Template.hasFilteredValues(java.lang.String)

hasFilteredValues

public abstract boolean hasFilteredValues(String filter)
Description copied from interface: Template
Returns whether any value matched a particular filter at template compilation.

Specified by:
hasFilteredValues in interface Template
Parameters:
filter - a template factory regular expression
Returns:
whether any matching values exist in this template
See Also:
Template.getFilteredValues(java.lang.String)

hasBlock

public final boolean hasBlock(String id)
Description copied from interface: Template
Returns whether this template contains a block with the given ID.

Specified by:
hasBlock in interface Template
Parameters:
id - the prospective ID of a block
Returns:
whether this template contains a block with the given ID
See Also:
Template.appendBlock(java.lang.String, java.lang.String), Template.setBlock(java.lang.String, java.lang.String), Template.getBlock(java.lang.String), Template.getContent()

isValueSet

public final boolean isValueSet(String id)
Description copied from interface: Template
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.

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

countValues

public final int countValues()
Description copied from interface: Template
Returns the number of values in this template which have been set.

Specified by:
countValues in interface Template
Returns:
the number of values in this template which have been set

removeValue

public final void removeValue(String id)
Description copied from interface: Template
Reverts the specified value back to its default value.

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

removeValues

public final void removeValues(List<String> ids)
Description copied from interface: Template
Reverts the specified values back to their default value.

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

blankValue

public final void blankValue(String id)
Description copied from interface: Template
Set the content of the specified value to an empte string.

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

clear

public final void clear()
Description copied from interface: Template
Resets all values in this template and removes any resource bundles. Configuration and localization tags are re-evaluated.

Specified by:
clear in interface Template

getAvailableValueIds

public abstract String[] getAvailableValueIds()
Description copied from interface: Template
Returns a list of the ID's of all values present in this template, including set and unset values.

Specified by:
getAvailableValueIds in interface Template
Returns:
a list of ID's of all set and unset value

getUnsetValueIds

public abstract Collection<String> getUnsetValueIds()
Description copied from interface: Template
Returns a list of the ID's of all values in this template which have not been set.

Specified by:
getUnsetValueIds in interface Template
Returns:
a list of ID's of values in this template which have not been set

hasValueId

public abstract boolean hasValueId(String id)
Description copied from interface: Template
Returns whether this template contains a value with the given ID.

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

getModificationTime

public abstract long getModificationTime()
Description copied from interface: Template
Returns when the file corresponding to this template was modified, in milliseconds since the Unix epoch.

Specified by:
getModificationTime in interface Template
Returns:
the time at which the underlying template file was modified

appendTextInternal

protected void appendTextInternal(InternalValue value,
                                  CharSequence text)

increasePartsCapacityInternal

protected void increasePartsCapacityInternal(InternalValue value,
                                             int size)

increaseValuesCapacityInternal

protected void increaseValuesCapacityInternal(InternalValue value,
                                              int size)

appendBlockExternalForm

protected abstract boolean appendBlockExternalForm(String id,
                                                   ExternalValue result)

appendBlockInternalForm

protected abstract boolean appendBlockInternalForm(String id,
                                                   InternalValue result)

appendValueExternalForm

protected final void appendValueExternalForm(String id,
                                             String tag,
                                             ExternalValue result)

appendDefaultValueExternalForm

protected abstract boolean appendDefaultValueExternalForm(String id,
                                                          ExternalValue result)

appendValueInternalForm

protected final void appendValueInternalForm(String id,
                                             String tag,
                                             InternalValue result)

appendDefaultValueInternalForm

protected abstract boolean appendDefaultValueInternalForm(String id,
                                                          InternalValue result)

getBeanHandler

public final BeanHandler getBeanHandler()
Description copied from interface: Template
Returns this template's bean handler. The bean handler is used for filling bean values into template values, and for building forms.

Specified by:
getBeanHandler in interface Template
Returns:
this template's bean handler

getEncoder

public final TemplateEncoder getEncoder()
Description copied from interface: Template
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.

Specified by:
getEncoder in interface Template
Returns:
this template's encoder

addResourceBundle

public final void addResourceBundle(ResourceBundle resourceBundle)
Description copied from interface: Template
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.

Specified by:
addResourceBundle in interface Template
Parameters:
resourceBundle - a resource bundle
See Also:
Template.getResourceBundles(), Template.hasResourceBundles()

getResourceBundles

public final Collection<ResourceBundle> getResourceBundles()
Description copied from interface: Template
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.

Specified by:
getResourceBundles in interface Template
Returns:
a list of this template's resource bundles
See Also:
Template.addResourceBundle(java.util.ResourceBundle), Template.hasResourceBundles()

hasResourceBundles

public final boolean hasResourceBundles()
Description copied from interface: Template
Returns whether this template has any resource bundles registered.

Specified by:
hasResourceBundles in interface Template
Returns:
whether this template contains any resource bundles
See Also:
Template.addResourceBundle(java.util.ResourceBundle), Template.getResourceBundles()

setLanguage

public void setLanguage(String lang)
Description copied from interface: Template
Sets this template's current language code, such as "en".

This is used when filling localized text values.

Specified by:
setLanguage in interface Template
Parameters:
lang - a 2-letter language code for the language to be used by this template
See Also:
Template.getLanguage()

getLanguage

public String getLanguage()
Description copied from interface: Template
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".

Specified by:
getLanguage in interface Template
Returns:
the 2-letter language code currently used by this template
See Also:
Template.setLanguage(java.lang.String)

setExpressionVar

public void setExpressionVar(String name,
                             Object value)
Description copied from interface: Template
Sets a variable which can be accessed by expression tags in OGNL, Groovy, or Janino.

Specified by:
setExpressionVar in interface Template
Parameters:
name - the name of the variable
value - the value to associate with the given variable name
See Also:
Template.setExpressionVars(java.util.Map), Template.getExpressionVars()

setExpressionVars

public void setExpressionVars(Map<String,Object> map)
Description copied from interface: Template
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.

Specified by:
setExpressionVars in interface Template
Parameters:
map - a map from variable name to variable value
See Also:
Template.setExpressionVar(java.lang.String, java.lang.Object), Template.getExpressionVars()

getExpressionVars

public Map<String,Object> getExpressionVars()
Description copied from interface: Template
Returns the name and value of all of the expression variables which have been set in this template.

Specified by:
getExpressionVars in interface Template
Returns:
the expression variables currently set in this template
See Also:
Template.setExpressionVar(java.lang.String, java.lang.Object), Template.setExpressionVars(java.util.Map)

cacheObject

public void cacheObject(String key,
                        Object value)
Description copied from interface: Template
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.

Specified by:
cacheObject in interface Template
Parameters:
key - a name under which the given value should be stored
value - an object

getCacheObject

public Object getCacheObject(String key)
Description copied from interface: Template
Returns the value corresponding to the given key in this template's cache, or null if no such cached object exists. As noted in Template.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.

Specified by:
getCacheObject in interface Template
Parameters:
key - a key whose associated cached object should be returned
Returns:
the value associated with the given key, or null if none exists

getDefaultContentType

public String getDefaultContentType()
Description copied from interface: Template
Returns this template's default content type, for example text/html.

Specified by:
getDefaultContentType in interface Template
Returns:
this template's default content type; or

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


setDefaultContentType

public void setDefaultContentType(String defaultContentType)

isTemplateClassModified

protected static boolean isTemplateClassModified(URL templateResource,
                                                 long templateModificationTime,
                                                 Map templateDependencies,
                                                 String templateModificationState,
                                                 ResourceFinder resourceFinder,
                                                 String modificationState)

clone

public Template clone()
Description copied from interface: Template
Returns a shallow copy of this template, with the same values, expression variables, and so on.

Specified by:
clone in interface Template
Overrides:
clone in class Object
Returns:
a shallow copy of this template


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