org.apache.velocity.runtime.parser.node
Class ASTIndex
java.lang.Object
org.apache.velocity.runtime.parser.node.SimpleNode
org.apache.velocity.runtime.parser.node.ASTIndex
- All Implemented Interfaces:
- 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 |
protected boolean |
strictRef
Indicates if we are running in strict reference mode. |
Fields inherited from class org.apache.velocity.runtime.parser.node.SimpleNode |
children, first, id, info, invalid, last, log, parent, parser, rsvc, state, templateName |
Methods inherited from class org.apache.velocity.runtime.parser.node.SimpleNode |
childrenAccept, dump, evaluate, getColumn, getFirstToken, getInfo, getLastToken, getLine, getLocation, getRuntimeServices, getTemplateName, getType, isInvalid, jjtAccept, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent, literal, render, setFirstToken, setInfo, setInvalid, toString, toString, value |
strictRef
protected boolean strictRef
- Indicates if we are running in strict reference mode.
ASTIndex
public ASTIndex(int i)
ASTIndex
public ASTIndex(Parser p,
int i)
init
public Object init(InternalContextAdapter context,
Object data)
throws TemplateInitException
- Specified by:
init
in interface Node
- Overrides:
init
in class SimpleNode
- Returns:
- The init result.
- 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:
context
- Used to access the method cache.node
- ASTNode used for error reporting.
execute
public Object execute(Object o,
InternalContextAdapter context)
throws MethodInvocationException
- Specified by:
execute
in interface Node
- Overrides:
execute
in class SimpleNode
- Returns:
- The execution result.
- Throws:
MethodInvocationException
- See Also:
Node.execute(java.lang.Object, org.apache.velocity.context.InternalContextAdapter)
Copyright © 2000-2010 The Apache Software Foundation. All Rights Reserved.