Class SimpleNode
java.lang.Object
org.apache.velocity.runtime.parser.node.SimpleNode
- All Implemented Interfaces:
Cloneable
,Node
,Renderable
- Direct Known Subclasses:
ASTAssignment
,ASTBinaryOperator
,ASTBlock
,ASTComment
,ASTDirective
,ASTDirectiveAssign
,ASTElseIfStatement
,ASTElseStatement
,ASTEscape
,ASTEscapedDirective
,ASTExpression
,ASTFalse
,ASTFloatingPointLiteral
,ASTIdentifier
,ASTIfStatement
,ASTIncludeStatement
,ASTIndex
,ASTIntegerLiteral
,ASTIntegerRange
,ASTMap
,ASTMethod
,ASTNegateNode
,ASTNotNode
,ASTObjectArray
,ASTParameters
,ASTprocess
,ASTReference
,ASTSetDirective
,ASTStringLiteral
,ASTText
,ASTTextblock
,ASTTrue
,ASTVariable
,ASTWord
-
Field Summary
Modifier and TypeFieldDescriptionprotected Node[]
protected int
Column number for this Node in the vm source file.protected Token
protected String
String image variable of the first Token element that was parsed and connected to this Node.protected int
protected int
protected boolean
protected Token
protected String
String image variable of the last Token element that was parsed and connected to this Node.protected int
Line number for this Node in the vm source file.protected String
For caching the literal value.protected org.slf4j.Logger
protected Node
protected Parser
protected RuntimeServices
boolean
protected Template
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionchildrenAccept
(StandardParserVisitor visitor, Object data) void
Removes references to Parser and Tokens since they are not needed anymore at this point.Root node deep cloningprotected Node
Child node deep cloningfinal void
Dumps nodes tree on System.out.final void
dump
(String prefix, PrintStream out) Dumps nodes tree on System.out.void
dump
(String prefix, PrintWriter out) Dumps nodes tree on System.out.boolean
evaluate
(InternalContextAdapter context) execute
(Object o, InternalContextAdapter context) int
int
getInfo()
int
getLine()
protected String
getLocation
(InternalContextAdapter context) Return a string that tells the current location of this node.int
getType()
init
(InternalContextAdapter context, Object data) boolean
jjtAccept
(StandardParserVisitor visitor, Object data) void
jjtAddChild
(Node n, int i) This method tells the node to add its argument to the node's list of children.void
jjtClose()
This method is called after all the child nodes have been added.jjtGetChild
(int i) This method returns a child node.int
Return the number of children the node has.void
jjtOpen()
This method is called after the node has been made the current node.void
jjtSetParent
(Node n) This pair of methods are used to inform the node of its parent.literal()
boolean
render
(InternalContextAdapter context, Writer writer) void
Call before calling cleanupParserAndTokens() if you want to store image of the first and last token of this node.void
void
setInfo
(int info) void
Mark the node as invalid.toString()
value
(InternalContextAdapter context)
-
Field Details
-
rsvc
-
log
protected org.slf4j.Logger log -
parent
-
children
-
id
protected int id -
parser
-
info
protected int info -
state
public boolean state -
invalid
protected boolean invalid -
first
-
last
-
template
-
literal
For caching the literal value. -
line
protected int lineLine number for this Node in the vm source file. -
column
protected int columnColumn number for this Node in the vm source file. -
firstImage
String image variable of the first Token element that was parsed and connected to this Node. -
lastImage
String image variable of the last Token element that was parsed and connected to this Node.
-
-
Constructor Details
-
SimpleNode
public SimpleNode(int i) - Parameters:
i
-
-
SimpleNode
- Parameters:
p
-i
-
-
-
Method Details
-
getRuntimeServices
-
jjtOpen
public void jjtOpen()Description copied from interface:Node
This method is called after the node has been made the current node. It indicates that child nodes can now be added to it. -
jjtClose
public void jjtClose()Description copied from interface:Node
This method is called after all the child nodes have been added. -
setFirstToken
- Parameters:
t
-
-
getFirstToken
- Specified by:
getFirstToken
in interfaceNode
- Returns:
- The first token.
- See Also:
-
getLastToken
- Specified by:
getLastToken
in interfaceNode
- Returns:
- The last token.
- See Also:
-
jjtSetParent
Description copied from interface:Node
This pair of methods are used to inform the node of its parent.- Specified by:
jjtSetParent
in interfaceNode
- Parameters:
n
-- See Also:
-
jjtGetParent
- Specified by:
jjtGetParent
in interfaceNode
- Returns:
- The node parent.
- See Also:
-
jjtAddChild
Description copied from interface:Node
This method tells the node to add its argument to the node's list of children.- Specified by:
jjtAddChild
in interfaceNode
- Parameters:
n
-i
-- See Also:
-
jjtGetChild
Description copied from interface:Node
This method returns a child node. The children are numbered from zero, left to right.- Specified by:
jjtGetChild
in interfaceNode
- Parameters:
i
-- Returns:
- A child node.
- See Also:
-
jjtGetNumChildren
public int jjtGetNumChildren()Description copied from interface:Node
Return the number of children the node has.- Specified by:
jjtGetNumChildren
in interfaceNode
- Returns:
- The number of children of this node.
- See Also:
-
jjtAccept
-
childrenAccept
- Specified by:
childrenAccept
in interfaceNode
- Parameters:
visitor
-data
-- Returns:
- The node execution result.
- See Also:
-
toString
- Parameters:
prefix
- display prefix- Returns:
- String representation of this node.
-
dump
Dumps nodes tree on System.out.
Override
dump(String, PrintWriter)
if you want to customize how the node dumps out its children.- Parameters:
prefix
-
-
dump
Dumps nodes tree on System.out.
Override
dump(String, PrintWriter)
if you want to customize how the node dumps out its children.- Parameters:
prefix
- display prefixout
- output print stream
-
dump
Dumps nodes tree on System.out.
Override this method if you want to customize how the node dumps out its children.
- Parameters:
prefix
- display prefixout
- output print writer
-
getLocation
Return a string that tells the current location of this node.- Parameters:
context
-- Returns:
- location
-
literal
-
init
- Specified by:
init
in interfaceNode
- Parameters:
context
-data
-- Returns:
- The init result.
- Throws:
TemplateInitException
- See Also:
-
evaluate
- Specified by:
evaluate
in interfaceNode
- Parameters:
context
-- Returns:
- The evaluation result.
- Throws:
MethodInvocationException
- See Also:
-
value
- Specified by:
value
in interfaceNode
- Parameters:
context
-- Returns:
- The node value.
- Throws:
MethodInvocationException
- See Also:
-
render
public boolean render(InternalContextAdapter context, Writer writer) throws IOException, MethodInvocationException, ParseErrorException, ResourceNotFoundException - Specified by:
render
in interfaceNode
- Specified by:
render
in interfaceRenderable
- Parameters:
context
-writer
-- Returns:
- True if the node rendered successfully.
- Throws:
IOException
MethodInvocationException
ParseErrorException
ResourceNotFoundException
- See Also:
-
execute
- Specified by:
execute
in interfaceNode
- Parameters:
o
-context
-- Returns:
- The execution result.
- Throws:
MethodInvocationException
- See Also:
-
getType
public int getType() -
setInfo
public void setInfo(int info) -
getInfo
public int getInfo() -
setInvalid
public void setInvalid()Description copied from interface:Node
Mark the node as invalid.- Specified by:
setInvalid
in interfaceNode
- See Also:
-
isInvalid
public boolean isInvalid() -
getLine
public int getLine() -
getColumn
public int getColumn() -
toString
-
getTemplateName
- Specified by:
getTemplateName
in interfaceNode
- Returns:
- the file name of the template
-
saveTokenImages
public void saveTokenImages()Call before calling cleanupParserAndTokens() if you want to store image of the first and last token of this node. -
cleanupParserAndTokens
public void cleanupParserAndTokens()Removes references to Parser and Tokens since they are not needed anymore at this point. This allows us to save memory quite a bit. -
getFirstTokenImage
- Specified by:
getFirstTokenImage
in interfaceNode
- Returns:
- String image variable of the first Token element that was parsed and connected to this Node.
-
getLastTokenImage
- Specified by:
getLastTokenImage
in interfaceNode
- Returns:
- String image variable of the last Token element that was parsed and connected to this Node.
-
getTemplate
- Specified by:
getTemplate
in interfaceNode
- Returns:
- the template this node belongs to
-
getParser
-
clone
Root node deep cloning- Parameters:
template
- owner template- Returns:
- cloned node
- Throws:
CloneNotSupportedException
- Since:
- 2.4
-
clone
Child node deep cloning- Parameters:
template
- owner templateparent
- parent node- Returns:
- cloned node
- Throws:
CloneNotSupportedException
- Since:
- 2.4
-