com.google.clearsilver.jsilver.interpreter
Class InterpretedMacro

java.lang.Object
  extended by com.google.clearsilver.jsilver.interpreter.InterpretedMacro
All Implemented Interfaces:
Macro, Template

public class InterpretedMacro
extends Object
implements Macro

User defined macro that will be executed by the interpreter. NOTE: This is not thread safe and cannot be shared between RenderingContexts. This is taken care of by the TemplateInterpreter.


Constructor Summary
InterpretedMacro(PCommand command, Template owningTemplate, String macroName, String[] argumentNames, TemplateInterpreter templateInterpreter, RenderingContext owningContext)
           
 
Method Summary
 RenderingContext createRenderingContext(Data data, Appendable out, ResourceLoader resourceLoader)
          Create a new RenderingContext.
 int getArgumentCount()
          Return the number of arguments this macro expects.
 String getArgumentName(int index)
          Get the name of the nth argument defined in the macro.
 String getDisplayName()
          Name to use when displaying error or log messages.
 EscapeMode getEscapeMode()
          Return the EscapeMode in which this template was generated.
 String getMacroName()
          Name of macro (e.g.
 String getTemplateName()
          Name of template (e.g.
 void render(Data data, Appendable out, ResourceLoader resourceLoader)
          Render the template.
 void render(RenderingContext context)
          Render the template with a custom RenderingContext.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InterpretedMacro

public InterpretedMacro(PCommand command,
                        Template owningTemplate,
                        String macroName,
                        String[] argumentNames,
                        TemplateInterpreter templateInterpreter,
                        RenderingContext owningContext)
Method Detail

render

public void render(RenderingContext context)
            throws IOException
Description copied from interface: Template
Render the template with a custom RenderingContext.

Specified by:
render in interface Template
Parameters:
context - RenderingContext to use during rendering.
Throws:
IOException

render

public void render(Data data,
                   Appendable out,
                   ResourceLoader resourceLoader)
            throws IOException
Description copied from interface: Template
Render the template.

Specified by:
render in interface Template
Parameters:
data - Data to merge with template.
out - Target to write to.
resourceLoader - ResourceLoader to use instead of the default template one when loading files.
Throws:
IOException

createRenderingContext

public RenderingContext createRenderingContext(Data data,
                                               Appendable out,
                                               ResourceLoader resourceLoader)
Description copied from interface: Template
Create a new RenderingContext.

Specified by:
createRenderingContext in interface Template
Parameters:
data - Data to merge with template.
out - Target to write to.
resourceLoader - ResourceLoader to load files.

getTemplateName

public String getTemplateName()
Description copied from interface: Template
Name of template (e.g. mytemplate.cs).

Specified by:
getTemplateName in interface Template

getEscapeMode

public EscapeMode getEscapeMode()
Description copied from interface: Template
Return the EscapeMode in which this template was generated.

Specified by:
getEscapeMode in interface Template
Returns:
EscapeMode

getDisplayName

public String getDisplayName()
Description copied from interface: Template
Name to use when displaying error or log messages. May return the same value as #getTemplateName, or may contain more information.

Specified by:
getDisplayName in interface Template

getMacroName

public String getMacroName()
Description copied from interface: Macro
Name of macro (e.g. showTable). Used to generate error messages.

Specified by:
getMacroName in interface Macro

getArgumentName

public String getArgumentName(int index)
Description copied from interface: Macro
Get the name of the nth argument defined in the macro. Throws exception if the argument is not found.

Specified by:
getArgumentName in interface Macro

getArgumentCount

public int getArgumentCount()
Description copied from interface: Macro
Return the number of arguments this macro expects. Must be equal to the number of arguments supplied.

Specified by:
getArgumentCount in interface Macro


Copyright © 2010-2012 Google. All Rights Reserved.