Java Doc for Template.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » template » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » rife 1.6.1 » com.uwyn.rife.template 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


com.uwyn.rife.template.Template

All known Subclasses:   com.uwyn.rife.template.AbstractTemplate,
Template
public interface Template extends Cloneable(Code)
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 com.uwyn.rife.engine.Element.getXhtmlTemplate(String) is used. By obtaining a template instance from the active com.uwyn.rife.engine.Element , features that are related to the web engine are added. To print a template for page output, com.uwyn.rife.engine.Element.print(Template) is usually used. However, the content of any template instance can be retrieved with the Template.getContent method which produces a regular String that is usable anywhere.

Components of a template

Templates are controlled by external code (usually a ), 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 Template.setValue(String,String) setValue and Template.appendValue(String,String)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 by the controller:

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

Values are automatically filled in many ways aside from calling Template.setValue and Template.appendValue 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 , or 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 Template.appendBlock 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 Template.setExpressionVar 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 Template.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 com.uwyn.rife.config RIFEconfiguration , 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 Template.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 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, , localization tags, and when . 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 Template.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.
author:
   Keith Lea <keith[remove] at cs dot oswego dot edu>
author:
   Geert Bevin (gbevin[remove] at uwyn dot com)
version:
   $Revision: 3643 $
since:
   1.0





Method Summary
public  voidaddResourceBundle(ResourceBundle resourceBundle)
     Adds a resource bundle to this template.
public  voidappendBlock(String valueId, String blockId)
     Appends the content of a block to a value.
public  voidappendValue(String id, Object value)
     Appends the result of calling String.valueOf(Object)String.valueOf on the given value to the specified value in this template.
public  voidappendValue(String id, boolean value)
     Appends "true" or "false" to the specified value in this template, depending on the given value.
public  voidappendValue(String id, char value)
     Appends the single specified character to the specified value in this template.
public  voidappendValue(String id, char[] value)
     Appends the given characters to the specified value in this template.
public  voidappendValue(String id, char[] value, int offset, int count)
     Appends the specified range of the given character string to the specified value in this template.
public  voidappendValue(String id, double value)
     Appends the given double precision floating point value to the specified value in this template.
public  voidappendValue(String id, float value)
     Appends the given floating point value to the specified value in this template.
public  voidappendValue(String id, int value)
     Appends the given integer to the specified value in this template.
public  voidappendValue(String id, long value)
     Appends the given long to the specified value in this template.
public  voidappendValue(String id, String value)
     Appends the given string, or an empty string if value is null, to the specified value in this template.
public  voidblankValue(String id)
     Set the content of the specified value to an empte string.
public  voidcacheObject(String key, Object value)
     Stores the given value in a cache, associated with the given key.
public  voidclear()
     Resets all values in this template and removes any resource bundles.
public  Objectclone()
     Returns a shallow copy of this template, with the same values, expression variables, and so on.
public  intcountValues()
     Returns the number of values in this template which .
public  InternalValuecreateInternalValue()
     Returns an anonymous value that can be used to construct complex content for use within this template.
public  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 .
public  List<String>evaluateExpressionConfigTags(String id)
     Evaluates the specified OGNL, Groovy, or Janino configuration expression tag.
public  List<String>evaluateExpressionTags(String id)
     Evaluates the specified OGNL, Groovy, or Janino expression tag.
public  List<String>evaluateL10nTags()
     Fills all values in this template which match "L10N:key", where "key" is a in a registered for this template.
public  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 .

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

public  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(TemplateStringString) ValueRenderer.render on a new instance of the class.
public  String[]getAvailableValueIds()
     Returns a list of the ID's of all values present in this template, including set and unset values.
public  BeanHandlergetBeanHandler()
     Returns this template's .
public  StringgetBlock(String id)
     Returns the evaluated content of the specified block as a text.
public  ObjectgetCacheObject(String key)
     Returns the value corresponding to the given key in this template's cache, or null if no such cached object exists.
public  StringgetContent()
     Returns the entire content of the template and finalize all non evaluated values.
public  StringgetDefaultContentType()
     Returns this template's default content type, for example text/html.
public  StringgetDefaultValue(String id)
     Returns the original text of the specified value, before any modification that may have been made using Template.setValue or similar methods.
public  List<CharSequence>getDeferredBlock(String id)
     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.

public  List<CharSequence>getDeferredContent()
     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.

public  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).
public  TemplateEncodergetEncoder()
     Returns the encoder that this template uses to convert strings to values in the template's generated text output.
public  Map<String, Object>getExpressionVars()
     Returns the name and value of all of the expression variables which have been in this template.
public  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, ...
public  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, ...
public  StringgetFullName()
     Returns this template's full name, as it was used to instantiate it by a template factory.
public  StringgetLanguage()
     Returns this template's current 2-letter language code.
public  longgetModificationTime()
     Returns when the file corresponding to this template was modified, in milliseconds since the Unix epoch.
public  StringgetName()
     Returns this template's name, without path information or file extension.
public  Collection<ResourceBundle>getResourceBundles()
     Returns a list of the resource bundles used by this template.
public  Collection<String>getUnsetValueIds()
     Returns a list of the ID's of all values in this template which .
public  StringgetValue(String id)
     Returns the current content of the specified value as a string.
public  booleanhasBlock(String id)
     Returns whether this template contains a block with the given ID.
public  booleanhasDefaultValue(String id)
     Returns whether a was specified in this template for the specified value.
public  booleanhasFilteredBlocks(String filter)
     Returns whether any block matched a particular filter at template compilation.
public  booleanhasFilteredValues(String filter)
     Returns whether any value matched a particular filter at template compilation.
public  booleanhasResourceBundles()
     Returns whether this template has any resource bundles .
public  booleanhasValueId(String id)
     Returns whether this template contains a value with the given ID.
public  booleanisValueSet(String id)
     Returns whether the specified value has been set.
public  voidremoveBean(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 Template.setBean(Object) setBean .
public  voidremoveBean(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 Template.setBean(Object) setBean .
public  voidremoveValue(String id)
     Reverts the specified value back to its default value.
public  voidremoveValues(List<String> ids)
     Reverts the specified values back to their default value.
public  voidsetBean(Object bean)
     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 Template.setValue(String,String) setValue individually for each property of the bean.

This method uses this template's to encode the bean properties before setting the values.

public  voidsetBean(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.

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 Template.setValue(String,String) setValue individually for each property of the bean prefixed with the given prefix.

This method uses this template's to encode the bean properties before setting the values.

public  voidsetBean(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.
public  voidsetBlock(String valueId, String blockId)
     Replaces the specified value with the content of the specified block.
public  voidsetExpressionVar(String name, Object value)
     Sets a variable which can be accessed by in OGNL, Groovy, or Janino.
public  voidsetExpressionVars(Map<String, Object> map)
     Sets the given variables to the given corresponding values, for use in .
public  voidsetLanguage(String lang)
     Sets this template's current language code, such as "en".
public  voidsetValue(String id, List<CharSequence> deferredContent)
     Sets the specified value in this template to content that's structured in the internal format.
public  voidsetValue(String id, InternalValue internalValue)
     Sets the specified value in this template to the value of the given .
public  voidsetValue(String id, Object value)
     Sets the specified value in this template to the result of calling String.valueOf(Object) String.valueOf on the given value.
public  voidsetValue(String id, boolean value)
     Sets the specified value in this template to true or false depending on the given value.
public  voidsetValue(String id, char value)
     Sets the specified value in this template to the single specified character.
public  voidsetValue(String id, char[] value)
     Sets the specified value in this template to the given characters.
public  voidsetValue(String id, char[] value, int offset, int count)
     Sets the specified value in this template to the specified range of the given character string.
public  voidsetValue(String id, double value)
     Sets the specified value in this template to the given double precision floating point value.
public  voidsetValue(String id, float value)
     Sets the specified value in this template to the given floating point value.
public  voidsetValue(String id, int value)
     Sets the specified value in this template to the given integer.
public  voidsetValue(String id, long value)
     Sets the specified value in this template to the given long.
public  voidsetValue(String id, String value)
     Sets the specified value in this template to the given string, or an empty string if value is null.
public  voidsetValue(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.
public  voidsetValue(String id, Template template)
     Sets the specified value in this template to the current of the given template.
public  voidwrite(OutputStream out)
     This method is a shorthand for Template.writeContent(OutputStream) .
public  voidwriteBlock(String id, OutputStream out)
     Writes the of the specified block to the given output stream, using UTF-8 encoding.
public  voidwriteContent(OutputStream out)
     Writes the to the given stream, using UTF-8 encoding.
public  voidwriteContent(OutputStream out, String charsetName)
     Writes the to the given stream, using the specified charset for encoding.



Method Detail
addResourceBundle
public void addResourceBundle(ResourceBundle resourceBundle)(Code)
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 .
Parameters:
  resourceBundle - a resource bundle
See Also:   Template.getResourceBundles
See Also:   Template.hasResourceBundles
since:
   1.0



appendBlock
public void appendBlock(String valueId, String blockId) throws TemplateException(Code)
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
Parameters:
  blockId - the ID of the block
exception:
  TemplateException - when the valueId orblockId aren't known
See Also:   Template.setBlock
See Also:   Template.getBlock
See Also:   Template.getContent
See Also:   Template.hasBlock
since:
   1.0



appendValue
public void appendValue(String id, Object value) throws TemplateException(Code)
Appends the result of calling String.valueOf(Object)String.valueOf on the given value to the specified value in this template.
Parameters:
  id - the ID of the value in this template
Parameters:
  value - an object
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.setValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



appendValue
public void appendValue(String id, boolean value) throws TemplateException(Code)
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
Parameters:
  value - a boolean value
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.setValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



appendValue
public void appendValue(String id, char value) throws TemplateException(Code)
Appends the single specified character to the specified value in this template.
Parameters:
  id - the ID of the value in this template
Parameters:
  value - a character
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.setValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



appendValue
public void appendValue(String id, char[] value) throws TemplateException(Code)
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
Parameters:
  value - a string of characters
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.setValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



appendValue
public void appendValue(String id, char[] value, int offset, int count) throws TemplateException(Code)
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
Parameters:
  value - a character string
Parameters:
  offset - the index in value of the first character touse
Parameters:
  count - the number of characters to use
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.setValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



appendValue
public void appendValue(String id, double value) throws TemplateException(Code)
Appends the given double precision floating point value to the specified value in this template. This method uses the method to print the given value, which probably prints more digits than you like. You probably want String.format String.format or NumberFormat instead.
Parameters:
  id - the ID of the value in this template
Parameters:
  value - a floating point value
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.setValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



appendValue
public void appendValue(String id, float value) throws TemplateException(Code)
Appends the given floating point value to the specified value in this template. This method uses the method to print the given value, which probably prints more digits than you like. You probably want String.formatString.format or NumberFormat instead.
Parameters:
  id - the ID of the value in this template
Parameters:
  value - a floating point value
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.setValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



appendValue
public void appendValue(String id, int value) throws TemplateException(Code)
Appends the given integer to the specified value in this template.
Parameters:
  id - the ID of the value in this template
Parameters:
  value - an integer
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.setValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



appendValue
public void appendValue(String id, long value) throws TemplateException(Code)
Appends the given long to the specified value in this template.
Parameters:
  id - the ID of the value in this template
Parameters:
  value - a long
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.setValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



appendValue
public void appendValue(String id, String value) throws TemplateException(Code)
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
Parameters:
  value - a string, or null
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.setValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



blankValue
public void blankValue(String id)(Code)
Set the content of the specified value to an empte string.
Parameters:
  id - the ID of a value in this template
See Also:   Template.appendValue
See Also:   Template.setValue
See Also:   Template.isValueSet
See Also:   Template.hasValueId
See Also:   Template.removeValue
See Also:   Template.removeValues
since:
   1.4



cacheObject
public void cacheObject(String key, Object value)(Code)
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
Parameters:
  value - an object
since:
   1.0



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



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



countValues
public int countValues()(Code)
Returns the number of values in this template which . the number of values in this template which have been set
since:
   1.0



createInternalValue
public InternalValue createInternalValue()(Code)
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(String)InternalValue.appendBlock reference blocks within this template. a new internal value instance for constructing more complexparts of this template
See Also:   InternalValue
since:
   1.0




evaluateConfigTags
public List<String> evaluateConfigTags()(Code)
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. the list of names of the template values that were generated
since:
   1.0




evaluateExpressionConfigTags
public List<String> evaluateExpressionConfigTags(String id)(Code)
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 .

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.
Parameters:
  id - the ID whose expression tag will be replaced with the valueof the evaluated expression in the tag ID the list of names of the template values that were generated
since:
   1.0




evaluateExpressionTags
public List<String> evaluateExpressionTags(String id)(Code)
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 .

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.
Parameters:
  id - the ID whose expression tag will be replaced with the valueof the evaluated expression in the tag ID the list of names of the template values that were generated
since:
   1.0




evaluateL10nTags
public List<String> evaluateL10nTags()(Code)
Fills all values in this template which match "L10N:key", where "key" is a in a 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. the list of names of the template values that were generated
since:
   1.0




evaluateLangTags
public List<String> evaluateLangTags(String id)(Code)
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 .

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.
Parameters:
  id - the ID whose language tag should be filled with theappropriate block the list of names of the template values that were generated
since:
   1.0




evaluateRenderTags
public List<String> evaluateRenderTags() throws TemplateException(Code)
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(TemplateStringString) 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.
exception:
  TemplateException - if a class in a render tag cannot beinstantiated the list of names of the template values that were generated
since:
   1.0




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



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



getBlock
public String getBlock(String id) throws TemplateException(Code)
Returns the evaluated content of the specified block as a text.
Parameters:
  id - the ID of the block in the template the evaluated textual content of the specified block
exception:
  TemplateException - when the block ID isn't known
See Also:   Template.appendBlock
See Also:   Template.setBlock
See Also:   Template.getContent
See Also:   Template.hasBlock
since:
   1.0



getCacheObject
public Object getCacheObject(String key)(Code)
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 , 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 the value associated with the given key, or nullif none exists
since:
   1.0



getContent
public String getContent() throws TemplateException(Code)
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, ...). the entire textual content of the template
exception:
  TemplateException - when an error occurred during theprocessing of the specialized tags
See Also:   Template.appendBlock
See Also:   Template.setBlock
See Also:   Template.getBlock
See Also:   Template.hasBlock
since:
   1.0




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

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




getDefaultValue
public String getDefaultValue(String id)(Code)
Returns the original text of the specified value, before any modification that may have been made using Template.setValue 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 the original text value of the specified value
See Also:   Template.hasDefaultValue
since:
   1.0




getDeferredBlock
public List<CharSequence> getDeferredBlock(String id) throws TemplateException(Code)
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 a list of the contents of the specified block
exception:
  TemplateException - if no such block exists; or

if an error occurred during the retrieval
See Also:   Template.getDeferredContent
since:
   1.0




getDeferredContent
public List<CharSequence> getDeferredContent() throws TemplateException(Code)
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. a list of the contents of this template
exception:
  TemplateException - if an error occurred during the retrieval
See Also:   Template.getDeferredBlock
since:
   1.0




getDependencies
public Map<URL, Long> getDependencies()(Code)
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. a list of URL's and last modification dates of resources onwhich this template depends
since:
   1.0



getEncoder
public TemplateEncoder getEncoder()(Code)
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. this template's encoder
since:
   1.0



getExpressionVars
public Map<String, Object> getExpressionVars()(Code)
Returns the name and value of all of the expression variables which have been in this template. the expression variables currently set in this template
See Also:   Template.setExpressionVar
See Also:   Template.setExpressionVars
since:
   1.0



getFilteredBlocks
public List<String[]> getFilteredBlocks(String filter)(Code)
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 a list of captured groups for matching block ID's
See Also:   Template.hasFilteredBlocks
since:
   1.0




getFilteredValues
public List<String[]> getFilteredValues(String filter)(Code)
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 a list of captured groups for matching value ID's
See Also:   Template.hasFilteredValues
since:
   1.0




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



getLanguage
public String getLanguage()(Code)
Returns this template's current 2-letter language code. This code is used when Template.evaluateL10nTags filling localized text values . If the language has not been , it defaults to the language set by the RIFE configuration parameter "L10N_DEFAULT_LANGUAGE". the 2-letter language code currently used by this template
See Also:   Template.setLanguage
since:
   1.0



getModificationTime
public long getModificationTime()(Code)
Returns when the file corresponding to this template was modified, in milliseconds since the Unix epoch. the time at which the underlying template file was modified
since:
   1.0



getName
public String getName()(Code)
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". this template's name, without path or file extension
since:
   1.0



getResourceBundles
public Collection<ResourceBundle> getResourceBundles()(Code)
Returns a list of the resource bundles used by this template. This will contain any bundles added through Template.addResourceBundleaddResourceBundle as well as any default resource bundles. a list of this template's resource bundles
See Also:   Template.addResourceBundle
See Also:   Template.hasResourceBundles
since:
   1.0



getUnsetValueIds
public Collection<String> getUnsetValueIds()(Code)
Returns a list of the ID's of all values in this template which . a list of ID's of values in this template which have not beenset
since:
   1.0



getValue
public String getValue(String id) throws TemplateException(Code)
Returns the current content of the specified value as a string.
Parameters:
  id - the ID of a value in this template the current content value of the specified value
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.setValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



hasBlock
public boolean hasBlock(String id)(Code)
Returns whether this template contains a block with the given ID.
Parameters:
  id - the prospective ID of a block whether this template contains a block with the given ID
See Also:   Template.appendBlock
See Also:   Template.setBlock
See Also:   Template.getBlock
See Also:   Template.getContent
since:
   1.0



hasDefaultValue
public boolean hasDefaultValue(String id)(Code)
Returns whether a was specified in this template for the specified value.
Parameters:
  id - the ID of a value in this template whether the specified value has a default value
See Also:   Template.getDefaultValue
since:
   1.0



hasFilteredBlocks
public boolean hasFilteredBlocks(String filter)(Code)
Returns whether any block matched a particular filter at template compilation.
Parameters:
  filter - a template factory regular expression whether any matching blocks exist in this template
See Also:   Template.getFilteredBlocks
since:
   1.0



hasFilteredValues
public boolean hasFilteredValues(String filter)(Code)
Returns whether any value matched a particular filter at template compilation.
Parameters:
  filter - a template factory regular expression whether any matching values exist in this template
See Also:   Template.getFilteredValues
since:
   1.0



hasResourceBundles
public boolean hasResourceBundles()(Code)
Returns whether this template has any resource bundles . whether this template contains any resource bundles
See Also:   Template.addResourceBundle
See Also:   Template.getResourceBundles
since:
   1.0



hasValueId
public boolean hasValueId(String id)(Code)
Returns whether this template contains a value with the given ID.
Parameters:
  id - the potential ID of a value in this template whether this template contains a value with the given ID
See Also:   Template.appendValue
See Also:   Template.setValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



isValueSet
public boolean isValueSet(String id)(Code)
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 whether the specified value has been set
See Also:   Template.appendValue
See Also:   Template.setValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0




removeBean
public void removeBean(Object bean) throws TemplateException(Code)
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 Template.setBean(Object) setBean . The values of the bean's properties are ignored.

Calling this method is equivalent to calling Template.removeValueremoveValue once for the name of each property of the given bean.
Parameters:
  bean - a bean
exception:
  TemplateException - if this template has no bean handlingcapability; or

an error occurred during the introspection of the bean
See Also:   Template.setBean
since:
   1.0




removeBean
public void removeBean(Object bean, String prefix) throws TemplateException(Code)
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 Template.setBean(Object) setBean . The values of the bean's properties are ignored.

Calling this method is equivalent to calling Template.removeValueremoveValue 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 whichvalues to remove from the template
Parameters:
  prefix - a prefix
exception:
  TemplateException - if this template has no bean handlingcapability; or

an error occurred during the introspection of the bean
See Also:   Template.setBean
since:
   1.0




removeValue
public void removeValue(String id)(Code)
Reverts the specified value back to its default value.
Parameters:
  id - the ID of a value in this template
See Also:   Template.appendValue
See Also:   Template.setValue
See Also:   Template.isValueSet
See Also:   Template.hasValueId
since:
   1.0



removeValues
public void removeValues(List<String> ids)(Code)
Reverts the specified values back to their default value.
Parameters:
  ids - the IDs of values in this template
See Also:   Template.appendValue
See Also:   Template.setValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.hasValueId
since:
   1.6



setBean
public void setBean(Object bean) throws TemplateException(Code)
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 Template.setValue(String,String) setValue individually for each property of the bean.

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

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 inthe template
exception:
  TemplateException - if this template has no bean handlingcapability; or

an error occurred during the introspection of the bean
See Also:   Template.removeBean
since:
   1.0




setBean
public void setBean(Object bean, String prefix) throws TemplateException(Code)
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 Template.setValue(String,String) setValue individually for each property of the bean prefixed with the given prefix.

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

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 inthe template
Parameters:
  prefix - the prefix of values which will be filled with the givenbean's property values
exception:
  TemplateException - if this template has no bean handlingcapability; or

an error occurred during the introspection of the bean
See Also:   Template.removeBean
since:
   1.0




setBean
public void setBean(Object bean, String prefix, boolean encode) throws TemplateException(Code)
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 Template.setValue(String,String) setValue individually for each property of the bean prefixed with the given prefix.

If encode is true, this method will use this template's 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 inthe template
Parameters:
  prefix - the prefix of values which will be filled with the givenbean's property values
Parameters:
  encode - true if the bean poroperty values have to beencoded; or

false otherwise
exception:
  TemplateException - if this template has no bean handlingcapability; or

an error occurred during the introspection of the bean
See Also:   Template.removeBean
since:
   1.0




setBlock
public void setBlock(String valueId, String blockId) throws TemplateException(Code)
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
Parameters:
  blockId - the ID of the block
exception:
  TemplateException - when the valueId orblockId aren't known
See Also:   Template.appendBlock
See Also:   Template.getBlock
See Also:   Template.getContent
See Also:   Template.hasBlock
since:
   1.0



setExpressionVar
public void setExpressionVar(String name, Object value)(Code)
Sets a variable which can be accessed by in OGNL, Groovy, or Janino.
Parameters:
  name - the name of the variable
Parameters:
  value - the value to associate with the given variable name
See Also:   Template.setExpressionVars
See Also:   Template.getExpressionVars
since:
   1.0



setExpressionVars
public void setExpressionVars(Map<String, Object> map)(Code)
Sets the given variables to the given corresponding values, for use in . Calling this method is equivalent to calling Template.setExpressionVarsetExpressionVar for each entry in the given map.
Parameters:
  map - a map from variable name to variable value
See Also:   Template.setExpressionVar
See Also:   Template.getExpressionVars
since:
   1.0



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

This is used when Template.evaluateL10nTags filling localized textvalues .
Parameters:
  lang - a 2-letter language code for the language to be used bythis template
See Also:   Template.getLanguage
since:
   1.0




setValue
public void setValue(String id, List<CharSequence> deferredContent) throws TemplateException(Code)
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
Parameters:
  deferredContent - content in the internal format
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.appendValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



setValue
public void setValue(String id, InternalValue internalValue) throws TemplateException(Code)
Sets the specified value in this template to the value of the given .
Parameters:
  id - the ID of the value in this template
Parameters:
  internalValue - an internal value, null set the valuecontent to blank content
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.appendValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



setValue
public void setValue(String id, Object value) throws TemplateException(Code)
Sets the specified value in this template to the result of calling String.valueOf(Object) String.valueOf on the given value.
Parameters:
  id - the ID of the value in this template
Parameters:
  value - an object
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.appendValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



setValue
public void setValue(String id, boolean value) throws TemplateException(Code)
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
Parameters:
  value - a boolean value
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.appendValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



setValue
public void setValue(String id, char value) throws TemplateException(Code)
Sets the specified value in this template to the single specified character.
Parameters:
  id - the ID of the value in this template
Parameters:
  value - a character
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.appendValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



setValue
public void setValue(String id, char[] value) throws TemplateException(Code)
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
Parameters:
  value - a string of characters
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.appendValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



setValue
public void setValue(String id, char[] value, int offset, int count) throws TemplateException(Code)
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
Parameters:
  value - a character string
Parameters:
  offset - the index in value of the first character touse
Parameters:
  count - the number of characters to use
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.appendValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



setValue
public void setValue(String id, double value) throws TemplateException(Code)
Sets the specified value in this template to the given double precision floating point value. This method uses the method to print the given value, which probably prints more digits than you like. You probably want String.format String.format or NumberFormat instead.
Parameters:
  id - the ID of the value in this template
Parameters:
  value - a floating point value
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.appendValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



setValue
public void setValue(String id, float value) throws TemplateException(Code)
Sets the specified value in this template to the given floating point value. This method uses the method to print the given value, which probably prints more digits than you like. You probably want String.formatString.format or NumberFormat instead.
Parameters:
  id - the ID of the value in this template
Parameters:
  value - a floating point value
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.appendValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



setValue
public void setValue(String id, int value) throws TemplateException(Code)
Sets the specified value in this template to the given integer.
Parameters:
  id - the ID of the value in this template
Parameters:
  value - an integer
exception:
  TemplateException - if the specified value does not exist inthis template
See Also:   Template.appendValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



setValue
public void setValue(String id, long value) throws TemplateException(Code)
Sets the specified value in this template to the given long.
Parameters:
  id - the ID of the value in this template
Parameters:
  value - a long
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.appendValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



setValue
public void setValue(String id, String value) throws TemplateException(Code)
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
Parameters:
  value - a string, or null
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.appendValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0



setValue
public void setValue(String id, CharSequence value) throws TemplateException(Code)
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
Parameters:
  value - a character sequence, or null
exception:
  TemplateException - if the specified value ID does not existin this template
See Also:   Template.appendValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.5



setValue
public void setValue(String id, Template template) throws TemplateException(Code)
Sets the specified value in this template to the current 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
Parameters:
  template - a template
exception:
  TemplateException - if the specified value ID does not existin this template; or

if an error occurred during the evaluation of the template parameter
See Also:   Template.appendValue
See Also:   Template.isValueSet
See Also:   Template.removeValue
See Also:   Template.removeValues
See Also:   Template.blankValue
See Also:   Template.hasValueId
since:
   1.0




write
public void write(OutputStream out) throws IOException, TemplateException(Code)
This method is a shorthand for Template.writeContent(OutputStream) .
Parameters:
  out - the stream to which the template contents should be written
exception:
  IOException - when errors occur during the manipulation of theoutput stream; or

when the character set isn't valid
exception:
  TemplateException - when an error occurs during the templatecontent evaluation
See Also:   Template.writeBlock
See Also:   Template.writeContent(OutputStream)
See Also:   Template.writeContent(OutputStream,String)
since:
   1.0




writeBlock
public void writeBlock(String id, OutputStream out) throws IOException, TemplateException(Code)
Writes the of the specified block to the given output stream, using UTF-8 encoding.
Parameters:
  id - the ID of the block
Parameters:
  out - the stream to write to
exception:
  IOException - when errors occur during the manipulation of theoutput stream
exception:
  TemplateException - when the block ID isn't known
See Also:   Template.writeContent(OutputStream)
See Also:   Template.writeContent(OutputStream,String)
See Also:   Template.write
since:
   1.0



writeContent
public void writeContent(OutputStream out) throws IOException, TemplateException(Code)
Writes the to the given stream, using UTF-8 encoding.
Parameters:
  out - the stream to which the template contents should be written
exception:
  IOException - when errors occur during the manipulation of theoutput stream
exception:
  TemplateException - when an error occurs during the templatecontent evaluation
See Also:   Template.writeBlock
See Also:   Template.writeContent(OutputStream,String)
See Also:   Template.write
since:
   1.0



writeContent
public void writeContent(OutputStream out, String charsetName) throws IOException, TemplateException(Code)
Writes the to the given stream, using the specified charset for encoding.
Parameters:
  out - the stream to which the template contents should be written
Parameters:
  charsetName - the name of the charset to use
exception:
  IOException - when errors occur during the manipulation of theoutput stream; or

when the character set isn't valid
exception:
  TemplateException - when an error occurs during the templatecontent evaluation
See Also:   Template.writeBlock
See Also:   Template.writeContent(OutputStream)
See Also:   Template.write
since:
   1.0




www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.