|
FreeHEP API Version current |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.freehep.util.template.Template
A simple implementation of ValueProvider.
Template store = new Template(); store.set("title", "Simple Book Template Example"); store.set("name", "JavaBY"); Template book1 = new Template(); book1.set("author", "Alexey Popov"); book1.set("title", "Patterns of using JavaBY Template Engine."); book1.set("year", "2002"); store.append("book", book1);Template book2 = new Template(); book2.set("author", "Garmash Viacheslav"); book2.set("title", "Creating web shop using JavaBY Template Engine."); book2.set("year", "2002"); store.append("book", book2); TemplateEngine engine = new TemplateEngine(); engine.addValueProvider(store); Reader in = new InputStreamReader(Test.class.getResourceAsStream("test.html")); Reader out = engine.filter(in);
Constructor Summary | |
Template()
Create an empty template. |
Method Summary | |
void |
append(String name,
Template template)
Append a template to this template |
String |
getValue(String name)
Get a single value |
List |
getValues(String name)
Get a list of value providers. |
void |
set(String name,
String value)
Set a value. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Template()
Method Detail |
public String getValue(String name)
ValueProvider
getValue
in interface ValueProvider
name
- The name whose value is to be returned
null
if undefined.public List getValues(String name)
ValueProvider
getValues
in interface ValueProvider
name
- The template name of the list to be returned.
null
if no template is defined.public void set(String name, String value)
name
- The name of the valuevalue
- The valuepublic void append(String name, Template template)
name
- The name of the template to add.template
- The template.
|
FreeHEP API Version current |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |