[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. |
---|
[837] | 14 | |
---|
[922] | 15 | package de.ugoe.cs.autoquest.plugin.mfc; |
---|
[619] | 16 | |
---|
| 17 | import java.util.ArrayList; |
---|
| 18 | import java.util.List; |
---|
| 19 | |
---|
| 20 | import org.jdom.Element; |
---|
| 21 | import org.jdom.Namespace; |
---|
| 22 | |
---|
[922] | 23 | import de.ugoe.cs.autoquest.plugin.mfc.eventcore.WindowsMessageType; |
---|
[619] | 24 | |
---|
| 25 | /** |
---|
| 26 | * <p> |
---|
[837] | 27 | * This class defines rules for the generation of MFC events. |
---|
[619] | 28 | * </p> |
---|
| 29 | * |
---|
[837] | 30 | * @version 1.0 |
---|
| 31 | * @author Steffen Herbold, Patrick Harms |
---|
[619] | 32 | */ |
---|
| 33 | class EventGenerationRule { |
---|
| 34 | |
---|
| 35 | /** |
---|
| 36 | * <p> |
---|
[837] | 37 | * Namespace used for parsing the rule. |
---|
[619] | 38 | * </p> |
---|
| 39 | */ |
---|
| 40 | private Namespace namespace; |
---|
| 41 | |
---|
| 42 | /** |
---|
| 43 | * <p> |
---|
[837] | 44 | * Name of the rule. |
---|
[619] | 45 | * </p> |
---|
| 46 | */ |
---|
| 47 | private String name; |
---|
| 48 | |
---|
| 49 | /** |
---|
| 50 | * <p> |
---|
[837] | 51 | * List of conditions for the rule to be matched. |
---|
[619] | 52 | * </p> |
---|
| 53 | */ |
---|
| 54 | private List<MessageCondition> messageConditions; |
---|
| 55 | |
---|
| 56 | /** |
---|
| 57 | * <p> |
---|
[837] | 58 | * List of parameters to be provided to the generated event. |
---|
[619] | 59 | * </p> |
---|
| 60 | */ |
---|
| 61 | private List<Term> eventParameters; |
---|
| 62 | |
---|
| 63 | /** |
---|
| 64 | * <p> |
---|
[837] | 65 | * List of replay message generation rules. |
---|
[619] | 66 | * </p> |
---|
| 67 | */ |
---|
| 68 | private List<ReplayMessageSpec> replayMessageSpecifications; |
---|
| 69 | |
---|
| 70 | /** |
---|
| 71 | * <p> |
---|
[837] | 72 | * Constructor. Creates a new EventGenerationRule. |
---|
[619] | 73 | * </p> |
---|
[837] | 74 | * |
---|
[619] | 75 | * @param ruleElement |
---|
[837] | 76 | * the JDOM element that descripes the rule |
---|
| 77 | * @param rulesNamespace |
---|
| 78 | * the XML namespace the rule is defined in |
---|
[619] | 79 | */ |
---|
| 80 | @SuppressWarnings("unchecked") |
---|
| 81 | EventGenerationRule(Element ruleElement, Namespace rulesNamespace) { |
---|
| 82 | this.namespace = rulesNamespace; |
---|
[837] | 83 | |
---|
[619] | 84 | this.name = ruleElement.getAttributeValue("name"); |
---|
[837] | 85 | |
---|
[619] | 86 | this.messageConditions = new ArrayList<MessageCondition>(); |
---|
| 87 | this.eventParameters = new ArrayList<Term>(); |
---|
| 88 | this.replayMessageSpecifications = new ArrayList<ReplayMessageSpec>(); |
---|
[837] | 89 | |
---|
[619] | 90 | for (Element child : (List<Element>) ruleElement.getChildren()) { |
---|
| 91 | if ("msg".equals(child.getName()) && namespace.equals(child.getNamespace())) { |
---|
| 92 | messageConditions.add(new MessageCondition(child)); |
---|
| 93 | } |
---|
| 94 | else if ("idinfo".equals(child.getName()) && namespace.equals(child.getNamespace())) { |
---|
| 95 | for (Element parameterElements : (List<Element>) child.getChildren()) { |
---|
| 96 | eventParameters.add(new Term(parameterElements)); |
---|
| 97 | } |
---|
| 98 | } |
---|
| 99 | else if ("genMsg".equals(child.getName()) && namespace.equals(child.getNamespace())) { |
---|
| 100 | replayMessageSpecifications.add(new ReplayMessageSpec(child)); |
---|
| 101 | } |
---|
[837] | 102 | else if ("genMsgSeq".equals(child.getName()) && namespace.equals(child.getNamespace())) |
---|
| 103 | { |
---|
[619] | 104 | replayMessageSpecifications.add(new ReplayMessageSpec(child)); |
---|
| 105 | } |
---|
| 106 | else { |
---|
[837] | 107 | throw new IllegalArgumentException( |
---|
| 108 | "the provided rules can not be parsed: unknown element " + |
---|
| 109 | child.getName()); |
---|
[619] | 110 | } |
---|
| 111 | } |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | /** |
---|
[837] | 115 | * <p> |
---|
| 116 | * Returns the name of the rule. |
---|
| 117 | * </p> |
---|
| 118 | * |
---|
[619] | 119 | * @return the name |
---|
| 120 | */ |
---|
| 121 | String getName() { |
---|
| 122 | return name; |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | /** |
---|
| 126 | * <p> |
---|
[837] | 127 | * Returns the conditions on the matched messages defined by this rule. |
---|
[619] | 128 | * </p> |
---|
[837] | 129 | * |
---|
| 130 | * @return the message conditions |
---|
[619] | 131 | */ |
---|
| 132 | List<MessageCondition> getMessageConditions() { |
---|
| 133 | return messageConditions; |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | /** |
---|
| 137 | * <p> |
---|
[837] | 138 | * Returns the parameters of the event generated by this rule. |
---|
[619] | 139 | * </p> |
---|
[837] | 140 | * |
---|
| 141 | * @return the event parameters |
---|
[619] | 142 | */ |
---|
| 143 | List<Term> getEventParameters() { |
---|
| 144 | return eventParameters; |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | /** |
---|
| 148 | * <p> |
---|
[837] | 149 | * Returns the replay specification defined by this rule. |
---|
[619] | 150 | * </p> |
---|
[837] | 151 | * |
---|
| 152 | * @return the replay specification |
---|
[619] | 153 | */ |
---|
| 154 | List<ReplayMessageSpec> getReplayMessageSpecifications() { |
---|
| 155 | return replayMessageSpecifications; |
---|
| 156 | } |
---|
| 157 | |
---|
| 158 | /** |
---|
| 159 | * <p> |
---|
[837] | 160 | * Helper class that describes conditions on the message sequence when matching this rule. |
---|
[619] | 161 | * </p> |
---|
| 162 | * |
---|
[837] | 163 | * @version 1.0 |
---|
| 164 | * @author Steffen Herbold, Patrick Harms |
---|
[619] | 165 | */ |
---|
| 166 | class MessageCondition { |
---|
| 167 | |
---|
| 168 | /** |
---|
| 169 | * <p> |
---|
[837] | 170 | * True, if the condition defines to match several conditions |
---|
[619] | 171 | * </p> |
---|
| 172 | */ |
---|
| 173 | private boolean matchMultiple; |
---|
[837] | 174 | |
---|
[619] | 175 | /** |
---|
| 176 | * <p> |
---|
[837] | 177 | * Type of the message matched by the condition |
---|
[619] | 178 | * </p> |
---|
| 179 | */ |
---|
| 180 | private WindowsMessageType messageType; |
---|
| 181 | |
---|
| 182 | /** |
---|
| 183 | * <p> |
---|
[837] | 184 | * Term conditions associated with the rule condition |
---|
[619] | 185 | * </p> |
---|
| 186 | */ |
---|
| 187 | private List<AttributeCondition> attributeConditions; |
---|
| 188 | |
---|
| 189 | /** |
---|
| 190 | * <p> |
---|
[837] | 191 | * List of messages to be stored, if the message matches, for continuing the rule |
---|
| 192 | * application |
---|
[619] | 193 | * </p> |
---|
| 194 | */ |
---|
| 195 | private ArrayList<Term> messagesToStore; |
---|
| 196 | |
---|
| 197 | /** |
---|
| 198 | * <p> |
---|
[837] | 199 | * Constructor. Creates a new MessageCondition. |
---|
[619] | 200 | * </p> |
---|
[837] | 201 | * |
---|
[619] | 202 | * @param msgChild |
---|
[837] | 203 | * JDOM element that describes the message condition |
---|
[619] | 204 | */ |
---|
| 205 | @SuppressWarnings("unchecked") |
---|
| 206 | private MessageCondition(Element msgChild) { |
---|
| 207 | this.matchMultiple = "true".equals(msgChild.getAttributeValue("multiple")); |
---|
| 208 | this.messageType = |
---|
| 209 | WindowsMessageType.parseMessageType(msgChild.getAttributeValue("type")); |
---|
[837] | 210 | |
---|
[619] | 211 | this.attributeConditions = new ArrayList<AttributeCondition>(); |
---|
| 212 | for (Element childElement : (List<Element>) msgChild.getChildren("equals", namespace)) { |
---|
| 213 | attributeConditions.add(new AttributeCondition(childElement)); |
---|
| 214 | } |
---|
[837] | 215 | |
---|
[619] | 216 | this.messagesToStore = new ArrayList<Term>(); |
---|
| 217 | for (Element childElement : (List<Element>) msgChild.getChildren("store", namespace)) { |
---|
| 218 | messagesToStore.add(new Term(childElement)); |
---|
| 219 | } |
---|
[837] | 220 | for (Element childElement : (List<Element>) msgChild.getChildren("storeSeq", namespace)) |
---|
[619] | 221 | { |
---|
| 222 | messagesToStore.add(new Term(childElement)); |
---|
| 223 | } |
---|
| 224 | } |
---|
| 225 | |
---|
| 226 | /** |
---|
[837] | 227 | * <p> |
---|
| 228 | * Returns whether a single message is matched to the condition or a whole sequence can be |
---|
| 229 | * matched. |
---|
| 230 | * </p> |
---|
| 231 | * |
---|
| 232 | * @return true if multiple message shall be matched, false if only a single message is |
---|
| 233 | * matched |
---|
[619] | 234 | */ |
---|
| 235 | boolean matchMultiple() { |
---|
| 236 | return matchMultiple; |
---|
| 237 | } |
---|
| 238 | |
---|
| 239 | /** |
---|
| 240 | * <p> |
---|
[837] | 241 | * Returns the type of the matched messages. |
---|
[619] | 242 | * </p> |
---|
[837] | 243 | * |
---|
| 244 | * @return the message type |
---|
[619] | 245 | */ |
---|
| 246 | WindowsMessageType getMessageType() { |
---|
| 247 | return messageType; |
---|
| 248 | } |
---|
| 249 | |
---|
| 250 | /** |
---|
| 251 | * <p> |
---|
[837] | 252 | * Returns the attribute conditions of the message condition. |
---|
[619] | 253 | * </p> |
---|
[837] | 254 | * |
---|
| 255 | * @return the attribute conditions |
---|
[619] | 256 | */ |
---|
| 257 | List<AttributeCondition> getAttributeConditions() { |
---|
| 258 | return attributeConditions; |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | /** |
---|
[837] | 262 | * <p> |
---|
| 263 | * Returns messages, that have eventually been stored as part of the condition. |
---|
| 264 | * </p> |
---|
| 265 | * |
---|
| 266 | * @return the stored messages |
---|
[619] | 267 | */ |
---|
| 268 | ArrayList<Term> getMessagesToStore() { |
---|
| 269 | return messagesToStore; |
---|
| 270 | } |
---|
| 271 | |
---|
| 272 | } |
---|
| 273 | |
---|
| 274 | /** |
---|
| 275 | * <p> |
---|
[837] | 276 | * Helper class that defines attribute conditions for matching messages. |
---|
[619] | 277 | * </p> |
---|
| 278 | * |
---|
[837] | 279 | * @version 1.0 |
---|
| 280 | * @author Steffen Herbold, Patrick Harms |
---|
[619] | 281 | */ |
---|
| 282 | class AttributeCondition { |
---|
| 283 | |
---|
| 284 | /** |
---|
| 285 | * <p> |
---|
[837] | 286 | * Left hand side of the condition. |
---|
[619] | 287 | * </p> |
---|
| 288 | */ |
---|
| 289 | private Term leftHandSide; |
---|
[837] | 290 | |
---|
[619] | 291 | /** |
---|
| 292 | * <p> |
---|
[837] | 293 | * Reft hand side of the condition. |
---|
[619] | 294 | * </p> |
---|
| 295 | */ |
---|
| 296 | private Term rightHandSide; |
---|
| 297 | |
---|
| 298 | /** |
---|
| 299 | * <p> |
---|
[837] | 300 | * Constructor. Creates a new AttributeCondition. |
---|
[619] | 301 | * </p> |
---|
[837] | 302 | * |
---|
| 303 | * @param conditionElement |
---|
| 304 | * JDOM element that describes the condition |
---|
[619] | 305 | */ |
---|
| 306 | private AttributeCondition(Element conditionElement) { |
---|
| 307 | this.leftHandSide = new Term((Element) conditionElement.getChildren().get(0)); |
---|
| 308 | this.rightHandSide = new Term((Element) conditionElement.getChildren().get(1)); |
---|
| 309 | } |
---|
[837] | 310 | |
---|
[619] | 311 | /** |
---|
[837] | 312 | * <p> |
---|
| 313 | * Returns the left hand side of the condition. |
---|
| 314 | * </p> |
---|
| 315 | * |
---|
| 316 | * @return the left hand side |
---|
[619] | 317 | */ |
---|
| 318 | Term getLeftHandSide() { |
---|
| 319 | return leftHandSide; |
---|
| 320 | } |
---|
| 321 | |
---|
| 322 | /** |
---|
[837] | 323 | * <p> |
---|
| 324 | * Returns the right hand side of the condition. |
---|
| 325 | * </p> |
---|
| 326 | * |
---|
| 327 | * @return the right hand side |
---|
[619] | 328 | */ |
---|
| 329 | Term getRightHandSide() { |
---|
| 330 | return rightHandSide; |
---|
| 331 | } |
---|
| 332 | |
---|
| 333 | } |
---|
| 334 | |
---|
| 335 | /** |
---|
| 336 | * <p> |
---|
[837] | 337 | * Helper class that defines terms to define conditions. |
---|
[619] | 338 | * </p> |
---|
| 339 | * |
---|
[837] | 340 | * @version 1.0 |
---|
| 341 | * @author Steffen Herbold, Patrick Harms |
---|
[619] | 342 | */ |
---|
| 343 | class Term { |
---|
| 344 | |
---|
| 345 | /** |
---|
| 346 | * <p> |
---|
[837] | 347 | * Name of the term. |
---|
[619] | 348 | * </p> |
---|
| 349 | */ |
---|
| 350 | private String name; |
---|
[837] | 351 | |
---|
[619] | 352 | /** |
---|
| 353 | * <p> |
---|
[837] | 354 | * Value of the term, if it is a constValue; null otherwise. |
---|
[619] | 355 | * </p> |
---|
| 356 | */ |
---|
| 357 | private String value; |
---|
| 358 | |
---|
| 359 | /** |
---|
| 360 | * <p> |
---|
[837] | 361 | * Variable name of the object, i.e. a message, of which a parameter is identified if the |
---|
| 362 | * term is a winInfoValue or a msgInfoValue; null otherwise. |
---|
[619] | 363 | * </p> |
---|
| 364 | */ |
---|
| 365 | private String messageId; |
---|
| 366 | |
---|
| 367 | /** |
---|
| 368 | * <p> |
---|
[837] | 369 | * Name of the parameter of the object, i.e., a message, of which a parameter is identified |
---|
| 370 | * if the term is a paramValue; null otherwise. |
---|
[619] | 371 | * </p> |
---|
| 372 | */ |
---|
| 373 | private String messageParameterName; |
---|
| 374 | |
---|
| 375 | /** |
---|
| 376 | * <p> |
---|
[837] | 377 | * Variable name of the message sequence denoted by the term in case of a seqValue; null |
---|
| 378 | * otherwise. |
---|
[619] | 379 | * </p> |
---|
| 380 | */ |
---|
| 381 | private String sequenceId; |
---|
| 382 | |
---|
| 383 | /** |
---|
| 384 | * <p> |
---|
[837] | 385 | * Name of the parameter of the sequence of which a parameter is identified if the term is a |
---|
| 386 | * seqValue; null otherwise. |
---|
[619] | 387 | * </p> |
---|
| 388 | */ |
---|
| 389 | private String sequenceParameterName; |
---|
| 390 | |
---|
| 391 | /** |
---|
| 392 | * <p> |
---|
[837] | 393 | * Name of the parameter of the window of the object, e.g. a message, of which a parameter |
---|
| 394 | * is identified if the term is a winInfoValue; null otherwise. |
---|
[619] | 395 | * </p> |
---|
| 396 | */ |
---|
| 397 | private String windowParameterName; |
---|
| 398 | |
---|
| 399 | /** |
---|
| 400 | * <p> |
---|
[837] | 401 | * Name of the info of the message of which a parameter is identified if the term is a |
---|
| 402 | * msgInfoValue; null otherwise. |
---|
[619] | 403 | * </p> |
---|
| 404 | */ |
---|
| 405 | private String messageInfoName; |
---|
| 406 | |
---|
| 407 | /** |
---|
| 408 | * <p> |
---|
[837] | 409 | * Name of the parameter of the message into which a value shall be stored if the term is a |
---|
| 410 | * resolveHwnd, null otherwise |
---|
[619] | 411 | * </p> |
---|
| 412 | */ |
---|
| 413 | private String storeParameterName; |
---|
| 414 | |
---|
| 415 | /** |
---|
| 416 | * <p> |
---|
[837] | 417 | * List of handles to be resolved in case the term is a store or storeSeq; null otherwise. |
---|
[619] | 418 | * </p> |
---|
| 419 | */ |
---|
| 420 | private List<Term> resolveHandles; |
---|
| 421 | |
---|
| 422 | /** |
---|
| 423 | * <p> |
---|
[837] | 424 | * Constructor. Creates a new Term. |
---|
[619] | 425 | * </p> |
---|
[837] | 426 | * |
---|
| 427 | * @param termElement |
---|
| 428 | * JDOM element that describes the term |
---|
[619] | 429 | */ |
---|
| 430 | @SuppressWarnings("unchecked") |
---|
| 431 | private Term(Element termElement) { |
---|
| 432 | this.name = termElement.getName(); |
---|
[837] | 433 | |
---|
[619] | 434 | if ("constValue".equals(name)) { |
---|
| 435 | this.value = termElement.getAttributeValue("value"); |
---|
| 436 | } |
---|
| 437 | else if ("paramValue".equals(name)) { |
---|
| 438 | this.messageId = termElement.getAttributeValue("obj"); |
---|
| 439 | this.messageParameterName = termElement.getAttributeValue("param"); |
---|
| 440 | } |
---|
| 441 | else if ("winInfoValue".equals(name)) { |
---|
| 442 | this.messageId = termElement.getAttributeValue("obj"); |
---|
| 443 | this.windowParameterName = termElement.getAttributeValue("winParam"); |
---|
| 444 | } |
---|
| 445 | else if ("msgInfoValue".equals(name)) { |
---|
| 446 | this.messageId = termElement.getAttributeValue("obj"); |
---|
| 447 | this.messageInfoName = termElement.getAttributeValue("msgParam"); |
---|
| 448 | } |
---|
| 449 | else if ("seqValue".equals(name)) { |
---|
| 450 | this.sequenceId = termElement.getAttributeValue("seqObj"); |
---|
| 451 | this.sequenceParameterName = termElement.getAttributeValue("param"); |
---|
| 452 | } |
---|
| 453 | else if ("store".equals(name)) { |
---|
| 454 | this.messageId = termElement.getAttributeValue("var"); |
---|
| 455 | if ((termElement.getChildren() != null) && (termElement.getChildren().size() > 0)) { |
---|
| 456 | this.resolveHandles = new ArrayList<Term>(); |
---|
| 457 | for (Element child : (List<Element>) termElement.getChildren()) { |
---|
| 458 | this.resolveHandles.add(new Term(child)); |
---|
| 459 | } |
---|
| 460 | } |
---|
| 461 | } |
---|
| 462 | else if ("storeSeq".equals(name)) { |
---|
| 463 | this.sequenceId = termElement.getAttributeValue("varSeq"); |
---|
| 464 | if ((termElement.getChildren() != null) && (termElement.getChildren().size() > 0)) { |
---|
| 465 | this.resolveHandles = new ArrayList<Term>(); |
---|
| 466 | for (Element child : (List<Element>) termElement.getChildren()) { |
---|
| 467 | this.resolveHandles.add(new Term(child)); |
---|
| 468 | } |
---|
| 469 | } |
---|
| 470 | } |
---|
| 471 | else if ("resolveHwnd".equals(name)) { |
---|
| 472 | this.messageParameterName = termElement.getAttributeValue("param"); |
---|
| 473 | this.storeParameterName = termElement.getAttributeValue("storeParam"); |
---|
| 474 | } |
---|
| 475 | } |
---|
| 476 | |
---|
| 477 | /** |
---|
[837] | 478 | * <p> |
---|
| 479 | * Returns the name of the term. |
---|
| 480 | * </p> |
---|
| 481 | * |
---|
[619] | 482 | * @return the name |
---|
| 483 | */ |
---|
| 484 | String getName() { |
---|
| 485 | return name; |
---|
| 486 | } |
---|
| 487 | |
---|
| 488 | /** |
---|
[837] | 489 | * <p> |
---|
| 490 | * Returns the value of the term. |
---|
| 491 | * </p> |
---|
| 492 | * |
---|
[619] | 493 | * @return the value |
---|
| 494 | */ |
---|
| 495 | String getValue() { |
---|
| 496 | return value; |
---|
| 497 | } |
---|
| 498 | |
---|
| 499 | /** |
---|
[837] | 500 | * <p> |
---|
| 501 | * Returns the object Id of the message, which is resolved as part of this term. |
---|
| 502 | * </p> |
---|
| 503 | * |
---|
| 504 | * @return the object Id |
---|
[619] | 505 | */ |
---|
| 506 | String getMessageId() { |
---|
| 507 | return messageId; |
---|
| 508 | } |
---|
| 509 | |
---|
| 510 | /** |
---|
[837] | 511 | * <p> |
---|
| 512 | * Returns the name of the message parameter that is resolved as part of this term. |
---|
| 513 | * </p> |
---|
| 514 | * |
---|
| 515 | * @return the message parameter name |
---|
[619] | 516 | */ |
---|
| 517 | String getMessageParameterName() { |
---|
| 518 | return messageParameterName; |
---|
| 519 | } |
---|
| 520 | |
---|
| 521 | /** |
---|
[837] | 522 | * <p> |
---|
| 523 | * Returns the object Id of the message sequence, which is resolved as part of this term. |
---|
| 524 | * </p> |
---|
| 525 | * |
---|
| 526 | * @return the object Id |
---|
[619] | 527 | */ |
---|
| 528 | String getSequenceId() { |
---|
| 529 | return sequenceId; |
---|
| 530 | } |
---|
| 531 | |
---|
| 532 | /** |
---|
[837] | 533 | * <p> |
---|
| 534 | * Returns the name of the message parameter that is resolved as part of this term. |
---|
| 535 | * </p> |
---|
| 536 | * |
---|
[619] | 537 | * @return the sequenceParameter |
---|
| 538 | */ |
---|
| 539 | String getSequenceParameterName() { |
---|
| 540 | return sequenceParameterName; |
---|
| 541 | } |
---|
| 542 | |
---|
| 543 | /** |
---|
[837] | 544 | * <p> |
---|
| 545 | * Returns the window parameter name that is resolved as part of this term. |
---|
| 546 | * </p> |
---|
| 547 | * |
---|
| 548 | * @return the name of the window parameter |
---|
[619] | 549 | */ |
---|
| 550 | String getWindowParameterName() { |
---|
| 551 | return windowParameterName; |
---|
| 552 | } |
---|
| 553 | |
---|
| 554 | /** |
---|
[837] | 555 | * <p> |
---|
| 556 | * Returns the name of the message info value that is resolved as part of this term. |
---|
| 557 | * </p> |
---|
| 558 | * |
---|
| 559 | * @return the name of the message info value |
---|
[619] | 560 | */ |
---|
| 561 | String getMessageInfoName() { |
---|
| 562 | return messageInfoName; |
---|
| 563 | } |
---|
| 564 | |
---|
| 565 | /** |
---|
[837] | 566 | * <p> |
---|
| 567 | * Returns the object Id under which a message will be stored. |
---|
| 568 | * </p> |
---|
| 569 | * |
---|
| 570 | * @return the object Id |
---|
[619] | 571 | */ |
---|
| 572 | String getStoreParameterName() { |
---|
| 573 | return storeParameterName; |
---|
| 574 | } |
---|
| 575 | |
---|
| 576 | /** |
---|
[837] | 577 | * <p> |
---|
| 578 | * Returns all terms that are responsible to resolve HWNDs. |
---|
| 579 | * </p> |
---|
| 580 | * |
---|
| 581 | * @return the terms |
---|
[619] | 582 | */ |
---|
| 583 | List<Term> getResolveHandles() { |
---|
| 584 | return resolveHandles; |
---|
| 585 | } |
---|
| 586 | |
---|
| 587 | } |
---|
[837] | 588 | |
---|
[619] | 589 | /** |
---|
| 590 | * <p> |
---|
[837] | 591 | * Helper class that defines the replay specification part of rules. |
---|
[619] | 592 | * </p> |
---|
| 593 | * |
---|
[837] | 594 | * @version 1.0 |
---|
| 595 | * @author Steffen Herbold, Patrick Harms |
---|
[619] | 596 | */ |
---|
| 597 | class ReplayMessageSpec { |
---|
| 598 | |
---|
| 599 | /** |
---|
| 600 | * <p> |
---|
[837] | 601 | * Determines if this specification defines one, or a sequence of messages. |
---|
[619] | 602 | * </p> |
---|
| 603 | */ |
---|
| 604 | private boolean generateSingleMessage; |
---|
[837] | 605 | |
---|
[619] | 606 | /** |
---|
| 607 | * <p> |
---|
[837] | 608 | * Object Id of a concrete message of message sequence to be replayed as is. |
---|
[619] | 609 | * </p> |
---|
| 610 | */ |
---|
| 611 | private String replayObjectId; |
---|
| 612 | |
---|
[837] | 613 | /** |
---|
| 614 | * <p> |
---|
| 615 | * Term describing the type of the generated message. |
---|
| 616 | * </p> |
---|
| 617 | */ |
---|
[619] | 618 | private Term type; |
---|
| 619 | |
---|
[837] | 620 | /** |
---|
| 621 | * <p> |
---|
| 622 | * Term describing the target of the generated message. |
---|
| 623 | * </p> |
---|
| 624 | */ |
---|
[619] | 625 | private Term target; |
---|
| 626 | |
---|
[837] | 627 | /** |
---|
| 628 | * <p> |
---|
| 629 | * Term describing the LO word of the LParam of the generated message. |
---|
| 630 | * </p> |
---|
| 631 | */ |
---|
[619] | 632 | private Term lparamLoWord; |
---|
| 633 | |
---|
[837] | 634 | /** |
---|
| 635 | * <p> |
---|
| 636 | * Term describing the HI word of the LParam of the generated message. |
---|
| 637 | * </p> |
---|
| 638 | */ |
---|
[619] | 639 | private Term lparamHiWord; |
---|
| 640 | |
---|
[837] | 641 | /** |
---|
| 642 | * <p> |
---|
| 643 | * Term describing the LParam of the generated message. |
---|
| 644 | * </p> |
---|
| 645 | */ |
---|
[619] | 646 | private Term lparam; |
---|
| 647 | |
---|
[837] | 648 | /** |
---|
| 649 | * <p> |
---|
| 650 | * Term describing the LO word of the WParam of the generated message. |
---|
| 651 | * </p> |
---|
| 652 | */ |
---|
[619] | 653 | private Term wparamLoWord; |
---|
| 654 | |
---|
[837] | 655 | /** |
---|
| 656 | * <p> |
---|
| 657 | * Term describing the HI word of the WParam of the generated message. |
---|
| 658 | * </p> |
---|
| 659 | */ |
---|
[619] | 660 | private Term wparamHiWord; |
---|
| 661 | |
---|
[837] | 662 | /** |
---|
| 663 | * <p> |
---|
| 664 | * Term describing the WParam of the generated message. |
---|
| 665 | * </p> |
---|
| 666 | */ |
---|
[619] | 667 | private Term wparam; |
---|
| 668 | |
---|
[837] | 669 | /** |
---|
| 670 | * <p> |
---|
| 671 | * Value in milliseconds that the replay waits until the the next message is replayed. |
---|
| 672 | * </p> |
---|
| 673 | */ |
---|
[619] | 674 | private int delay; |
---|
[837] | 675 | |
---|
[619] | 676 | /** |
---|
| 677 | * <p> |
---|
[837] | 678 | * Constructor. Creates a new ReplayMessageSpec. |
---|
[619] | 679 | * </p> |
---|
[837] | 680 | * |
---|
| 681 | * @param replayMessageSpecElement |
---|
| 682 | * JDOM element that describes the replay message specification |
---|
[619] | 683 | */ |
---|
| 684 | @SuppressWarnings("unchecked") |
---|
| 685 | private ReplayMessageSpec(Element replayMessageSpecElement) { |
---|
| 686 | List<Element> children = replayMessageSpecElement.getChildren(); |
---|
| 687 | if ("genMsg".equals(replayMessageSpecElement.getName())) { |
---|
| 688 | generateSingleMessage = true; |
---|
| 689 | if (children.size() == 1) { |
---|
| 690 | replayObjectId = children.get(0).getAttributeValue("obj"); |
---|
| 691 | } |
---|
| 692 | } |
---|
| 693 | else { |
---|
| 694 | generateSingleMessage = false; |
---|
| 695 | if (children.size() == 1) { |
---|
| 696 | replayObjectId = children.get(0).getAttributeValue("seqObj"); |
---|
| 697 | } |
---|
| 698 | } |
---|
[837] | 699 | |
---|
[619] | 700 | this.delay = Integer.parseInt(replayMessageSpecElement.getAttributeValue("delay")); |
---|
[837] | 701 | |
---|
[619] | 702 | if (children.size() > 1) { |
---|
| 703 | for (Element child : children) { |
---|
| 704 | Element termElement = (Element) child.getChildren().get(0); |
---|
[837] | 705 | |
---|
[619] | 706 | if (child.getName().equals("type")) { |
---|
| 707 | this.type = new Term(termElement); |
---|
| 708 | } |
---|
| 709 | else if (child.getName().equals("target")) { |
---|
| 710 | this.target = new Term(termElement); |
---|
[837] | 711 | |
---|
[619] | 712 | if (!generateSingleMessage) { |
---|
| 713 | // in this case, the target is always a sequence value term, i.e. |
---|
| 714 | // the targets of the originally recorded sequence. So the |
---|
| 715 | // replay object id is set to this sequence |
---|
| 716 | replayObjectId = target.getSequenceId(); |
---|
| 717 | } |
---|
| 718 | } |
---|
| 719 | else if (child.getName().equals("LPARAM")) { |
---|
| 720 | Element loWordElement = child.getChild("LOWORD", namespace); |
---|
| 721 | if (loWordElement != null) { |
---|
| 722 | this.lparamLoWord = |
---|
| 723 | new Term((Element) loWordElement.getChildren().get(0)); |
---|
| 724 | } |
---|
[837] | 725 | |
---|
[619] | 726 | Element hiWordElement = child.getChild("HIWORD", namespace); |
---|
| 727 | if (hiWordElement != null) { |
---|
| 728 | this.lparamHiWord = |
---|
[837] | 729 | new Term((Element) hiWordElement.getChildren().get(0)); |
---|
[619] | 730 | } |
---|
[837] | 731 | |
---|
[619] | 732 | if ((lparamLoWord == null) && (lparamHiWord == null)) { |
---|
| 733 | this.lparam = new Term(termElement); |
---|
| 734 | } |
---|
| 735 | } |
---|
| 736 | else if (child.getName().equals("WPARAM")) { |
---|
| 737 | Element loWordElement = child.getChild("LOWORD", namespace); |
---|
| 738 | if (loWordElement != null) { |
---|
| 739 | this.wparamLoWord = |
---|
| 740 | new Term((Element) loWordElement.getChildren().get(0)); |
---|
| 741 | } |
---|
[837] | 742 | |
---|
[619] | 743 | Element hiWordElement = child.getChild("HIWORD", namespace); |
---|
| 744 | if (hiWordElement != null) { |
---|
| 745 | this.wparamHiWord = |
---|
[837] | 746 | new Term((Element) hiWordElement.getChildren().get(0)); |
---|
[619] | 747 | } |
---|
[837] | 748 | |
---|
[619] | 749 | if ((wparamLoWord == null) && (wparamHiWord == null)) { |
---|
| 750 | this.wparam = new Term(termElement); |
---|
| 751 | } |
---|
| 752 | } |
---|
| 753 | } |
---|
| 754 | } |
---|
| 755 | } |
---|
| 756 | |
---|
| 757 | /** |
---|
| 758 | * <p> |
---|
[837] | 759 | * Determines if this specification defines one, or a sequence of messages. |
---|
[619] | 760 | * </p> |
---|
[837] | 761 | * |
---|
| 762 | * @return true if only a single message is generated; false if a sequence is generated |
---|
[619] | 763 | */ |
---|
| 764 | boolean generateSingleMessage() { |
---|
| 765 | return generateSingleMessage; |
---|
| 766 | } |
---|
| 767 | |
---|
| 768 | /** |
---|
| 769 | * <p> |
---|
[837] | 770 | * Returns the object Id from which the message is generated. |
---|
[619] | 771 | * </p> |
---|
[837] | 772 | * |
---|
| 773 | * @return the object Id |
---|
[619] | 774 | */ |
---|
| 775 | String getReplayObjectId() { |
---|
| 776 | return replayObjectId; |
---|
| 777 | } |
---|
| 778 | |
---|
| 779 | /** |
---|
[837] | 780 | * <p> |
---|
| 781 | * Returns the term that describes the type of the generated message. |
---|
| 782 | * </p> |
---|
| 783 | * |
---|
| 784 | * @return the type term |
---|
[619] | 785 | */ |
---|
| 786 | Term getType() { |
---|
| 787 | return type; |
---|
| 788 | } |
---|
| 789 | |
---|
| 790 | /** |
---|
[837] | 791 | * <p> |
---|
| 792 | * Returns the term that describes the target of the generated message. |
---|
| 793 | * </p> |
---|
| 794 | * |
---|
| 795 | * @return the target term |
---|
[619] | 796 | */ |
---|
| 797 | Term getTarget() { |
---|
| 798 | return target; |
---|
| 799 | } |
---|
| 800 | |
---|
| 801 | /** |
---|
[837] | 802 | * <p> |
---|
| 803 | * Returns the term that describes the LO word of the LParam of the generated message. |
---|
| 804 | * </p> |
---|
| 805 | * |
---|
| 806 | * @return the LParam LO word term |
---|
[619] | 807 | */ |
---|
| 808 | Term getLparamLoWord() { |
---|
| 809 | return lparamLoWord; |
---|
| 810 | } |
---|
| 811 | |
---|
| 812 | /** |
---|
[837] | 813 | * <p> |
---|
| 814 | * Returns the term that describes the HI word of the LParam of the generated message. |
---|
| 815 | * </p> |
---|
| 816 | * |
---|
| 817 | * @return the LParam HI word term |
---|
[619] | 818 | */ |
---|
| 819 | Term getLparamHiWord() { |
---|
| 820 | return lparamHiWord; |
---|
| 821 | } |
---|
| 822 | |
---|
| 823 | /** |
---|
[837] | 824 | * <p> |
---|
| 825 | * Returns the term that describes the LParam of the generated message. |
---|
| 826 | * </p> |
---|
| 827 | * |
---|
| 828 | * @return the LParam term |
---|
[619] | 829 | */ |
---|
| 830 | Term getLparam() { |
---|
| 831 | return lparam; |
---|
| 832 | } |
---|
| 833 | |
---|
| 834 | /** |
---|
[837] | 835 | * <p> |
---|
| 836 | * Returns the term that describes the LO word of the WParam of the generated message. |
---|
| 837 | * </p> |
---|
| 838 | * |
---|
| 839 | * @return the WParam LO word term |
---|
[619] | 840 | */ |
---|
| 841 | Term getWparamLoWord() { |
---|
| 842 | return wparamLoWord; |
---|
| 843 | } |
---|
| 844 | |
---|
| 845 | /** |
---|
[837] | 846 | * <p> |
---|
| 847 | * Returns the term that describes the HI word of the WParam of the generated message. |
---|
| 848 | * </p> |
---|
| 849 | * |
---|
| 850 | * @return the WParam HI word term |
---|
[619] | 851 | */ |
---|
| 852 | Term getWparamHiWord() { |
---|
| 853 | return wparamHiWord; |
---|
| 854 | } |
---|
| 855 | |
---|
| 856 | /** |
---|
[837] | 857 | * <p> |
---|
| 858 | * Returns the term that describes the WParam of the generated message. |
---|
| 859 | * </p> |
---|
| 860 | * |
---|
| 861 | * @return the WParam term |
---|
[619] | 862 | */ |
---|
| 863 | Term getWparam() { |
---|
| 864 | return wparam; |
---|
| 865 | } |
---|
| 866 | |
---|
| 867 | /** |
---|
[837] | 868 | * <p> |
---|
| 869 | * Returns the delay during the replay after this message is sent. |
---|
| 870 | * </p> |
---|
| 871 | * |
---|
[619] | 872 | * @return the delay |
---|
| 873 | */ |
---|
| 874 | int getDelay() { |
---|
| 875 | return delay; |
---|
| 876 | } |
---|
| 877 | |
---|
| 878 | } |
---|
| 879 | } |
---|