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
This node is responsible for the bracket notation at the end of
a reference, e.g., $foo[1]
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Indicates if we are running in strict reference mode. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
adjMinusIndexArg
(Object argument, Object o, InternalContextAdapter context, SimpleNode node) If argument is an Integer and negative, then return (o.size() - argument).execute
(Object o, InternalContextAdapter context) 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
-
Field Details
-
strictRef
protected boolean strictRefIndicates if we are running in strict reference mode.
-
-
Constructor Details
-
ASTIndex
public ASTIndex(int i) - Parameters:
i
-
-
ASTIndex
- Parameters:
p
-i
-
-
-
Method Details
-
init
- Specified by:
init
in interfaceNode
- Overrides:
init
in classSimpleNode
- Parameters:
context
-data
-- Returns:
- data
- Throws:
TemplateInitException
- See Also:
-
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
- Specified by:
execute
in interfaceNode
- Overrides:
execute
in classSimpleNode
- Parameters:
o
-context
-- Returns:
- object value
- Throws:
MethodInvocationException
- See Also:
-