1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.el.convert; |
20 | |
|
21 | |
import javax.el.ELException; |
22 | |
import javax.el.MethodExpression; |
23 | |
import javax.faces.component.StateHolder; |
24 | |
import javax.faces.context.FacesContext; |
25 | |
import javax.faces.el.EvaluationException; |
26 | |
import javax.faces.el.MethodBinding; |
27 | |
import javax.faces.el.MethodNotFoundException; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
public final class MethodExpressionToMethodBinding extends MethodBinding implements StateHolder { |
41 | |
|
42 | |
private MethodExpression methodExpression; |
43 | |
|
44 | 0 | private boolean isTransient = false; |
45 | |
|
46 | 0 | public MethodExpressionToMethodBinding() { |
47 | 0 | methodExpression = null; |
48 | 0 | } |
49 | |
|
50 | |
|
51 | 0 | public MethodExpressionToMethodBinding(final MethodExpression methodExpression) { |
52 | 0 | this.methodExpression = methodExpression; |
53 | 0 | } |
54 | |
|
55 | |
@Override |
56 | |
public String getExpressionString() |
57 | |
{ |
58 | 0 | return methodExpression.getExpressionString(); |
59 | |
} |
60 | |
|
61 | |
public Class getType(FacesContext facesContext) |
62 | |
throws MethodNotFoundException { |
63 | |
|
64 | |
try { |
65 | 0 | return methodExpression.getMethodInfo(facesContext.getELContext()).getReturnType(); |
66 | 0 | } catch (javax.el.MethodNotFoundException e) { |
67 | 0 | throw new javax.faces.el.MethodNotFoundException(e); |
68 | |
} |
69 | |
} |
70 | |
|
71 | |
public Object invoke(final FacesContext facesContext, final Object[] params) |
72 | |
throws EvaluationException, MethodNotFoundException { |
73 | |
|
74 | |
try { |
75 | 0 | return methodExpression.invoke(facesContext.getELContext(), params); |
76 | 0 | } catch (javax.el.MethodNotFoundException e) { |
77 | 0 | throw new javax.faces.el.MethodNotFoundException(e); |
78 | 0 | } catch (ELException e) { |
79 | 0 | throw new EvaluationException(e.getCause()); |
80 | |
} |
81 | |
} |
82 | |
|
83 | |
|
84 | |
|
85 | |
public void restoreState(final FacesContext context, final Object state) { |
86 | 0 | methodExpression = (MethodExpression)state; |
87 | 0 | } |
88 | |
|
89 | |
public Object saveState(final FacesContext context) { |
90 | 0 | return methodExpression; |
91 | |
} |
92 | |
|
93 | |
public void setTransient(final boolean newTransientValue) { |
94 | 0 | isTransient = newTransientValue; |
95 | 0 | } |
96 | |
|
97 | |
public boolean isTransient() { |
98 | 0 | return isTransient; |
99 | |
} |
100 | |
|
101 | |
} |