1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package net.sf.asterisk.manager.impl;
18
19 import java.util.ArrayList;
20 import java.util.Collection;
21
22 import net.sf.asterisk.manager.ResponseEvents;
23 import net.sf.asterisk.manager.event.ResponseEvent;
24 import net.sf.asterisk.manager.response.ManagerResponse;
25
26 /***
27 * Implementation of the ResponseEvents interface.
28 *
29 * @author srt
30 * @version $Id: ResponseEventsImpl.java,v 1.1 2005/07/16 21:48:16 srt Exp $
31 * @since 0.2
32 */
33 public class ResponseEventsImpl implements ResponseEvents
34 {
35 private ManagerResponse response;
36 private final Collection events;
37 private boolean complete;
38
39 /***
40 * Creates a new instance.
41 */
42 public ResponseEventsImpl()
43 {
44 this.events = new ArrayList();
45 this.complete = false;
46 }
47
48
49
50 public ManagerResponse getResponse()
51 {
52 return response;
53 }
54
55 public Collection getEvents()
56 {
57 return events;
58 }
59
60 public boolean isComplete()
61 {
62 return complete;
63 }
64
65
66
67 /***
68 * Sets the ManagerResponse received.
69 *
70 * @param response the ManagerResponse received.
71 */
72 public void setRepsonse(ManagerResponse response)
73 {
74 this.response = response;
75 }
76
77 /***
78 * Adds a ResponseEvent that has been received.
79 *
80 * @param event the ResponseEvent that has been received.
81 */
82 public void addEvent(ResponseEvent event)
83 {
84 synchronized (events)
85 {
86 events.add(event);
87 }
88 }
89
90 /***
91 * Indicats if all events have been received.
92 *
93 * @param complete <code>true</code> if all events have been received,
94 * <code>false</code> otherwise.
95 */
96 public void setComplete(boolean complete)
97 {
98 this.complete = complete;
99 }
100 }