org.rythmengine.template
Interface ITemplate

All Superinterfaces:
Cloneable, ITag
All Known Implementing Classes:
JavaTagBase, TagBase, TemplateBase, ToStringTemplateBase

public interface ITemplate
extends ITag, Cloneable

Define a template instance API


Nested Class Summary
static class ITemplate.__Context
          The render time context.
 
Nested classes/interfaces inherited from interface org.rythmengine.template.ITag
ITag.__Body, ITag.__Parameter, ITag.__ParameterList
 
Method Summary
 ITemplate __cloneMe(RythmEngine engine, ITemplate caller)
          Get a copy of this template instance and pass in the engine and caller
 ICodeType __curCodeType()
          (not API) Return current code type.
 Escape __curEscape()
          (not API) Return the current escape scheme
 Locale __curLocale()
          (not API) Return the current locale
 RythmEngine __engine()
          Return the engine instance that is running this template
 StringBuilder __getBuffer()
          Return the internal buffer
<T> T
__getRenderArg(String name)
          Return a render arg value by name
 org.rythmengine.internal.compiler.TemplateClass __getTemplateClass(boolean useCaller)
          Return the template class of this template instance
 Map<String,Object> __getUserContext()
          Return user context previously set to this template instance.
 void __init()
          Must be called before real render() happened.
 ITemplate __setOutputStream(OutputStream os)
          Set binary output stream to the template instance.
 ITemplate __setRenderArg(int position, Object arg)
          Set a render arg by position
 ITemplate __setRenderArg(JSONWrapper jsonData)
          Set renderArgs using JSON data
 ITemplate __setRenderArg(String name, Object arg)
          Set a render arg by name
 ITemplate __setRenderArgs(Map<String,Object> args)
          Set renderArgs in name-value pair
 ITemplate __setRenderArgs(Object... args)
          Set renderArgs in position
 ITemplate __setSecureCode(String secureCode)
          Set secure code (for sandbox purpse)
 ITemplate __setUserContext(Map<String,Object> userContext)
          Set user context to the template instance
 ITemplate __setWriter(Writer writer)
          Set a character based writer to the template instance
 String render()
          Render the template and return result as String
 void render(OutputStream os)
          Render the template and put the result into outputstream
 void render(Writer w)
          Render the template and put the result into writer
 
Methods inherited from interface org.rythmengine.template.ITag
__call, __getName, __setBodyContext
 

Method Detail

__engine

RythmEngine __engine()
Return the engine instance that is running this template

Returns:
the engine instance

__getTemplateClass

org.rythmengine.internal.compiler.TemplateClass __getTemplateClass(boolean useCaller)
Return the template class of this template instance

Parameters:
useCaller - if set to true then return caller template class if this template has no template class
Returns:
the template class

__setOutputStream

ITemplate __setOutputStream(OutputStream os)
Set binary output stream to the template instance.

Parameters:
os -
Returns:
this template instance
Throws:
NullPointerException - if os specified is null
IllegalStateException - if output stream or writer is already set

__setWriter

ITemplate __setWriter(Writer writer)
Set a character based writer to the template instance

Parameters:
writer -
Returns:
this template instance
Throws:
NullPointerException - if os specified is null
IllegalStateException - if output stream or writer is already set

__setUserContext

ITemplate __setUserContext(Map<String,Object> userContext)
Set user context to the template instance

Parameters:
userContext -
Returns:
this template instance

__getUserContext

Map<String,Object> __getUserContext()
Return user context previously set to this template instance. if there is no user context has been set, then an empty Map is returned.

Returns:
the user context

__setRenderArgs

ITemplate __setRenderArgs(Map<String,Object> args)
Set renderArgs in name-value pair

Parameters:
args -
Returns:
this template instance

__setRenderArgs

ITemplate __setRenderArgs(Object... args)
Set renderArgs in position

Parameters:
args -
Returns:
this template instance

__setRenderArg

ITemplate __setRenderArg(String name,
                         Object arg)
Set a render arg by name

Parameters:
name -
arg -
Returns:
this template instance

__getRenderArg

<T> T __getRenderArg(String name)
Return a render arg value by name

Type Parameters:
T -
Parameters:
name -
Returns:
render arg by name

__setRenderArg

ITemplate __setRenderArg(int position,
                         Object arg)
Set a render arg by position

Parameters:
position -
arg -
Returns:
this template instance

__setRenderArg

ITemplate __setRenderArg(JSONWrapper jsonData)
Set renderArgs using JSON data

Parameters:
jsonData -
Returns:
this template instance

render

String render()
Render the template and return result as String

Returns:
render result

render

void render(OutputStream os)
Render the template and put the result into outputstream

Parameters:
os -

render

void render(Writer w)
Render the template and put the result into writer

Parameters:
w -

__init

void __init()
Must be called before real render() happened. Also if the template extends a parent template, then the parent template's __init() must be called before this template's __init()


__getBuffer

StringBuilder __getBuffer()
Return the internal buffer

Returns:
buffer

__setSecureCode

ITemplate __setSecureCode(String secureCode)
Set secure code (for sandbox purpse)

Parameters:
secureCode -
Returns:
this template

__cloneMe

ITemplate __cloneMe(RythmEngine engine,
                    ITemplate caller)
Get a copy of this template instance and pass in the engine and caller

Parameters:
engine - the rythm engine
caller - the caller template
Returns:
a cloned instance of this template class

__curLocale

Locale __curLocale()
(not API) Return the current locale

Returns:
the locale

__curEscape

Escape __curEscape()
(not API) Return the current escape scheme

Returns:
the escape

__curCodeType

ICodeType __curCodeType()
(not API) Return current code type.

Returns:
current type


Copyright © 2013. All Rights Reserved.