1 /*
2 * File: WidgetStub.java
3 * Created: 5.11.2006 8:22:42
4 *
5 * Copyright 2006 Michal Burda.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 package net.sf.webmancer.widget;
23
24 import java.util.Vector;
25
26 import net.sf.webmancer.base.Event;
27 import net.sf.webmancer.model.IModelBuilder;
28
29 /**
30 * @author Michal Burda
31 */
32 public class WidgetStub extends AbstractWidget {
33 /**
34 *
35 */
36 private IModelBuilder receivedBuilder;
37
38 /**
39 *
40 */
41 private int buildCalls;
42
43 /**
44 *
45 */
46 private Vector<Event> handledEvents;
47
48 /**
49 *
50 */
51 private Vector<Event> putEvents;
52
53 /**
54 * @param id
55 */
56 public WidgetStub() {
57 super();
58 this.receivedBuilder = null;
59 this.buildCalls = 0;
60 this.handledEvents = new Vector<Event>();
61 this.putEvents = new Vector<Event>();
62 }
63
64 /**
65 * @see net.sf.webmancer.widget.AbstractWidget#build(net.sf.webmancer.model.IModelBuilder)
66 */
67 @Override
68 public void build(final IModelBuilder builder) {
69 this.receivedBuilder = builder;
70 this.buildCalls++;
71 builder.element("test", "widget", this.getBeanName());
72 }
73
74 /**
75 * @see net.sf.webmancer.widget.AbstractWidget#handleEvent(net.sf.webmancer.base.Event)
76 */
77 @Override
78 public void handleEvent(final Event event) {
79 this.handledEvents.add(event);
80 super.handleEvent(event);
81 }
82
83 /**
84 * @see net.sf.webmancer.widget.AbstractWidget#putEvent(net.sf.webmancer.base.Event)
85 */
86 @Override
87 public void putEvent(Event event) {
88 this.putEvents.add(event);
89 }
90
91 /**
92 * @return
93 */
94 public Vector<Event> getHandledEvents() {
95 return this.handledEvents;
96 }
97
98 /**
99 * @return
100 */
101 public IModelBuilder getReceivedBuilder() {
102 return this.receivedBuilder;
103 }
104
105 /**
106 * @return
107 */
108 public int getBuildCalls() {
109 return this.buildCalls;
110 }
111
112 /**
113 * @return
114 */
115 public Vector<Event> getPutEvents() {
116 return this.putEvents;
117 }
118
119
120 }