- Timestamp:
- 09/09/11 06:23:36 (13 years ago)
- Location:
- trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/windows/data
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/windows/data/WindowTree.java
r157 r171 28 28 * 29 29 * @author Steffen Herbold 30 * @version 1.0 30 31 */ 31 32 public class WindowTree { -
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/windows/data/WindowTreeNode.java
r52 r171 18 18 * 19 19 * @author Steffen Herbold 20 * @version 1.0 20 21 */ 21 22 public class WindowTreeNode { … … 69 70 */ 70 71 private List<WindowTreeNode> children; 71 72 72 73 /** 73 74 * <p> … … 263 264 xmlString = parent.xmlRepresentation(); 264 265 } 265 xmlString += "<window name=\"" + StringTools.xmlEntityReplacement(windowName) + "\" class=\"" 266 + StringTools.xmlEntityReplacement(className) + "\" resourceId=\"" + resourceId + "\" isModal=\"" 267 + isModal + "\"/>"; 266 xmlString += "<window name=\"" 267 + StringTools.xmlEntityReplacement(windowName) + "\" class=\"" 268 + StringTools.xmlEntityReplacement(className) 269 + "\" resourceId=\"" + resourceId + "\" isModal=\"" + isModal 270 + "\"/>"; 268 271 return xmlString; 269 272 } 270 273 274 /** 275 * <p> 276 * Returns the names of the parents and itself separated by dots, e.g., 277 * "GrandParent.Parent.windowName" 278 * </p> 279 * 280 * @return names of the parents separated by dots 281 */ 271 282 public String getParentNames() { 272 283 String parentNames = ""; 273 if (parent != null 274 parentNames = parent.getParentNames() +".";284 if (parent != null) { 285 parentNames = parent.getParentNames() + "."; 275 286 } 276 287 parentNames += windowName; -
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/windows/data/WindowsMessage.java
r141 r171 8 8 import de.ugoe.cs.util.StringTools; 9 9 10 /** 11 * <p> 12 * Contains all informations about a windows message, i.e., all parameters that 13 * are read when a windows message is parsed as well as its target, hwnd, etc. 14 * </p> 15 * 16 * @author Steffen Herbold 17 * @version 1.0 18 * 19 */ 10 20 public class WindowsMessage implements IReplayable { 11 /** 12 * Id for object serialization. 21 22 /** 23 * <p> 24 * Id for object serialization. 25 * </p> 13 26 */ 14 27 private static final long serialVersionUID = 1L; 15 28 29 /** 30 * <p> 31 * Type of the message. 32 * </p> 33 */ 16 34 final int type; 35 36 /** 37 * <p> 38 * Window class of the message target. Default: "" 39 * </p> 40 */ 17 41 private String windowClass = ""; 42 43 /** 44 * <p> 45 * Resource Id of the message target. Default: 0 46 * </p> 47 */ 18 48 private int resourceId = 0; 49 50 /** 51 * <p> 52 * XML representation of the message target. 53 * </p> 54 */ 19 55 private String xmlWindowDescription = ""; 56 57 /** 58 * <p> 59 * String that contains the names of all parent widgets and itself, separated by dots, 60 * e.g., "GrandParent.Parent.self". 61 * </p> 62 */ 20 63 private String parentNames = null; 64 65 /** 66 * <p> 67 * String that contains the window class of the parent widget. 68 * </p> 69 */ 21 70 private String parentClass = null; 22 71 72 /** 73 * <p> 74 * LPARAM of the message. Default: 0 75 * </p> 76 */ 23 77 private long LPARAM = 0; 78 79 /** 80 * <p> 81 * WPARAM of the message. Default: 0 82 * </p> 83 */ 24 84 private long WPARAM = 0; 25 85 86 /** 87 * <p> 88 * If the LPARAM contains a HWND, this string stores the target of the HWND. 89 * </p> 90 */ 26 91 private String LPARAMasWindowDesc = null; 92 93 /** 94 * <p> 95 * If the WPARAM contains a HWND, this string stores the target of the HWND. 96 * </p> 97 */ 27 98 private String WPARAMasWindowDesc = null; 28 99 100 /** 101 * <p> 102 * Delay after sending the messages during a replay. Default: 0 103 * </p> 104 */ 29 105 private int delay = 0; 30 106 107 /** 108 * <p> 109 * A map of all parameters, associated with the message, created during the 110 * parsing of messages from the logs {@code param}-nodes. 111 * </p> 112 */ 31 113 private Map<String, String> params = new HashMap<String, String>(); 32 114 115 /** 116 * <p> 117 * Constructor. Creates a new message with a given message type. 118 * </p> 119 * 120 * @param type 121 * type of the message 122 */ 33 123 public WindowsMessage(int type) { 34 124 this.type = type; 35 125 } 36 126 127 /** 128 * <p> 129 * Adds a parameter to the message. 130 * </p> 131 * 132 * @param type 133 * type descriptor of the parameter 134 * @param value 135 * value of the parameter 136 */ 37 137 public void addParameter(String type, String value) { 38 138 params.put(type, value); … … 44 144 } 45 145 146 /** 147 * <p> 148 * Returns the type of the message. 149 * </p> 150 * 151 * @return type of the message 152 */ 46 153 public int getType() { 47 154 return type; 48 155 } 49 156 157 /** 158 * <p> 159 * Returns the value of a parameter, given its type. If the parameter is not 160 * found, {@code null} is returned. 161 * </p> 162 * 163 * @param type 164 * type of the parameter 165 * @return value of the parameter 166 */ 50 167 public String getParameter(String type) { 51 168 return params.get(type); 52 169 } 53 170 171 /** 172 * <p> 173 * Returns the window class of the message target. 174 * </p> 175 * 176 * @return window class of the message target 177 */ 54 178 public String getWindowClass() { 55 179 return windowClass; 56 180 } 57 181 182 /** 183 * <p> 184 * Returns the HWND the message is addressed to. 185 * </p> 186 * 187 * @return HWND the message is addressed to 188 */ 58 189 public int getHwnd() { 59 190 int hwnd = -1; … … 67 198 } 68 199 200 /** 201 * <p> 202 * Returns the resource Id of the message target. 203 * </p> 204 * 205 * @return resource Id of the message target 206 */ 69 207 public int getWindowResourceId() { 70 208 return resourceId; 71 209 } 72 210 211 /** 212 * <p> 213 * Two {@link WindowsMessage} are equal, if their {@link #type}, 214 * {@link #xmlWindowDescription}, and {@link #params} are equal. 215 * </p> 216 * 217 * @see java.lang.Object#equals(java.lang.Object) 218 */ 73 219 @Override 74 220 public boolean equals(Object other) { 75 if ( other==this) {221 if (other == this) { 76 222 return true; 77 223 } … … 86 232 } 87 233 234 /* 235 * (non-Javadoc) 236 * 237 * @see java.lang.Object#hashCode() 238 */ 88 239 @Override 89 240 public int hashCode() { … … 98 249 } 99 250 251 /** 252 * <p> 253 * Returns a string representation of the message of the form 254 * "msg[target=HWND;type=TYPE]". 255 * </p> 256 * 257 * @see java.lang.Object#toString() 258 */ 100 259 @Override 101 260 public String toString() { … … 104 263 } 105 264 265 /** 266 * <p> 267 * Retrieves the target string of a message from a given {@link WindowTree} 268 * through looking up the HWND the message is addressed to in the window 269 * tree. 270 * </p> 271 * 272 * @param windowTree 273 * {@link WindowTree} from which the target is extracted 274 * @throws InvalidParameterException 275 * thrown if HWND is not contained in windowTree 276 */ 106 277 public void setTarget(WindowTree windowTree) 107 278 throws InvalidParameterException { … … 117 288 parentNames = node.getParentNames(); 118 289 WindowTreeNode parent = node.getParent(); 119 if ( parent==null) {290 if (parent == null) { 120 291 parentClass = ""; 121 292 } else { … … 125 296 } 126 297 298 /** 299 * <p> 300 * Sets the LPARAM of a message. 301 * </p> 302 * 303 * @param paramValue 304 * value of the LPARAM 305 */ 127 306 public void setLPARAM(long paramValue) { 128 307 LPARAM = paramValue; 129 308 } 130 309 310 /** 311 * <p> 312 * Sets the WPARAM of a message. 313 * </p> 314 * 315 * @param paramValue 316 * value of the WPARAM 317 */ 131 318 public void setWPARAM(long paramValue) { 132 319 WPARAM = paramValue; 133 320 } 134 321 322 /** 323 * <p> 324 * Returns the LPARAM of a message. 325 * </p> 326 * 327 * @return LPARAM of the message 328 */ 135 329 public long getLPARAM() { 136 330 return LPARAM; 137 331 } 138 332 333 /** 334 * <p> 335 * Returns the WPARAM of a message. 336 * </p> 337 * 338 * @return WPARAM of the message 339 */ 139 340 public long getWPARAM() { 140 341 return WPARAM; 141 342 } 142 343 344 /** 345 * <p> 346 * If the LPARAM contains a HWND, this function can be used to set a target 347 * string to identify the HWND at run-time. 348 * </p> 349 * 350 * @param windowDesc 351 * target string 352 */ 143 353 public void setLPARAMasWindowDesc(String windowDesc) { 144 354 LPARAMasWindowDesc = windowDesc; 145 355 } 146 356 357 /** 358 * <p> 359 * If the WPARAM contains a HWND, this function can be used to set a target 360 * string to identify the HWND at run-time. 361 * </p> 362 * 363 * @param windowDesc 364 * target string 365 */ 147 366 public void setWPARAMasWindowDesc(String windowDesc) { 148 367 WPARAMasWindowDesc = windowDesc; 149 368 } 150 369 370 /** 371 * <p> 372 * If the LPARAM contains a HWND and the target string for the HWND is set, 373 * this function returns the target string. Otherwise, {@code null} is 374 * returned. 375 * </p> 376 * 377 * @return target string if available; {@code null} otherwise 378 */ 151 379 public String getLPARAMasWindowDesc() { 152 380 return LPARAMasWindowDesc; 153 381 } 154 382 383 /** 384 * <p> 385 * If the WPARAM contains a HWND and the target string for the HWND is set, 386 * this function returns the target string. Otherwise, {@code null} is 387 * returned. 388 * </p> 389 * 390 * @return target string if available; {@code null} otherwise 391 */ 155 392 public String getWPARAMasWindowDesc() { 156 393 return WPARAMasWindowDesc; 157 394 } 158 395 396 /** 397 * <p> 398 * Returns the target string of the message. 399 * </p> 400 * 401 * @return target string of the message 402 */ 159 403 public String getXmlWindowDescription() { 160 404 return xmlWindowDescription; 161 405 } 162 406 407 /** 408 * <p> 409 * Sets the target string manually. 410 * </p> 411 * 412 * @param xmlWindowDescription 413 * target string 414 */ 163 415 public void setXmlWindowDescription(String xmlWindowDescription) { 164 416 this.xmlWindowDescription = xmlWindowDescription; 165 417 } 166 418 419 /** 420 * <p> 421 * Returns the delay after this message during replays. 422 * </p> 423 * 424 * @return delay after this message 425 */ 167 426 public int getDelay() { 168 427 return delay; 169 428 } 170 429 430 /** 431 * <p> 432 * Sets the delay after this message during replays. 433 * </p> 434 * 435 * @param delay 436 * delay after this message 437 */ 171 438 public void setDelay(int delay) { 172 439 this.delay = delay; 173 440 } 174 441 442 /** 443 * <p> 444 * Returns the parent names separated by dots, e.g., "GrandParent.Parent". 445 * </p> 446 * 447 * @return names of the parents 448 */ 175 449 public String getParentNames() { 176 450 return parentNames; 177 451 } 178 452 453 /** 454 * <p> 455 * Returns the window class of the parent. 456 * </p> 457 * 458 * @return window classes of the parents 459 */ 179 460 public String getParentClass() { 180 461 return parentClass; 181 462 } 182 463 464 /** 465 * <p> 466 * Returns the number of parameters stored together with this message. 467 * </p> 468 * 469 * @return 470 */ 183 471 public int getNumParams() { 184 472 return params.size(); 185 473 } 186 474 475 /* 476 * (non-Javadoc) 477 * 478 * @see de.ugoe.cs.eventbench.data.IReplayable#getReplay() 479 */ 480 @Override 187 481 public String getReplay() { 188 482 StringBuilder currentMsgStr = new StringBuilder(400); 189 currentMsgStr.append(" <msg type=\"" +type+"\" ");190 currentMsgStr.append("LPARAM=\"" +LPARAM+"\" ");191 currentMsgStr.append("WPARAM=\"" +WPARAM+"\" ");192 currentMsgStr.append("delay=\"" +delay+"\">");193 if ( LPARAMasWindowDesc!=null) {483 currentMsgStr.append(" <msg type=\"" + type + "\" "); 484 currentMsgStr.append("LPARAM=\"" + LPARAM + "\" "); 485 currentMsgStr.append("WPARAM=\"" + WPARAM + "\" "); 486 currentMsgStr.append("delay=\"" + delay + "\">"); 487 if (LPARAMasWindowDesc != null) { 194 488 currentMsgStr.append(StringTools.ENDLINE); 195 489 currentMsgStr.append(" <LPARAM>"); … … 198 492 currentMsgStr.append(StringTools.ENDLINE); 199 493 currentMsgStr.append("</LPARAM>"); 200 } 201 if ( WPARAMasWindowDesc!=null) {494 } 495 if (WPARAMasWindowDesc != null) { 202 496 currentMsgStr.append(StringTools.ENDLINE); 203 497 currentMsgStr.append(" <WPARAM>"); … … 214 508 return currentMsgStr.toString(); 215 509 } 216 510 511 /* 512 * (non-Javadoc) 513 * 514 * @see de.ugoe.cs.eventbench.data.IReplayable#getTarget() 515 */ 516 @Override 217 517 public String getTarget() { 218 518 return xmlWindowDescription;
Note: See TracChangeset
for help on using the changeset viewer.