[927] | 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 | |
---|
[857] | 15 | package de.ugoe.cs.autoquest.htmlmonitor; |
---|
| 16 | |
---|
| 17 | /** |
---|
| 18 | * <p> |
---|
[870] | 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. |
---|
[857] | 23 | * </p> |
---|
| 24 | * |
---|
| 25 | * @author Patrick Harms |
---|
| 26 | */ |
---|
| 27 | class HtmlEvent { |
---|
| 28 | |
---|
| 29 | /** |
---|
[870] | 30 | * infos about the client that caused the event |
---|
[857] | 31 | */ |
---|
| 32 | private HtmlClientInfos clientInfos; |
---|
| 33 | |
---|
| 34 | /** |
---|
[870] | 35 | * the time stamp of the event |
---|
[857] | 36 | */ |
---|
| 37 | private Long time; |
---|
| 38 | |
---|
| 39 | /** |
---|
[1069] | 40 | * the HTML element on which the event was executed |
---|
[857] | 41 | */ |
---|
[1069] | 42 | private HtmlPageElement target; |
---|
[857] | 43 | |
---|
| 44 | /** |
---|
[1069] | 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 | /** |
---|
[870] | 55 | * the type of the event, e.g. onclick |
---|
[857] | 56 | */ |
---|
| 57 | private String eventType; |
---|
| 58 | |
---|
| 59 | /** |
---|
[870] | 60 | * the coordinates of the event, usually an array with two values (x and y) |
---|
[857] | 61 | */ |
---|
| 62 | private Integer[] coordinates; |
---|
| 63 | |
---|
| 64 | /** |
---|
[870] | 65 | * if the event is a key event, the key that was pressed or released |
---|
[857] | 66 | */ |
---|
| 67 | private Integer key; |
---|
| 68 | |
---|
| 69 | /** |
---|
[870] | 70 | * if the event is a scroll event, the resulting position of the scrolled element |
---|
[857] | 71 | */ |
---|
[942] | 72 | private Integer[] scrollPosition; |
---|
[857] | 73 | |
---|
| 74 | /** |
---|
[942] | 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 | /** |
---|
[857] | 80 | * <p> |
---|
[1069] | 81 | * initializes the event with all relevant infos |
---|
[857] | 82 | * </p> |
---|
| 83 | * |
---|
[870] | 84 | * @param clientInfos infos about the client that caused the event |
---|
| 85 | * @param time the time stamp of the event |
---|
[1069] | 86 | * @param target the HTML element on which the event was executed |
---|
[870] | 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 |
---|
[942] | 93 | * @param selectedValue if the event is an on change event, the value to which the changed |
---|
| 94 | * element is changed |
---|
[857] | 95 | */ |
---|
| 96 | HtmlEvent(HtmlClientInfos clientInfos, |
---|
| 97 | Long time, |
---|
[1069] | 98 | HtmlPageElement target, |
---|
[857] | 99 | String eventType, |
---|
| 100 | Integer[] coordinates, |
---|
| 101 | Integer key, |
---|
[942] | 102 | Integer[] scrollPosition, |
---|
| 103 | String selectedValue) |
---|
[857] | 104 | { |
---|
| 105 | this.clientInfos = clientInfos; |
---|
| 106 | this.time = time; |
---|
[1069] | 107 | this.target = target; |
---|
| 108 | this.targetDocument = target.getDocument(); |
---|
| 109 | this.targetDOMPath = target.getDOMPath(); |
---|
[857] | 110 | this.eventType = eventType; |
---|
| 111 | this.coordinates = coordinates; |
---|
| 112 | this.key = key; |
---|
| 113 | this.scrollPosition = scrollPosition; |
---|
[942] | 114 | this.selectedValue = selectedValue; |
---|
[857] | 115 | } |
---|
| 116 | |
---|
| 117 | /** |
---|
[1069] | 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 | /** |
---|
[857] | 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 | /** |
---|
[1069] | 174 | * @return the target |
---|
[857] | 175 | */ |
---|
[1069] | 176 | HtmlPageElement getTarget() { |
---|
| 177 | return target; |
---|
[857] | 178 | } |
---|
| 179 | |
---|
| 180 | /** |
---|
[1069] | 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 | /** |
---|
[857] | 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 | */ |
---|
[942] | 218 | Integer[] getScrollPosition() { |
---|
[857] | 219 | return scrollPosition; |
---|
| 220 | } |
---|
| 221 | |
---|
[942] | 222 | /** |
---|
| 223 | * @return the selectedValue |
---|
| 224 | */ |
---|
| 225 | String getSelectedValue() { |
---|
| 226 | return selectedValue; |
---|
| 227 | } |
---|
| 228 | |
---|
[857] | 229 | } |
---|