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 org.apache.commons.logging.Log;
20 /***
21 * Handles discovery and valuation of a
22 * boolean object property, of the
23 * form public boolean is<property> when executed.
24 *
25 * We do this separately as to preserve the current
26 * quasi-broken semantics of get<as is property>
27 * get< flip 1st char> get("property") and now followed
28 * by is<Property>
29 *
30 * @author <a href="geirm@apache.org">Geir Magnusson Jr.</a>
31 * @version $Id: BooleanPropertyExecutor.java,v 1.4 2004/02/28 13:45:21 yoavs Exp $
32 */
33 public class BooleanPropertyExecutor extends PropertyExecutor
34 {
35 public BooleanPropertyExecutor(Log rlog, org.apache.commons.jexl.util.introspection.Introspector is, Class clazz, String property)
36 {
37 super(rlog, is, clazz, property);
38 }
39
40 protected void discover(Class clazz, String property)
41 {
42 try
43 {
44 char c;
45 StringBuffer sb;
46
47 Object[] params = { };
48
49
50
51
52
53 sb = new StringBuffer("is");
54 sb.append(property);
55
56 c = sb.charAt(2);
57
58 if (Character.isLowerCase(c))
59 {
60 sb.setCharAt(2, Character.toUpperCase(c));
61 }
62
63 methodUsed = sb.toString();
64 method = introspector.getMethod(clazz, methodUsed, params);
65
66 if (method != null)
67 {
68
69
70
71
72 if (method.getReturnType() == Boolean.TYPE)
73 return;
74
75 method = null;
76 }
77 }
78 catch(Exception e)
79 {
80 rlog.error("PROGRAMMER ERROR : BooleanPropertyExector() : " + e);
81 }
82 }
83 }