Class ASTIndex
- java.lang.Object
-
- org.apache.velocity.runtime.parser.node.SimpleNode
-
- org.apache.velocity.runtime.parser.node.ASTIndex
-
- All Implemented Interfaces:
Cloneable
,Node
,Renderable
public class ASTIndex extends SimpleNode
This node is responsible for the bracket notation at the end of a reference, e.g., $foo[1]
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
strictRef
Indicates if we are running in strict reference mode.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Object
adjMinusIndexArg(Object argument, Object o, InternalContextAdapter context, SimpleNode node)
If argument is an Integer and negative, then return (o.size() - argument).Object
execute(Object o, InternalContextAdapter context)
Object
init(InternalContextAdapter context, Object data)
-
Methods inherited from class org.apache.velocity.runtime.parser.node.SimpleNode
childrenAccept, cleanupParserAndTokens, clone, clone, dump, dump, dump, evaluate, getColumn, getFirstToken, getFirstTokenImage, getInfo, getLastToken, getLastTokenImage, getLine, getLocation, getParser, getRuntimeServices, getTemplate, getTemplateName, getType, isInvalid, jjtAccept, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent, literal, render, saveTokenImages, setFirstToken, setInfo, setInvalid, toString, toString, value
-
-
-
-
Constructor Detail
-
ASTIndex
public ASTIndex(int i)
- Parameters:
i
-
-
ASTIndex
public ASTIndex(Parser p, int i)
- Parameters:
p
-i
-
-
-
Method Detail
-
init
public Object init(InternalContextAdapter context, Object data) throws TemplateInitException
- Specified by:
init
in interfaceNode
- Overrides:
init
in classSimpleNode
- Parameters:
context
-data
-- Returns:
- data
- Throws:
TemplateInitException
- See Also:
Node.init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
-
adjMinusIndexArg
public static Object adjMinusIndexArg(Object argument, Object o, InternalContextAdapter context, SimpleNode node)
If argument is an Integer and negative, then return (o.size() - argument). Otherwise return the original argument. We use this to calculate the true index of a negative index e.g., $foo[-1]. If no size() method is found on the 'o' object, then we throw an VelocityException.- Parameters:
argument
-o
-context
- Used to access the method cache.node
- ASTNode used for error reporting.- Returns:
- found object
-
execute
public Object execute(Object o, InternalContextAdapter context) throws MethodInvocationException
- Specified by:
execute
in interfaceNode
- Overrides:
execute
in classSimpleNode
- Parameters:
o
-context
-- Returns:
- object value
- Throws:
MethodInvocationException
- See Also:
Node.execute(java.lang.Object, org.apache.velocity.context.InternalContextAdapter)
-
-