Class Directive
java.lang.Object
org.apache.velocity.runtime.directive.Directive
- All Implemented Interfaces:
Cloneable
,DirectiveConstants
- Direct Known Subclasses:
Block
,Break
,Evaluate
,Foreach
,InputBase
,Literal
,Macro
,RuntimeMacro
,Stop
,VelocimacroProxy
Base class for all directives used in Velocity.
- Version:
- $Id: Directive.java 778045 2009-05-23 22:17:46Z nbubna $
- Author:
- Jason van Zyl, Nathan Bubna
-
Field Summary
FieldsFields inherited from interface org.apache.velocity.runtime.directive.DirectiveConstants
BLOCK, LINE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
for log msg purposesint
getLine()
for log msg purposesabstract String
getName()
Return the name of this directive.abstract int
getType()
Get the directive type BLOCK/LINE.void
init
(RuntimeServices rs, InternalContextAdapter context, Node node) How this directive is to be initialized.boolean
protected Scope
protected void
postRender
(InternalContextAdapter context) This cleans up any scope control for this directive after rendering, assuming the scope control was turned on.protected void
preRender
(InternalContextAdapter context) This creates and places the scope control for this directive into the context (if scope provision is turned on).abstract boolean
render
(InternalContextAdapter context, Writer writer, Node node) How this directive is to be renderedvoid
setLocation
(int line, int column) Allows the template location to be set.void
setLocation
(int line, int column, String templateName) Allows the template location to be set.
-
Field Details
-
rsvc
-
-
Constructor Details
-
Directive
public Directive()
-
-
Method Details
-
getName
Return the name of this directive.- Returns:
- The name of this directive.
-
getType
public abstract int getType()Get the directive type BLOCK/LINE.- Returns:
- The directive type BLOCK/LINE.
-
setLocation
public void setLocation(int line, int column) Allows the template location to be set.- Parameters:
line
-column
-
-
setLocation
Allows the template location to be set.- Parameters:
line
-column
-
-
getLine
public int getLine()for log msg purposes- Returns:
- The current line for log msg purposes.
-
getColumn
public int getColumn()for log msg purposes- Returns:
- The current column for log msg purposes.
-
getTemplateName
- Returns:
- The template file name this directive was defined in, or null if not defined in a file.
-
getScopeName
-
isScopeProvided
public boolean isScopeProvided()- Returns:
- true if there will be a scope control injected into the context when rendering this directive.
-
init
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException How this directive is to be initialized.- Parameters:
rs
-context
-node
-- Throws:
TemplateInitException
-
render
public abstract boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException How this directive is to be rendered- Parameters:
context
-writer
-node
-- Returns:
- True if the directive rendered successfully.
- Throws:
IOException
ResourceNotFoundException
ParseErrorException
MethodInvocationException
-
preRender
This creates and places the scope control for this directive into the context (if scope provision is turned on). -
makeScope
-
postRender
This cleans up any scope control for this directive after rendering, assuming the scope control was turned on.
-