public class Macro extends Directive
Modifier and Type | Class and Description |
---|---|
static class |
Macro.MacroArg
MacroArgs holds the information for a single argument in a
macro definition.
|
Modifier and Type | Field and Description |
---|---|
private static boolean |
debugMode |
BLOCK, LINE
Constructor and Description |
---|
Macro() |
Modifier and Type | Method and Description |
---|---|
void |
checkArgs(java.util.ArrayList<java.lang.Integer> argtypes,
Token t,
java.lang.String templateName)
Check the argument types of a macro call, called by the parser to do validation
|
private static java.util.List<Macro.MacroArg> |
getArgArray(Node node,
RuntimeServices rsvc)
Creates an array containing the literal text from the macro
argument(s) (including the macro's name as the first arg).
|
java.lang.String |
getName()
Return name of this directive.
|
int |
getType()
Return type of this directive.
|
void |
init(RuntimeServices rs,
InternalContextAdapter context,
Node node)
How this directive is to be initialized.
|
boolean |
isScopeProvided()
Since this class does no processing of content,
there is never a need for an internal scope.
|
static java.lang.StringBuilder |
macroToString(java.lang.StringBuilder buf,
java.util.List<Macro.MacroArg> macroArgs,
RuntimeServices rsvc)
For debugging purposes.
|
boolean |
render(InternalContextAdapter context,
java.io.Writer writer,
Node node)
render() doesn't do anything in the final output rendering.
|
getColumn, getLine, getScopeName, getTemplate, getTemplateName, makeScope, postRender, preRender, setLocation, setLocation
public java.lang.String getName()
public int getType()
public boolean isScopeProvided()
isScopeProvided
in class Directive
public boolean render(InternalContextAdapter context, java.io.Writer writer, Node node) throws java.io.IOException
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException
Directive
public void checkArgs(java.util.ArrayList<java.lang.Integer> argtypes, Token t, java.lang.String templateName) throws ParseException
checkArgs
in class Directive
argtypes
- type, Array of argument types of each argument to the directive
for example ParserTreeConstants.JJTWORDt
- token of directivetemplateName
- the name of the template this directive is referenced in.ParseException
private static java.util.List<Macro.MacroArg> getArgArray(Node node, RuntimeServices rsvc)
node
- The parse node from which to grok the argument
list. It's expected to include the block node tree (for the
macro body).rsvc
- For debugging purposes only.public static java.lang.StringBuilder macroToString(java.lang.StringBuilder buf, java.util.List<Macro.MacroArg> macroArgs, RuntimeServices rsvc)
argArray
and appends them to buf
.buf
- A StringBuilder. If null, a new StringBuilder is allocated.macroArgs
- Array of macro arguments, containing the
#macro() arguments and default values. the 0th is the name.