1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.jexl.util;
18
19 import java.lang.reflect.InvocationTargetException;
20
21 import org.apache.commons.logging.Log;
22
23
24 /***
25 * Executor that simply tries to execute a get(key)
26 * operation. This will try to find a get(key) method
27 * for any type of object, not just objects that
28 * implement the Map interface as was previously
29 * the case.
30 *
31 * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
32 * @version $Id: GetExecutor.java,v 1.4 2004/02/28 13:45:21 yoavs Exp $
33 */
34 public class GetExecutor extends AbstractExecutor
35 {
36 /***
37 * Container to hold the 'key' part of
38 * get(key).
39 */
40 private Object[] args = new Object[1];
41
42 /***
43 * Default constructor.
44 */
45 public GetExecutor(Log r, org.apache.commons.jexl.util.introspection.Introspector ispect, Class c, String key)
46 throws Exception
47 {
48 rlog = r;
49 args[0] = key;
50 method = ispect.getMethod(c, "get", args);
51 }
52
53 /***
54 * Execute method against context.
55 */
56 public Object execute(Object o)
57 throws IllegalAccessException, InvocationTargetException
58 {
59 if (method == null)
60 return null;
61
62 return method.invoke(o, args);
63 }
64
65 }
66
67
68
69
70
71
72
73
74