Class ASTReference
java.lang.Object
org.apache.velocity.runtime.parser.node.SimpleNode
org.apache.velocity.runtime.parser.node.ASTReference
- All Implemented Interfaces:
Cloneable
,Node
,Renderable
This class is responsible for handling the references in
VTL ($foo).
Please look at the Parser.jjt file which is
what controls the generation of this class.
- Version:
- $Id$
- Author:
- Jason van Zyl, Geir Magnusson Jr., Christoph Reck, Kent Johnson
-
Field Summary
Modifier and TypeFieldDescriptionboolean
Indicates if we are using modified escape behavior in strict mode.boolean
Indicates if we are running in strict reference mode.protected Info
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
evaluate
(InternalContextAdapter context) Computes boolean value of this reference Returns the actual value of reference return type boolean, and 'true' if value is not nullexecute
(Object o, InternalContextAdapter context) gets an Object that 'is' the value of the referenceReturns the 'root string', the reference keyinit
(InternalContextAdapter context, Object data) jjtAccept
(StandardParserVisitor visitor, Object data) static String
printClass
(Class<?> clazz) Utility class to handle nulls when printing a class typeboolean
render
(InternalContextAdapter context, Writer writer) gets the value of the reference and outputs it to the writer.boolean
setValue
(InternalContextAdapter context, Object value) Sets the value of a complex reference (something like $foo.bar) Currently used by ASTSetReference()value
(InternalContextAdapter context) Methods inherited from class org.apache.velocity.runtime.parser.node.SimpleNode
childrenAccept, cleanupParserAndTokens, clone, clone, dump, dump, dump, getColumn, getFirstToken, getFirstTokenImage, getInfo, getLastToken, getLastTokenImage, getLine, getLocation, getParser, getRuntimeServices, getTemplate, getTemplateName, getType, isInvalid, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent, literal, saveTokenImages, setFirstToken, setInfo, setInvalid, toString, toString
-
Field Details
-
strictRef
public boolean strictRefIndicates if we are running in strict reference mode. -
strictEscape
public boolean strictEscapeIndicates if we are using modified escape behavior in strict mode. mainly we allow \$abc -> to render as $abc -
uberInfo
-
-
Constructor Details
-
ASTReference
public ASTReference(int id) - Parameters:
id
-
-
ASTReference
- Parameters:
p
-id
-
-
-
Method Details
-
jjtAccept
- Specified by:
jjtAccept
in interfaceNode
- Overrides:
jjtAccept
in classSimpleNode
- Parameters:
visitor
-data
-- Returns:
- The Node execution result object.
- See Also:
-
init
- Specified by:
init
in interfaceNode
- Overrides:
init
in classSimpleNode
- Parameters:
context
-data
-- Returns:
- The init result.
- Throws:
TemplateInitException
- See Also:
-
getRootString
Returns the 'root string', the reference key- Returns:
- the root string.
-
execute
gets an Object that 'is' the value of the reference- Specified by:
execute
in interfaceNode
- Overrides:
execute
in classSimpleNode
- Parameters:
o
- Object parameter, unused per se, but non-null by convention inside an #if/#elseif evaluationcontext
- context used to generate value- Returns:
- The execution result.
- Throws:
MethodInvocationException
- See Also:
-
render
public boolean render(InternalContextAdapter context, Writer writer) throws IOException, MethodInvocationException gets the value of the reference and outputs it to the writer.- Specified by:
render
in interfaceNode
- Specified by:
render
in interfaceRenderable
- Overrides:
render
in classSimpleNode
- Parameters:
context
- context of data to use in getting valuewriter
- writer to render to- Returns:
- True if rendering was successful.
- Throws:
IOException
MethodInvocationException
- See Also:
-
evaluate
Computes boolean value of this reference Returns the actual value of reference return type boolean, and 'true' if value is not null- Specified by:
evaluate
in interfaceNode
- Overrides:
evaluate
in classSimpleNode
- Parameters:
context
- context to compute value with- Returns:
- True if evaluation was ok.
- Throws:
MethodInvocationException
- See Also:
-
value
- Specified by:
value
in interfaceNode
- Overrides:
value
in classSimpleNode
- Parameters:
context
-- Returns:
- The node value.
- Throws:
MethodInvocationException
- See Also:
-
printClass
Utility class to handle nulls when printing a class type- Parameters:
clazz
-- Returns:
- class name, or the string "null"
-
setValue
public boolean setValue(InternalContextAdapter context, Object value) throws MethodInvocationException Sets the value of a complex reference (something like $foo.bar) Currently used by ASTSetReference()- Parameters:
context
- context object containing this referencevalue
- Object to set as value- Returns:
- true if successful, false otherwise
- Throws:
MethodInvocationException
- See Also:
-
getRootVariableValue
- Parameters:
context
-- Returns:
- The evaluated value of the variable.
- Throws:
MethodInvocationException
-