source: trunk/autoquest-htmlmonitor/src/main/java/de/ugoe/cs/autoquest/htmlmonitor/HtmlEvent.java @ 1174

Last change on this file since 1174 was 1069, checked in by pharms, 11 years ago
  • support of new HTML logging format
File size: 6.7 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.htmlmonitor;
16
17/**
18 * <p>
19 * represents an event caused by a user on a specific web site. An event contains the infos
20 * about the client ({@link HtmlClientInfos}, when ant where the event took place, the type of
21 * event and some additional infos such as the event coordinates or the number of the pressed
22 * key.
23 * </p>
24 *
25 * @author Patrick Harms
26 */
27class HtmlEvent {
28
29    /**
30     * infos about the client that caused the event
31     */
32    private HtmlClientInfos clientInfos;
33
34    /**
35     * the time stamp of the event
36     */
37    private Long time;
38
39    /**
40     * the HTML element on which the event was executed
41     */
42    private HtmlPageElement target;
43
44    /**
45     * the document to which the HTML element on which the event was executed belongs
46     */
47    private HtmlDocument targetDocument;
48
49    /**
50     * the targets DOM path through the document to which it belongs
51     */
52    private String targetDOMPath;
53
54    /**
55     * the type of the event, e.g. onclick
56     */
57    private String eventType;
58
59    /**
60     * the coordinates of the event, usually an array with two values (x and y)
61     */
62    private Integer[] coordinates;
63
64    /**
65     * if the event is a key event, the key that was pressed or released
66     */
67    private Integer key;
68
69    /**
70     * if the event is a scroll event, the resulting position of the scrolled element
71     */
72    private Integer[] scrollPosition;
73
74    /**
75     * if the event is an on change event, the value to which the changed element is changed
76     */
77    private String selectedValue;
78
79    /**
80     * <p>
81     * initializes the event with all relevant infos
82     * </p>
83     *
84     * @param clientInfos    infos about the client that caused the event
85     * @param time           the time stamp of the event
86     * @param target         the HTML element on which the event was executed
87     * @param eventType      the type of the event, e.g. onclick
88     * @param coordinates    the coordinates of the event, usually an array with two values
89     *                       (x and y)
90     * @param key            if the event is a key event, the key that was pressed or released
91     * @param scrollPosition if the event is a scroll event, the resulting position of the
92     *                       scrolled element
93     * @param selectedValue  if the event is an on change event, the value to which the changed
94     *                       element is changed
95     */
96    HtmlEvent(HtmlClientInfos clientInfos,
97              Long            time,
98              HtmlPageElement target,
99              String          eventType,
100              Integer[]       coordinates,
101              Integer         key,
102              Integer[]       scrollPosition,
103              String          selectedValue)
104    {
105        this.clientInfos = clientInfos;
106        this.time = time;
107        this.target = target;
108        this.targetDocument = target.getDocument();
109        this.targetDOMPath = target.getDOMPath();
110        this.eventType = eventType;
111        this.coordinates = coordinates;
112        this.key = key;
113        this.scrollPosition = scrollPosition;
114        this.selectedValue = selectedValue;
115    }
116
117    /**
118     * <p>
119     * initializes the event for which the id of the target is not known yet. In this case
120     * the document and DOM path for the target are provided
121     * </p>
122     *
123     * @param clientInfos    infos about the client that caused the event
124     * @param time           the time stamp of the event
125     * @param targetDocument the document to which the HTML element belongs on which the event was
126     *                       executed
127     * @param targetDOMPath  the path through the DOM of the document of the HTML element on which
128     *                       the event was executed
129     * @param eventType      the type of the event, e.g. onclick
130     * @param coordinates    the coordinates of the event, usually an array with two values
131     *                       (x and y)
132     * @param key            if the event is a key event, the key that was pressed or released
133     * @param scrollPosition if the event is a scroll event, the resulting position of the
134     *                       scrolled element
135     * @param selectedValue  if the event is an on change event, the value to which the changed
136     *                       element is changed
137     */
138    HtmlEvent(HtmlClientInfos clientInfos,
139              Long            time,
140              HtmlDocument    targetDocument,
141              String          targetDOMPath,
142              String          eventType,
143              Integer[]       coordinates,
144              Integer         key,
145              Integer[]       scrollPosition,
146              String          selectedValue)
147    {
148        this.clientInfos = clientInfos;
149        this.time = time;
150        this.targetDocument = targetDocument;
151        this.targetDOMPath = targetDOMPath;
152        this.eventType = eventType;
153        this.coordinates = coordinates;
154        this.key = key;
155        this.scrollPosition = scrollPosition;
156        this.selectedValue = selectedValue;
157    }
158
159    /**
160     * @return the clientInfos
161     */
162    HtmlClientInfos getClientInfos() {
163        return clientInfos;
164    }
165
166    /**
167     * @return the time
168     */
169    Long getTime() {
170        return time;
171    }
172
173    /**
174     * @return the target
175     */
176    HtmlPageElement getTarget() {
177        return target;
178    }
179
180    /**
181     * @return the targetDocument
182     */
183    HtmlDocument getTargetDocument() {
184        return targetDocument;
185    }
186
187    /**
188     * @return the targetDOMPath
189     */
190    String getTargetDOMPath() {
191        return targetDOMPath;
192    }
193
194    /**
195     * @return the eventType
196     */
197    String getEventType() {
198        return eventType;
199    }
200
201    /**
202     * @return the coordinates
203     */
204    Integer[] getCoordinates() {
205        return coordinates;
206    }
207
208    /**
209     * @return the key
210     */
211    Integer getKey() {
212        return key;
213    }
214
215    /**
216     * @return the scrollPosition
217     */
218    Integer[] getScrollPosition() {
219        return scrollPosition;
220    }
221
222    /**
223     * @return the selectedValue
224     */
225    String getSelectedValue() {
226        return selectedValue;
227    }
228
229}
Note: See TracBrowser for help on using the repository browser.