FreeHEP API
Version current

org.freehep.util.template
Class Template

java.lang.Object
  extended byorg.freehep.util.template.Template
All Implemented Interfaces:
ValueProvider

public class Template
extends Object
implements ValueProvider

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);

Version:
$Id: Template.java,v 1.1 2003/02/07 23:57:13 tonyj Exp $
Author:
tonyj
Source Code:
Template.java

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

Template

public Template()
Create an empty template.

Method Detail

getValue

public String getValue(String name)
Description copied from interface: ValueProvider
Get a single value

Specified by:
getValue in interface ValueProvider
Parameters:
name - The name whose value is to be returned
Returns:
The value, or null if undefined.

getValues

public List getValues(String name)
Description copied from interface: ValueProvider
Get a list of value providers. Each item in the returned list must itself be a ValueProvider.

Specified by:
getValues in interface ValueProvider
Parameters:
name - The template name of the list to be returned.
Returns:
The list of value providers, or null if no template is defined.

set

public void set(String name,
                String value)
Set a value.

Parameters:
name - The name of the value
value - The value

append

public void append(String name,
                   Template template)
Append a template to this template

Parameters:
name - The name of the template to add.
template - The template.

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.