1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.view.facelets.el; |
20 | |
|
21 | |
import java.io.Externalizable; |
22 | |
import java.io.IOException; |
23 | |
import java.io.ObjectInput; |
24 | |
import java.io.ObjectOutput; |
25 | |
import javax.el.ELContext; |
26 | |
import javax.el.ELException; |
27 | |
import javax.el.MethodExpression; |
28 | |
import javax.el.MethodInfo; |
29 | |
import javax.el.MethodNotFoundException; |
30 | |
import javax.el.PropertyNotFoundException; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
public class MethodExpressionMethodExpression extends MethodExpression implements Externalizable |
37 | |
{ |
38 | |
|
39 | 0 | private static final Object[] EMPTY_PARAMS = new Object[0]; |
40 | |
|
41 | |
private MethodExpression methodExpressionOneArg; |
42 | |
private MethodExpression methodExpressionZeroArg; |
43 | |
|
44 | |
public MethodExpressionMethodExpression() |
45 | 0 | { |
46 | 0 | } |
47 | |
|
48 | |
public MethodExpressionMethodExpression(MethodExpression methodExpressionOneArg, |
49 | |
MethodExpression methodExpressionZeroArg) |
50 | 0 | { |
51 | 0 | this.methodExpressionOneArg = methodExpressionOneArg; |
52 | 0 | this.methodExpressionZeroArg = methodExpressionZeroArg; |
53 | 0 | } |
54 | |
|
55 | |
@Override |
56 | |
public MethodInfo getMethodInfo(ELContext context) |
57 | |
throws NullPointerException, PropertyNotFoundException, MethodNotFoundException, ELException |
58 | |
{ |
59 | |
try |
60 | |
{ |
61 | |
|
62 | 0 | return methodExpressionOneArg.getMethodInfo(context); |
63 | |
} |
64 | 0 | catch (MethodNotFoundException mnfe) |
65 | |
{ |
66 | |
|
67 | 0 | return methodExpressionZeroArg.getMethodInfo(context); |
68 | |
} |
69 | |
} |
70 | |
|
71 | |
@Override |
72 | |
public Object invoke(ELContext context, Object[] params) |
73 | |
throws NullPointerException, PropertyNotFoundException, MethodNotFoundException, ELException |
74 | |
{ |
75 | |
try |
76 | |
{ |
77 | |
|
78 | 0 | return methodExpressionOneArg.invoke(context, params); |
79 | |
} |
80 | 0 | catch (MethodNotFoundException mnfe) |
81 | |
{ |
82 | |
|
83 | 0 | return methodExpressionZeroArg.invoke(context, EMPTY_PARAMS); |
84 | |
} |
85 | |
} |
86 | |
|
87 | |
@Override |
88 | |
public String getExpressionString() |
89 | |
{ |
90 | |
try |
91 | |
{ |
92 | |
|
93 | 0 | return methodExpressionOneArg.getExpressionString(); |
94 | |
} |
95 | 0 | catch (MethodNotFoundException mnfe) |
96 | |
{ |
97 | |
|
98 | 0 | return methodExpressionZeroArg.getExpressionString(); |
99 | |
} |
100 | |
} |
101 | |
|
102 | |
@Override |
103 | |
public boolean isLiteralText() |
104 | |
{ |
105 | 0 | return false; |
106 | |
} |
107 | |
|
108 | |
public void writeExternal(ObjectOutput out) throws IOException |
109 | |
{ |
110 | 0 | out.writeObject(methodExpressionOneArg); |
111 | 0 | out.writeObject(methodExpressionZeroArg); |
112 | 0 | } |
113 | |
|
114 | |
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException |
115 | |
{ |
116 | 0 | methodExpressionOneArg = (MethodExpression) in.readObject(); |
117 | 0 | methodExpressionZeroArg = (MethodExpression) in.readObject(); |
118 | 0 | } |
119 | |
|
120 | |
@Override |
121 | |
public boolean equals(Object obj) |
122 | |
{ |
123 | 0 | if (obj instanceof MethodExpressionMethodExpression) |
124 | |
{ |
125 | 0 | MethodExpressionMethodExpression me = (MethodExpressionMethodExpression) obj; |
126 | 0 | return methodExpressionOneArg.equals(me.methodExpressionOneArg) && |
127 | |
methodExpressionZeroArg.equals(me.methodExpressionZeroArg); |
128 | |
} |
129 | 0 | return false; |
130 | |
} |
131 | |
|
132 | |
@Override |
133 | |
public int hashCode() |
134 | |
{ |
135 | 0 | int hash = 31; |
136 | 0 | hash = 19 * hash + (this.methodExpressionOneArg != null ? this.methodExpressionOneArg.hashCode() : 0); |
137 | 0 | hash = 19 * hash + (this.methodExpressionZeroArg != null ? this.methodExpressionZeroArg.hashCode() : 0); |
138 | 0 | return hash; |
139 | |
} |
140 | |
} |