1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.seasar.teeda.core.el.impl.commons; |
17 | |
|
18 | |
import javax.faces.el.EvaluationException; |
19 | |
import javax.servlet.jsp.el.ELException; |
20 | |
|
21 | |
import org.apache.commons.el.Coercions; |
22 | |
import org.apache.commons.el.Logger; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
public class CoercionsUtil { |
28 | |
|
29 | 1 | private static final org.seasar.framework.log.Logger logger_ = org.seasar.framework.log.Logger |
30 | 1 | .getLogger(CoercionsUtil.class); |
31 | |
|
32 | 0 | private CoercionsUtil() { |
33 | 0 | } |
34 | |
|
35 | |
public static Integer coerceToInteger(Object index) { |
36 | 13 | return coerceToInteger(index, CommonsElLogger.getLogger()); |
37 | |
} |
38 | |
|
39 | |
public static Integer coerceToInteger(Object index, Logger logger) { |
40 | |
try { |
41 | 13 | return Coercions.coerceToInteger(index, logger); |
42 | 0 | } catch (ELException e) { |
43 | 0 | logger_.error(e + " occured at " + CoercionsUtil.class); |
44 | 0 | return null; |
45 | |
} |
46 | |
} |
47 | |
|
48 | |
public static boolean coerceToPrimitiveBoolean(Object value) |
49 | |
throws EvaluationException { |
50 | 6 | return coerceToPrimitiveBoolean(value, CommonsElLogger.getLogger()); |
51 | |
} |
52 | |
|
53 | |
public static boolean coerceToPrimitiveBoolean(Object value, Logger logger) |
54 | |
throws EvaluationException { |
55 | |
try { |
56 | 6 | return Coercions.coerceToBoolean(value, logger).booleanValue(); |
57 | 0 | } catch (ELException e) { |
58 | 0 | throw new EvaluationException(e); |
59 | |
} |
60 | |
} |
61 | |
|
62 | |
public static Object coerce(Object newValue, Class type) |
63 | |
throws EvaluationException { |
64 | |
try { |
65 | 6 | return Coercions |
66 | |
.coerce(newValue, type, CommonsElLogger.getLogger()); |
67 | 0 | } catch (ELException e) { |
68 | 0 | throw new EvaluationException(e); |
69 | |
} |
70 | |
} |
71 | |
|
72 | |
} |