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
Fields Modifier and Type Field Description private java.lang.String
methodName
private static java.lang.Object[]
noParams
private static java.lang.Class[]
noTypes
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 java.lang.Object
adjMinusIndexArg(java.lang.Object argument, java.lang.Object o, InternalContextAdapter context, SimpleNode node)
If argument is an Integer and negative, then return (o.size() - argument).java.lang.Object
execute(java.lang.Object o, InternalContextAdapter context)
java.lang.Object
init(InternalContextAdapter context, java.lang.Object data)
-
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
-
-
-
-
Field Detail
-
methodName
private final java.lang.String methodName
- See Also:
- Constant Field Values
-
strictRef
protected boolean strictRef
Indicates if we are running in strict reference mode.
-
noParams
private static final java.lang.Object[] noParams
-
noTypes
private static final java.lang.Class[] noTypes
-
-
Constructor Detail
-
ASTIndex
public ASTIndex(int i)
-
ASTIndex
public ASTIndex(Parser p, int i)
-
-
Method Detail
-
init
public java.lang.Object init(InternalContextAdapter context, java.lang.Object data) throws TemplateInitException
- Specified by:
init
in interfaceNode
- Overrides:
init
in classSimpleNode
- Returns:
- The init result.
- Throws:
TemplateInitException
- See Also:
Node.init(org.apache.velocity.context.InternalContextAdapter, java.lang.Object)
-
adjMinusIndexArg
public static java.lang.Object adjMinusIndexArg(java.lang.Object argument, java.lang.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 java.lang.Object execute(java.lang.Object o, InternalContextAdapter context) throws MethodInvocationException
- Specified by:
execute
in interfaceNode
- Overrides:
execute
in classSimpleNode
- Returns:
- The execution result.
- Throws:
MethodInvocationException
- See Also:
Node.execute(java.lang.Object, org.apache.velocity.context.InternalContextAdapter)
-
-