ee.mare.indrek.jtlt
Class TemplateContext

Object
  extended byee.mare.indrek.jtlt.TemplateContext
Direct Known Subclasses:
HtmlTemplateContext

public class TemplateContext
extends Object

TemplateContext represents the settings and parameters that are used with working templates derived from given context. Usually you'll be using the default context. The default parameters are: startTag is <!--, endTag is -->. Also only one macro that handles the KEY-s is defined.


Constructor Summary
TemplateContext()
          Construct a new TemplateContext.
 
Method Summary
 void clearShortcutTags(String macro)
          Clear shortcut tags for macro.
 void complain(String err)
          This method is called by templates when an error happens at runtime.
 void complain(String err, Exception ex)
          Complain by getting an additional exception to complain about.
 TemplateMacro findMacro(String name)
          Find a registered macro with given name.
 String getCharset()
          Get the charset used when opening template files for reading.
 String getEndTag()
          Get the ending string for template directives.
 String getStartTag()
          Get the starting string for template directives.
 void registerMacro(TemplateMacro m)
          Register a macro.
 void setCharset(String charset)
          Set the charset that is used when opening template files.
 PrintStream setComplainTo(PrintStream out)
          Set the stream where to complain when unexpected errors happen.
 void setEndTag(String ss)
          Set the ending tag for template directives.
 void setShortcutTags(String macro, String start, String end)
          Set a shortcut tags for macro.
 void setStartTag(String ss)
          Set the starting tag for template directives.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateContext

public TemplateContext()
Construct a new TemplateContext. These are used to create instances of templates with given parameters (start/end tag), tempalte macros, filters, etc.

Method Detail

clearShortcutTags

public void clearShortcutTags(String macro)
Clear shortcut tags for macro.


complain

public void complain(String err)
This method is called by templates when an error happens at runtime. Currently it only prints out the error message and a current stack trace to the stream specified by setComplainTo(java.io.PrintStream).


complain

public void complain(String err,
                     Exception ex)
Complain by getting an additional exception to complain about.


findMacro

public TemplateMacro findMacro(String name)
Find a registered macro with given name.

See Also:
registerMacro(ee.mare.indrek.jtlt.TemplateMacro)

getCharset

public String getCharset()
Get the charset used when opening template files for reading. The default charset is ISO-8859-1.


getEndTag

public String getEndTag()
Get the ending string for template directives.

See Also:
setEndTag(java.lang.String)

getStartTag

public String getStartTag()
Get the starting string for template directives.

See Also:
setStartTag(java.lang.String)

registerMacro

public void registerMacro(TemplateMacro m)
Register a macro.

See Also:
findMacro(java.lang.String)

setCharset

public void setCharset(String charset)
Set the charset that is used when opening template files.


setComplainTo

public PrintStream setComplainTo(PrintStream out)
Set the stream where to complain when unexpected errors happen. Complains will be mostly written when you try to lock a block that does not exist. Can be set to null to disable complaints. By default set to System.err.

Returns:
the previously assigned complain stream

setEndTag

public void setEndTag(String ss)
Set the ending tag for template directives.

See Also:
getEndTag()

setShortcutTags

public void setShortcutTags(String macro,
                            String start,
                            String end)
Set a shortcut tags for macro.


setStartTag

public void setStartTag(String ss)
Set the starting tag for template directives.

See Also:
getStartTag()