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