1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.apache.commons.jexl.parser;
17  
18  import org.apache.commons.jexl.JexlContext;
19  
20  /***
21   * represents an integer.
22   * 
23   * @author <a href="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
24   * @version $Id: ASTIntegerLiteral.java 398202 2006-04-29 16:40:34Z dion $
25   */
26  public class ASTIntegerLiteral extends SimpleNode {
27      /*** literal value. */
28      protected Integer val;
29  
30      /***
31       * Create the node given an id.
32       * 
33       * @param id node id.
34       */
35      public ASTIntegerLiteral(int id) {
36          super(id);
37      }
38  
39      /***
40       * Create a node with the given parser and id.
41       * 
42       * @param p a parser.
43       * @param id node id.
44       */
45      public ASTIntegerLiteral(Parser p, int id) {
46          super(p, id);
47      }
48  
49      /*** {@inheritDoc} */
50      public Object jjtAccept(ParserVisitor visitor, Object data) {
51          return visitor.visit(this, data);
52      }
53  
54      /***
55       * Part of reference resolution - wierd... in JSTL EL you can have foo.2
56       * which is equiv to foo[2] it appears...
57       *
58       * @param obj the object to evaluate against.
59       * @param ctx the {@link JexlContext}.
60       * @throws Exception on any error.
61       * @return the resulting value.
62       * @see ASTArrayAccess#evaluateExpr(Object, Object)
63       */
64      public Object execute(Object obj, JexlContext ctx) throws Exception {
65          return ASTArrayAccess.evaluateExpr(obj, val);
66      }
67  
68      /*** {@inheritDoc} */
69      public Object value(JexlContext jc) throws Exception {
70          return val;
71      }
72  }