1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.trinidad.component;
20
21 import javax.el.ELContext;
22 import javax.el.MethodExpression;
23 import javax.el.MethodInfo;
24
25 import org.apache.myfaces.trinidad.event.AttributeChangeEvent;
26 import org.apache.myfaces.trinidad.event.AttributeChangeListener;
27
28
29
30
31 public class AttributeChangeTester extends MethodExpression
32 implements AttributeChangeListener
33 {
34 public AttributeChangeTester()
35 {
36 }
37
38 public void processAttributeChange(AttributeChangeEvent event)
39 {
40 if (_methodBindingCalled)
41 throw new IllegalStateException("Method binding called before listener");
42 _listenerCalled = true;
43 }
44
45 public MethodInfo getMethodInfo(ELContext context)
46 {
47 return null;
48 }
49
50 @Override
51 public Object invoke(ELContext context, Object params[])
52 {
53 if (params.length != 1)
54 throw new IllegalStateException("Params not of length 1");
55 if (params[0] == null)
56 throw new IllegalStateException("Event is null");
57 if (!(params[0] instanceof AttributeChangeEvent))
58 throw new IllegalStateException("Event isn't an AttributeChangeEvent");
59
60 _methodBindingCalled = true;
61 return null;
62 }
63
64 public String getExpressionString()
65 {
66 return null;
67 }
68
69 public boolean isLiteralText()
70 {
71 return false;
72 }
73
74 public int hashCode()
75 {
76 return 0;
77 }
78
79 public boolean equals(Object o)
80 {
81 return o == this;
82 }
83
84 public void verify()
85 {
86 if (!_methodBindingCalled)
87 throw new IllegalStateException("Method binding never called");
88
89 if (!_listenerCalled)
90 throw new IllegalStateException("Listener never called");
91 }
92
93 private boolean _methodBindingCalled;
94 private boolean _listenerCalled;
95 }