|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectbsh.servlet.SimpleTemplate
public class SimpleTemplate
This is a simple template engine. An instance of SimpleTemplate wraps a StringBuffer and performs replace operations on one or more parameters embedded as HMTL style comments. The value can then be retrieved as a String or written to a stream. Template values in the text are of the form: Substitutions then take the form of: template.replace( "NAME", value ); Two static util methods are provided to help read the text of a template from a stream (perhaps a URL or resource). e.g.
| Constructor Summary | |
|---|---|
SimpleTemplate(java.io.Reader reader)
|
|
SimpleTemplate(java.lang.String template)
|
|
SimpleTemplate(java.net.URL url)
|
|
| Method Summary | |
|---|---|
static java.lang.String |
getStringFromStream(java.io.InputStream ins)
|
static java.lang.String |
getStringFromStream(java.io.Reader reader)
|
static SimpleTemplate |
getTemplate(java.lang.String file)
Get a template by name, with caching. |
static void |
main(java.lang.String[] args)
usage: filename param value |
void |
replace(java.lang.String param,
java.lang.String value)
Substitute the specified text for the parameter |
static void |
setCacheTemplates(boolean b)
|
java.lang.String |
toString()
|
void |
write(java.io.PrintStream out)
|
void |
write(java.io.PrintWriter out)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SimpleTemplate(java.lang.String template)
public SimpleTemplate(java.io.Reader reader)
throws java.io.IOException
java.io.IOException
public SimpleTemplate(java.net.URL url)
throws java.io.IOException
java.io.IOException| Method Detail |
|---|
public static SimpleTemplate getTemplate(java.lang.String file)
public static java.lang.String getStringFromStream(java.io.InputStream ins)
throws java.io.IOException
java.io.IOException
public static java.lang.String getStringFromStream(java.io.Reader reader)
throws java.io.IOException
java.io.IOException
public void replace(java.lang.String param,
java.lang.String value)
public java.lang.String toString()
toString in class java.lang.Objectpublic void write(java.io.PrintWriter out)
public void write(java.io.PrintStream out)
public static void main(java.lang.String[] args)
throws java.io.IOException
java.io.IOExceptionpublic static void setCacheTemplates(boolean b)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||