Package 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:
  `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.

### Fields inherited from class org.apache.velocity.runtime.parser.node.SimpleNode

`children, column, first, firstImage, id, info, invalid, last, lastImage, line, literal, log, parent, parser, rsvc, state, template`

## Constructor Summary

Constructors
Constructor
Description
`ASTIndex(int i)`
`ASTIndex(Parser p, int i)`

## Method Summary

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`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### strictRef

protected boolean strictRef
Indicates if we are running in strict reference mode.

## Constructor Details

### ASTIndex

public ASTIndex(int i)

Parameters:
  `i` -

### ASTIndex

public ASTIndex(Parser p, int i)

Parameters:
  `p` -
  `i` -

## Method Details

### init

public Object init(InternalContextAdapter context, Object data) throws TemplateInitException

Specified by:
  `init` in interface `Node`
Overrides:
  `init` in class `SimpleNode`
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 interface `Node`
Overrides:
  `execute` in class `SimpleNode`
Parameters:
  `o` -
  `context` -
Returns:
  object value
Throws:
  `MethodInvocationException`
See Also:
  - `Node.execute(java.lang.Object, org.apache.velocity.context.InternalContextAdapter)`