Coverage report

| %line | %branch
--- | --- | ---
org.apache.commons.jexl.parser.ASTMethod |
57% |
90% |

1 |  |
     package org.apache.commons.jexl.parser;
2 |  |
3 |  |
     import java.lang.reflect.InvocationTargetException;
4 |  |
5 |  |
     import org.apache.commons.jexl.JexlContext;
6 |  |
     import org.apache.commons.jexl.util.Introspector;
7 |  |
     import org.apache.commons.jexl.util.introspection.VelMethod;
8 |  |
     import org.apache.commons.jexl.util.introspection.Info;
9 |  |
10 | 2 |
     public class ASTMethod extends SimpleNode
11 |  |
     {
12 |  |
         /** dummy velocity info */
13 | 30 |
         private static Info DUMMY = new Info("", 1, 1);
14 |  |
15 |  |
         public ASTMethod(int id)
16 |  |
         {
17 | 0 |
             super(id);
18 | 0 |
         }
19 |  |
20 |  |
         public ASTMethod(Parser p, int id)
21 |  |
         {
22 | 486 |
             super(p, id);
23 | 486 |
         }
24 |  |
25 |  |
26 |  |
         /** Accept the visitor. **/
27 |  |
         public Object jjtAccept(ParserVisitor visitor, Object data)
28 |  |
         {
29 | 0 |
             return visitor.visit(this, data);
30 |  |
         }
31 |  |
32 |  |
         /**
33 |  |
          *  returns the value of itself applied to the object.
34 |  |
          *   We assume that an identifier can be gotten via a get(String)
35 |  |
          */
36 |  |
         public Object execute(Object obj, JexlContext jc)
37 |  |
             throws Exception
38 |  |
         {
39 | 471 |
             String methodName = ((ASTIdentifier)jjtGetChild(0)).val;
40 |  |
41 | 471 |
             int paramCount = jjtGetNumChildren()-1;
42 |  |
43 |  |
             /*
44 |  |
              *  get our params
45 |  |
              */
46 |  |
47 | 471 |
             Object params[] = new Object[paramCount];
48 |  |
49 |  |
             try
50 |  |
             {
51 | 846 |
                 for (int i=0; i<paramCount; i++)
52 |  |
                 {
53 | 375 |
                     params[i] = ( (SimpleNode) jjtGetChild(i+1)).value(jc);
54 |  |
                 }
55 |  |
56 | 471 |
                 VelMethod vm = Introspector.getUberspect().getMethod(obj, methodName, params, DUMMY);
57 |  |
58 | 471 |
                 if (vm == null)
59 | 0 |
                     return null;
60 |  |
61 | 471 |
                 return vm.invoke(obj, params);
62 |  |
             }
63 |  |
             catch(InvocationTargetException e)
64 |  |
             {
65 | 0 |
                 Throwable t = e.getTargetException();
66 |  |
67 | 0 |
                 if (t instanceof Exception)
68 |  |
                 {
69 | 0 |
                     throw (Exception) t;
70 |  |
                 }
71 |  |
72 | 0 |
                 throw e;
73 |  |
             }
74 |  |
         }
75 |  |
     }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.