Class SimpleNode
- java.lang.Object
-
- org.apache.velocity.runtime.parser.node.SimpleNode
-
- All Implemented Interfaces:
Node
,Renderable
- Direct Known Subclasses:
ASTAndNode
,ASTAssignment
,ASTBlock
,ASTComment
,ASTDirective
,ASTElseIfStatement
,ASTElseStatement
,ASTEQNode
,ASTEscape
,ASTEscapedDirective
,ASTExpression
,ASTFalse
,ASTFloatingPointLiteral
,ASTGENode
,ASTGTNode
,ASTIdentifier
,ASTIfStatement
,ASTIncludeStatement
,ASTIndex
,ASTIntegerLiteral
,ASTIntegerRange
,ASTLENode
,ASTLTNode
,ASTMap
,ASTMathNode
,ASTMethod
,ASTNENode
,ASTNotNode
,ASTObjectArray
,ASTOrNode
,ASTParameters
,ASTprocess
,ASTReference
,ASTSetDirective
,ASTStringLiteral
,ASTText
,ASTTextblock
,ASTTrue
,ASTVariable
,ASTWord
public class SimpleNode extends java.lang.Object implements Node
-
-
Field Summary
Fields Modifier and Type Field Description protected Node[]
children
protected Token
first
protected int
id
protected int
info
protected boolean
invalid
protected Token
last
protected Log
log
protected Node
parent
protected Parser
parser
protected RuntimeServices
rsvc
boolean
state
protected java.lang.String
templateName
-
Constructor Summary
Constructors Constructor Description SimpleNode(int i)
SimpleNode(Parser p, int i)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
childrenAccept(ParserVisitor visitor, java.lang.Object data)
void
dump(java.lang.String prefix)
Override this method if you want to customize how the node dumps out its children.boolean
evaluate(InternalContextAdapter context)
java.lang.Object
execute(java.lang.Object o, InternalContextAdapter context)
int
getColumn()
Token
getFirstToken()
int
getInfo()
Token
getLastToken()
int
getLine()
protected java.lang.String
getLocation(InternalContextAdapter context)
Return a string that tells the current location of this node.RuntimeServices
getRuntimeServices()
java.lang.String
getTemplateName()
int
getType()
java.lang.Object
init(InternalContextAdapter context, java.lang.Object data)
boolean
isInvalid()
java.lang.Object
jjtAccept(ParserVisitor visitor, java.lang.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.Node
jjtGetChild(int i)
This method returns a child node.int
jjtGetNumChildren()
Return the number of children the node has.Node
jjtGetParent()
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.java.lang.String
literal()
boolean
render(InternalContextAdapter context, java.io.Writer writer)
void
setFirstToken(Token t)
void
setInfo(int info)
void
setInvalid()
Mark the node as invalid.java.lang.String
toString()
java.lang.String
toString(java.lang.String prefix)
java.lang.Object
value(InternalContextAdapter context)
-
-
-
Field Detail
-
rsvc
protected RuntimeServices rsvc
-
log
protected Log log
-
parent
protected Node parent
-
children
protected Node[] children
-
id
protected int id
-
parser
protected Parser parser
-
info
protected int info
-
state
public boolean state
-
invalid
protected boolean invalid
-
first
protected Token first
-
last
protected Token last
-
templateName
protected java.lang.String templateName
-
-
Constructor Detail
-
SimpleNode
public SimpleNode(int i)
- Parameters:
i
-
-
SimpleNode
public SimpleNode(Parser p, int i)
- Parameters:
p
-i
-
-
-
Method Detail
-
getRuntimeServices
public RuntimeServices 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.- Specified by:
jjtOpen
in interfaceNode
- See Also:
Node.jjtOpen()
-
jjtClose
public void jjtClose()
Description copied from interface:Node
This method is called after all the child nodes have been added.- Specified by:
jjtClose
in interfaceNode
- See Also:
Node.jjtClose()
-
setFirstToken
public void setFirstToken(Token t)
- Parameters:
t
-
-
getFirstToken
public Token getFirstToken()
- Specified by:
getFirstToken
in interfaceNode
- Returns:
- The first token.
- See Also:
Node.getFirstToken()
-
getLastToken
public Token getLastToken()
- Specified by:
getLastToken
in interfaceNode
- Returns:
- The last token.
- See Also:
Node.getLastToken()
-
jjtSetParent
public void jjtSetParent(Node n)
Description copied from interface:Node
This pair of methods are used to inform the node of its parent.- Specified by:
jjtSetParent
in interfaceNode
- See Also:
Node.jjtSetParent(org.apache.velocity.runtime.parser.node.Node)
-
jjtGetParent
public Node jjtGetParent()
- Specified by:
jjtGetParent
in interfaceNode
- Returns:
- The node parent.
- See Also:
Node.jjtGetParent()
-
jjtAddChild
public void jjtAddChild(Node n, int i)
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
- See Also:
Node.jjtAddChild(org.apache.velocity.runtime.parser.node.Node, int)
-
jjtGetChild
public Node jjtGetChild(int i)
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
- Returns:
- A child node.
- See Also:
Node.jjtGetChild(int)
-
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:
Node.jjtGetNumChildren()
-
jjtAccept
public java.lang.Object jjtAccept(ParserVisitor visitor, java.lang.Object data)
- Specified by:
jjtAccept
in interfaceNode
- Returns:
- The Node execution result object.
- See Also:
Node.jjtAccept(org.apache.velocity.runtime.parser.node.ParserVisitor, java.lang.Object)
-
childrenAccept
public java.lang.Object childrenAccept(ParserVisitor visitor, java.lang.Object data)
- Specified by:
childrenAccept
in interfaceNode
- Returns:
- The node execution result.
- See Also:
Node.childrenAccept(org.apache.velocity.runtime.parser.node.ParserVisitor, java.lang.Object)
-
toString
public java.lang.String toString(java.lang.String prefix)
- Parameters:
prefix
-- Returns:
- String representation of this node.
-
dump
public void dump(java.lang.String prefix)
Override this method if you want to customize how the node dumps out its children.- Parameters:
prefix
-
-
getLocation
protected java.lang.String getLocation(InternalContextAdapter context)
Return a string that tells the current location of this node.
-
literal
public java.lang.String literal()
- Specified by:
literal
in interfaceNode
- Returns:
- A literal.
- See Also:
Node.literal()
-
init
public java.lang.Object init(InternalContextAdapter context, java.lang.Object data) throws TemplateInitException
- Specified by:
init
in interfaceNode
- Returns:
- The init result.
- Throws:
TemplateInitException
- See Also:
Node.init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
-
evaluate
public boolean evaluate(InternalContextAdapter context) throws MethodInvocationException
- Specified by:
evaluate
in interfaceNode
- Returns:
- The evaluation result.
- Throws:
MethodInvocationException
- See Also:
Node.evaluate(org.apache.velocity.context.InternalContextAdapter)
-
value
public java.lang.Object value(InternalContextAdapter context) throws MethodInvocationException
- Specified by:
value
in interfaceNode
- Returns:
- The node value.
- Throws:
MethodInvocationException
- See Also:
Node.value(org.apache.velocity.context.InternalContextAdapter)
-
render
public boolean render(InternalContextAdapter context, java.io.Writer writer) throws java.io.IOException, MethodInvocationException, ParseErrorException, ResourceNotFoundException
- Specified by:
render
in interfaceNode
- Specified by:
render
in interfaceRenderable
- Returns:
- True if the node rendered successfully.
- Throws:
java.io.IOException
MethodInvocationException
ParseErrorException
ResourceNotFoundException
- See Also:
Node.render(org.apache.velocity.context.InternalContextAdapter, java.io.Writer)
-
execute
public java.lang.Object execute(java.lang.Object o, InternalContextAdapter context) throws MethodInvocationException
- Specified by:
execute
in interfaceNode
- Returns:
- The execution result.
- Throws:
MethodInvocationException
- See Also:
Node.execute(java.lang.Object, org.apache.velocity.context.InternalContextAdapter)
-
getType
public int getType()
- Specified by:
getType
in interfaceNode
- Returns:
- The NodeType.
- See Also:
Node.getType()
-
setInfo
public void setInfo(int info)
- Specified by:
setInfo
in interfaceNode
- See Also:
Node.setInfo(int)
-
getInfo
public int getInfo()
- Specified by:
getInfo
in interfaceNode
- Returns:
- The current node info.
- See Also:
Node.getInfo()
-
setInvalid
public void setInvalid()
Description copied from interface:Node
Mark the node as invalid.- Specified by:
setInvalid
in interfaceNode
- See Also:
Node.setInvalid()
-
isInvalid
public boolean isInvalid()
- Specified by:
isInvalid
in interfaceNode
- Returns:
- True if the node is invalid.
- See Also:
Node.isInvalid()
-
getLine
public int getLine()
- Specified by:
getLine
in interfaceNode
- Returns:
- The current line position.
- See Also:
Node.getLine()
-
getColumn
public int getColumn()
- Specified by:
getColumn
in interfaceNode
- Returns:
- The current column position.
- See Also:
Node.getColumn()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Since:
- 1.5
-
getTemplateName
public java.lang.String getTemplateName()
- Specified by:
getTemplateName
in interfaceNode
- Returns:
- the file name of the template
-
-