| Modifier and Type | Class and Description |
|---|---|
protected static class |
TemplateBase.__Itr<T>
The helper class to facilitate generating code for the “for” loop in the template source
|
TextBuilder.StrBufITemplate.__ContextITag.__Body, ITag.__Parameter, ITag.__ParameterList| Modifier and Type | Field and Description |
|---|---|
protected ITemplate.__Context |
__ctx
The render context
|
protected RythmEngine |
__engine
The rythm engine that run this template
|
protected static ILogger |
__logger
The logger
|
protected boolean |
__logTime |
protected TemplateBase |
__parent
The parent template (layout template)
|
protected Map<String,Object> |
__renderArgs
Stores render args of this template.
|
__buffer, __caller| Constructor and Description |
|---|
TemplateBase()
Construct a template instance
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
__append(boolean b)
Append a boolean to internal buffer
|
protected void |
__append(char c)
Append a char to internal buffer
|
protected void |
__append(double d)
Append a double to internal buffer
|
protected void |
__append(float f)
Append a float to internal buffer
|
protected void |
__append(int i)
Append an integer to internal buffer
|
protected void |
__append(long l)
Append a long to internal buffer
|
protected void |
__append(Object o)
Append a object to internal buffer or output (os or writer).
|
protected void |
__append(TextBuilder.StrBuf wrapper)
Append a
TextBuilder.StrBuf content into the buffer |
protected TemplateBase |
__caller()
Return caller of the template when this template is invoked as a
tag |
ITemplate |
__cloneMe(RythmEngine engine,
ITemplate caller)
Not to be used in user application or template
|
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
|
protected static void |
__debug(String msg,
Object... args) |
Escape |
__defaultEscape()
Return the default
escape method. |
protected void |
__endSection()
End a layout section.
|
protected void |
__endSection(boolean def)
End a layout section with a boolean flag mark if it is a default content or not.
|
RythmEngine |
__engine()
Return the
engine running this template |
protected static void |
__error(String msg,
Object... args) |
protected static void |
__error(Throwable t,
String msg,
Object... args) |
protected Object |
__eval(String expr) |
protected void |
__finally()
Template could rewrite this method to make sure operation get called after template rendered even in the case there are exception thrown out
|
protected static <T> T |
__get(Map<String,Object> map,
String name,
Class<T> cls) |
protected <T> T |
__get(String name)
Alias of
__getRenderArg(String) |
protected <T> T |
__get(String name,
Class<T> cls) |
protected <T> T |
__getAs(String name,
Class<T> c)
Get render arg and do type cast to the class specified
|
protected Class |
__getClass(boolean o) |
protected Class |
__getClass(byte o) |
protected Class |
__getClass(char o) |
protected Class |
__getClass(double o) |
protected Class |
__getClass(float o) |
protected Class |
__getClass(int o) |
protected Class |
__getClass(long o) |
protected Class |
__getClass(Object o) |
<T> T |
__getRenderArg(String name)
Return a render arg value by name
|
protected <T> T |
__getRenderProperty(String name)
Get render property by name.
|
protected <T> T |
__getRenderProperty(String name,
T def)
Get render property by name.
|
protected <T> T |
__getRenderPropertyAs(String name,
T def)
Get render property by name and do type cast to the specified default value.
|
protected RawData |
__getSection()
Get layout content as
RawData. |
protected RawData |
__getSection(String name)
Get a section content as
RawData by name. |
TemplateClass |
__getTemplateClass(boolean useCaller)
Get the template class of this template.
|
Map<String,Object> |
__getUserContext()
Return user context previously set to this template instance.
|
protected void |
__handleTemplateExecutionException(Exception e)
Handle template execution exception.
|
protected boolean |
__hasParent() |
protected String |
__i18n(String key,
Object... args) |
protected static void |
__info(String msg,
Object... args) |
void |
__init()
the implementation of this method is to be generated by
CodeBuilder. |
protected void |
__internalBuild()
Not to be used in user application or template
|
protected TemplateBase |
__internalClone()
Not to be used in user application or template
|
protected void |
__internalInit()
Not to be used in user application or template
|
protected String |
__internalRender()
Not to be used in user application or template
|
protected void |
__invokeTag(int line,
String name)
Invoke a tag.
|
protected void |
__invokeTag(int line,
String name,
boolean ignoreNonExistsTag)
Invoke a tag.
|
protected void |
__invokeTag(int line,
String name,
ITag.__ParameterList params)
Invoke a tag.
|
protected void |
__invokeTag(int line,
String name,
ITag.__ParameterList params,
boolean ignoreNonExistsTag)
Invoke a tag.
|
protected void |
__invokeTag(int line,
String name,
ITag.__ParameterList params,
ITag.__Body body)
Invoke a tag.
|
protected void |
__invokeTag(int line,
String name,
ITag.__ParameterList params,
ITag.__Body body,
boolean ignoreNoExistsTag)
Invoke a tag.
|
protected void |
__invokeTag(int line,
String name,
ITag.__ParameterList params,
ITag.__Body body,
ITag.__Body context)
Invoke a tag.
|
protected void |
__invokeTag(int line,
String name,
ITag.__ParameterList params,
ITag.__Body body,
ITag.__Body context,
boolean ignoreNonExistsTag)
Invoke a tag.
|
protected static boolean |
__isDefVal(Object o) |
protected void |
__loadExtendingArgs()
the implementation of this method is to be generated by
CodeBuilder. |
protected static void |
__log(String msg,
Object... args) |
protected void |
__pLayoutContent()
Print the layout content.
|
protected void |
__pLayoutSection(String name)
Print a layout section by name.
|
protected void |
__pLayoutSectionInherited(String name)
Print default section content inside child template section content.
|
protected void |
__popItrVar() |
void |
__prepareRender(ICodeType type,
Locale locale,
RythmEngine engine) |
protected void |
__pushItrVar(String name,
Object val) |
protected RawData |
__render(String template)
Render another template from within this template.
|
protected RawData |
__render(String template,
Object... args)
Render another template from this template.
|
protected String |
__renderArgName(int i)
Return render arg name by position
|
protected Class[] |
__renderArgTypeArray()
Return render arg type in array.
|
protected Map<String,Class> |
__renderArgTypeMap()
Return render arg type in Map.
|
protected static <T> T |
__safeCast(Object o,
Class<T> cls) |
protected TemplateBase |
__set(String name,
Object arg)
alias of
__setRenderArg(String, Object) |
protected void |
__setLayoutContent(String body)
Set layout content.
|
protected void |
__setOutput(File file)
Set output file
|
protected void |
__setOutput(OutputStream os)
Set output stream
|
protected void |
__setOutput(String path)
Set output file path
|
protected void |
__setOutput(Writer w)
Set output writer
|
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
|
protected TemplateBase |
__setRenderArgs0(ITag.__ParameterList params)
Set render arg from
tag params Not to be used in user application or template |
protected void |
__setRenderProperty(String name,
Object val)
Set render property by name.
|
ITemplate |
__setSecureCode(String secureCode)
Set secure code (for sandbox purpse)
|
void |
__setTemplateClass(TemplateClass templateClass)
Set template class and template code type to this template instance
|
protected void |
__setup()
the implementation of this method is to be generated by
CodeBuilder. |
ITemplate |
__setUserContext(Map<String,Object> context)
Set user context to the template instance
|
ITemplate |
__setWriter(Writer writer)
Set a character based writer to the template instance
|
protected void |
__startSection(String name)
Start a layout section.
|
protected ITemplate |
__template()
Used for Java extension/transformer
|
protected static <T> T |
__transNull(Class<T> cls) |
protected void |
__triggerRenderEvent(IEvent<Void,ITemplate> event,
RythmEngine engine)
Trigger render events.
|
protected static void |
__warn(String msg,
Object... args) |
protected static void |
__warn(Throwable t,
String msg,
Object... args) |
TextBuilder |
build()
The
CodeBuilder will generate the implementation of this method usually |
TemplateBase |
pe(Object o)
Print a general expression with
default escape method |
TemplateBase |
pe(Object o,
Escape escape)
Print a general expression, using specified
escape method |
String |
render()
Render and return result in String.
|
void |
render(OutputStream os)
Render to binary output stream.
|
void |
render(Writer w)
Render to character based writer.
|
protected S |
s()
Return
String helper instance. |
pe, pe, pe, pe, pe, pe, pe, pe, pe, pe, pe, pe, pe__append, __getBuffer, __setBuffer, buffer, caller, clone, getSelfOut, np, p, p, p, p, p, p, p, p, p, p2t, p2tn, p3t, p3tn, p4t, p4tn, pn, pn, pt, ptn, setSelfOut, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait__getBuffer__call, __getName, __setBodyContextprotected static final ILogger __logger
The logger
protected transient RythmEngine __engine
The rythm engine that run this template
protected Map<String,Object> __renderArgs
Stores render args of this template. The generated template source code will also declare render args as separate protected field while keeping a copy inside this Map data structure
protected TemplateBase __parent
The parent template (layout template)
protected ITemplate.__Context __ctx
The render context
protected boolean __logTime
public void __setTemplateClass(TemplateClass templateClass)
Set template class and template code type to this template instance
Not to be called in user application or template
templateClass - public void __prepareRender(ICodeType type, Locale locale, RythmEngine engine)
protected S s()
Return String helper instance. Could be used in template authoring. For example:
@if (s().empty(userRight)){ @return } public ITemplate __setWriter(Writer writer)
ITemplateSet a character based writer to the template instance
__setWriter in interface ITemplatepublic ITemplate __setOutputStream(OutputStream os)
ITemplateSet binary output stream to the template instance.
__setOutputStream in interface ITemplatepublic RythmEngine __engine()
Return the engine running this template
protected ITemplate __template()
Used for Java extension/transformer
protected void __invokeTag(int line,
String name)
Invoke a tag. Usually should not used directly in user template
line - name - protected void __invokeTag(int line,
String name,
boolean ignoreNonExistsTag)
Invoke a tag. Usually should not used directly in user template
line - name - ignoreNonExistsTag - protected void __invokeTag(int line,
String name,
ITag.__ParameterList params)
Invoke a tag. Usually should not used directly in user template
line - name - params - protected void __invokeTag(int line,
String name,
ITag.__ParameterList params,
boolean ignoreNonExistsTag)
Invoke a tag. Usually should not used directly in user template
line - name - params - ignoreNonExistsTag - protected void __invokeTag(int line,
String name,
ITag.__ParameterList params,
ITag.__Body body)
Invoke a tag. Usually should not used directly in user template
line - name - params - body - protected void __invokeTag(int line,
String name,
ITag.__ParameterList params,
ITag.__Body body,
boolean ignoreNoExistsTag)
Invoke a tag. Usually should not used directly in user template
line - name - params - body - ignoreNoExistsTag - protected void __invokeTag(int line,
String name,
ITag.__ParameterList params,
ITag.__Body body,
ITag.__Body context)
Invoke a tag. Usually should not used directly in user template
line - name - params - body - context - protected void __invokeTag(int line,
String name,
ITag.__ParameterList params,
ITag.__Body body,
ITag.__Body context,
boolean ignoreNonExistsTag)
Invoke a tag. Usually should not used directly in user template
line - name - params - body - context - ignoreNonExistsTag - protected RawData __render(String template, Object... args)
Render another template from this template. Could be used in template authoring. For example:
@args String customTemplate, Map<String, Object> customParams @{ Object renderResult = render(customTemplate, customParams); } @renderResult
template - args - protected RawData __render(String template)
Render another template from within this template. Using the renderArgs of this template.
template - RawData__render(String, Object...)protected final void __setLayoutContent(String body)
Set layout content. Should not be used in user application or template
body - protected void __startSection(String name)
Start a layout section. Not to be used in user application or template
name - protected void __endSection()
End a layout section. Not to be used in user application or template
protected void __endSection(boolean def)
End a layout section with a boolean flag mark if it is a default content or not. Not to be used in user application or template
def - protected void __pLayoutSection(String name)
Print a layout section by name. Not to be used in user application or template
name - protected void __pLayoutSectionInherited(String name)
Print default section content inside child template section content.
name - protected RawData __getSection(String name)
Get a section content as RawData by name. Not to be used in user application or template
name - protected RawData __getSection()
Get layout content as RawData. Not to be used in user application or template
protected void __pLayoutContent()
Print the layout content. Not to be used in user application or template
protected TemplateBase __internalClone()
Not to be used in user application or template
TemplateBasepublic ITemplate __cloneMe(RythmEngine engine, ITemplate caller)
Not to be used in user application or template
protected void __internalInit()
Not to be used in user application or template
protected void __setup()
the implementation of this method is to be generated by CodeBuilder. Not to be used in user application or template
protected void __loadExtendingArgs()
the implementation of this method is to be generated by CodeBuilder. Not to be used in user application or template
public void __init()
the implementation of this method is to be generated by CodeBuilder. Not to be used in user application or template
public TemplateClass __getTemplateClass(boolean useCaller)
Get the template class of this template. Not to be used in user application or template
__getTemplateClass in interface ITemplateuseCaller - TemplateClasspublic final void render(OutputStream os)
Render to binary output stream. This method is usually called from API defined in RythmEngine
public final void render(Writer w)
Render to character based writer. This method is usually called from API defined in RythmEngine
protected void __triggerRenderEvent(IEvent<Void,ITemplate> event, RythmEngine engine)
Trigger render events.
Not an API for user application
event - engine - public final String render()
Render and return result in String. This method is usually called from API defined in RythmEngine
public ITemplate __setSecureCode(String secureCode)
ITemplateSet secure code (for sandbox purpse)
__setSecureCode in interface ITemplateprotected void __setOutput(String path)
Set output file path
path - protected void __setOutput(File file)
Set output file
file - protected void __setOutput(OutputStream os)
Set output stream
os - protected void __setOutput(Writer w)
Set output writer
w - protected void __internalBuild()
Not to be used in user application or template
protected boolean __hasParent()
protected String __internalRender()
Not to be used in user application or template
public TextBuilder build()
The CodeBuilder will generate the implementation of this method usually
build in class TextBuilderTextBuilderprotected void __finally()
Template could rewrite this method to make sure operation get called after template rendered even in the case there are exception thrown out
public Map<String,Object> __getUserContext()
ITemplateReturn user context previously set to this template instance. if there is no user context has been set, then an empty Map is returned.
__getUserContext in interface ITemplatepublic ITemplate __setUserContext(Map<String,Object> context)
ITemplateSet user context to the template instance
__setUserContext in interface ITemplateprotected Class[] __renderArgTypeArray()
Return render arg type in array. Not to be used in user application or template
protected String __renderArgName(int i)
Return render arg name by position
i - protected Map<String,Class> __renderArgTypeMap()
Return render arg type in Map. Not to be used in user application or template
public ITemplate __setRenderArgs(Map<String,Object> args)
ITemplateSet renderArgs in name-value pair
__setRenderArgs in interface ITemplatepublic ITemplate __setRenderArg(JSONWrapper jsonData)
ITemplateSet renderArgs using JSON data
__setRenderArg in interface ITemplateprotected TemplateBase __setRenderArgs0(ITag.__ParameterList params)
Set render arg from tag params Not to be used in user application or template
params - public ITemplate __setRenderArgs(Object... args)
ITemplateSet renderArgs in position
__setRenderArgs in interface ITemplatepublic ITemplate __setRenderArg(String name, Object arg)
ITemplateSet a render arg by name
__setRenderArg in interface ITemplateprotected final TemplateBase __set(String name, Object arg)
alias of __setRenderArg(String, Object)
name - arg - protected final TemplateBase __caller()
Return caller of the template when this template is invoked as a tag
public <T> T __getRenderArg(String name)
ITemplateReturn a render arg value by name
__getRenderArg in interface ITemplateprotected static final <T> T __transNull(Class<T> cls)
protected static final boolean __isDefVal(Object o)
protected final <T> T __get(String name)
Alias of __getRenderArg(String)
T - name - protected final <T> T __getAs(String name, Class<T> c)
Get render arg and do type cast to the class specified
T - name - c - protected final <T> T __getRenderProperty(String name, T def)
Get render property by name. And do type case by the left value of the expression.
If no property found by name then return the default value specified
T - name - def - protected final <T> T __getRenderProperty(String name)
Get render property by name. This is usually called by @get() directive in teh layout template.
T - name - __setRenderProperty(String, Object)protected final <T> T __getRenderPropertyAs(String name, T def)
Get render property by name and do type cast to the specified default value. If the render property cannot be found by name, then return the default value
T - name - def - __getRenderProperty(String)protected final void __setRenderProperty(String name, Object val)
Set render property by name. This is pass value from sub (content) template to parent (layout) template Usually this is invoked by @set() directive in the sub template
name - val - __getRenderProperty(String),
__getRenderProperty(String, Object)protected final void __handleTemplateExecutionException(Exception e)
Handle template execution exception. Not to be called in user application or template
e - public ITemplate __setRenderArg(int position, Object arg)
ITemplateSet a render arg by position
__setRenderArg in interface ITemplatepublic ICodeType __curCodeType()
ITemplate(not API) Return current code type.
__curCodeType in interface ITemplatetypepublic Locale __curLocale()
ITemplate(not API) Return the current locale
__curLocale in interface ITemplatepublic Escape __curEscape()
ITemplate(not API) Return the current escape scheme
__curEscape in interface ITemplateprotected void __append(TextBuilder.StrBuf wrapper)
TextBuilderAppend a TextBuilder.StrBuf content into the buffer
__append in class TextBuilderprotected void __append(Object o)
TextBuilderAppend a object to internal buffer or output (os or writer).
__append in class TextBuilderprotected void __append(char c)
TextBuilderAppend a char to internal buffer
__append in class TextBuilderprotected void __append(int i)
TextBuilderAppend an integer to internal buffer
__append in class TextBuilderprotected void __append(long l)
TextBuilderAppend a long to internal buffer
__append in class TextBuilderprotected void __append(float f)
TextBuilderAppend a float to internal buffer
__append in class TextBuilderprotected void __append(double d)
TextBuilderAppend a double to internal buffer
__append in class TextBuilderprotected void __append(boolean b)
TextBuilderAppend a boolean to internal buffer
__append in class TextBuilderpublic Escape __defaultEscape()
TemplateBuilderReturn the default escape method.
This implementation returns Escape.RAW. But the sub class could override this method to return different escape method
__defaultEscape in class TemplateBuilderescapepublic final TemplateBase pe(Object o)
TemplateBuilderPrint a general expression with default escape method
pe in class TemplateBuilderpublic final TemplateBase pe(Object o, Escape escape)
TemplateBuilderPrint a general expression, using specified escape method
pe in class TemplateBuilderprotected final Class __getClass(int o)
protected final Class __getClass(boolean o)
protected final Class __getClass(char o)
protected final Class __getClass(long o)
protected final Class __getClass(float o)
protected final Class __getClass(double o)
protected final Class __getClass(byte o)
protected void __popItrVar()
Copyright © 2017–2021 OSGL (Open Source General Library). All rights reserved.