1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.myfaces.trinidad.event;
20
21 import javax.faces.component.UIComponent;
22 import javax.faces.event.FacesEvent;
23 import javax.faces.event.FacesListener;
24
25 /**
26 * Event delivered when the poll component polls the server.
27 * <p>
28 * @version $Name: $ ($Revision: adfrt/faces/adf-faces-api/src/main/java/oracle/adf/view/faces/event/PollEvent.java#0 $) $Date: 10-nov-2005.19:09:03 $
29 */
30 public class PollEvent extends FacesEvent
31 {
32 public PollEvent(UIComponent source)
33 {
34 super(source);
35 }
36
37 @Override
38 public void processListener(FacesListener listener)
39 {
40 ((PollListener) listener).processPoll(this);
41 }
42
43 @Override
44 public boolean isAppropriateListener(FacesListener listener)
45 {
46 return (listener instanceof PollListener);
47 }
48
49 @Override
50 public int hashCode()
51 {
52 //A simple implementation to differentiate based on component that
53 // fires the event.
54 return (getComponent() == null) ? 0 : getComponent().hashCode();
55 }
56
57 @Override
58 public boolean equals(Object o)
59 {
60 if (o instanceof PollEvent)
61 {
62 PollEvent that = (PollEvent)o;
63 return (this.getComponent().equals(that.getComponent()));
64 }
65
66 return false;
67 }
68
69 @Override
70 public String toString()
71 {
72 StringBuffer sb = new StringBuffer();
73 sb.append(getClass().getName());
74 sb.append("[component=");
75 sb.append(getComponent());
76 sb.append(']');
77 return sb.toString();
78 }
79
80 private static final long serialVersionUID = 1L;
81 }