Changeset 837 for trunk/quest-plugin-mfc/src/main/java/de/ugoe/cs/quest/plugin/mfc/EventGenerationRule.java
- Timestamp:
- 09/20/12 12:03:03 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-plugin-mfc/src/main/java/de/ugoe/cs/quest/plugin/mfc/EventGenerationRule.java
r655 r837 1 1 2 package de.ugoe.cs.quest.plugin.mfc; 2 3 … … 11 12 /** 12 13 * <p> 13 * T ODO comment14 * This class defines rules for the generation of MFC events. 14 15 * </p> 15 16 * 16 * @version $Revision: $ $Date: 22.08.2012$17 * @author 2012, last modified by $Author: patrick$17 * @version 1.0 18 * @author Steffen Herbold, Patrick Harms 18 19 */ 19 20 class EventGenerationRule { … … 21 22 /** 22 23 * <p> 23 * the namespace used for parsing the rule24 * Namespace used for parsing the rule. 24 25 * </p> 25 26 */ … … 28 29 /** 29 30 * <p> 30 * the name of the rule31 * Name of the rule. 31 32 * </p> 32 33 */ … … 35 36 /** 36 37 * <p> 37 * the list of conditions for the rule to be matched38 * List of conditions for the rule to be matched. 38 39 * </p> 39 40 */ … … 42 43 /** 43 44 * <p> 44 * the list of parameters to be provided to the generated event45 * List of parameters to be provided to the generated event. 45 46 * </p> 46 47 */ … … 49 50 /** 50 51 * <p> 51 * the list of replay message generation rules52 * List of replay message generation rules. 52 53 * </p> 53 54 */ … … 56 57 /** 57 58 * <p> 58 * TODO: comment59 * </p> 60 * 59 * Constructor. Creates a new EventGenerationRule. 60 * </p> 61 * 61 62 * @param ruleElement 62 * @param rulesNamespace 63 * the JDOM element that descripes the rule 64 * @param rulesNamespace 65 * the XML namespace the rule is defined in 63 66 */ 64 67 @SuppressWarnings("unchecked") 65 68 EventGenerationRule(Element ruleElement, Namespace rulesNamespace) { 66 69 this.namespace = rulesNamespace; 67 70 68 71 this.name = ruleElement.getAttributeValue("name"); 69 72 70 73 this.messageConditions = new ArrayList<MessageCondition>(); 71 74 this.eventParameters = new ArrayList<Term>(); 72 75 this.replayMessageSpecifications = new ArrayList<ReplayMessageSpec>(); 73 76 74 77 for (Element child : (List<Element>) ruleElement.getChildren()) { 75 78 if ("msg".equals(child.getName()) && namespace.equals(child.getNamespace())) { … … 84 87 replayMessageSpecifications.add(new ReplayMessageSpec(child)); 85 88 } 86 else if ("genMsgSeq".equals(child.getName()) && namespace.equals(child.getNamespace())) { 89 else if ("genMsgSeq".equals(child.getName()) && namespace.equals(child.getNamespace())) 90 { 87 91 replayMessageSpecifications.add(new ReplayMessageSpec(child)); 88 92 } 89 93 else { 90 throw new IllegalArgumentException 91 ("the provided rules can not be parsed: unknown element " + child.getName()); 94 throw new IllegalArgumentException( 95 "the provided rules can not be parsed: unknown element " + 96 child.getName()); 92 97 } 93 98 } … … 95 100 96 101 /** 102 * <p> 103 * Returns the name of the rule. 104 * </p> 105 * 97 106 * @return the name 98 107 */ … … 103 112 /** 104 113 * <p> 105 * TODO: comment106 * </p> 107 * 108 * @return 114 * Returns the conditions on the matched messages defined by this rule. 115 * </p> 116 * 117 * @return the message conditions 109 118 */ 110 119 List<MessageCondition> getMessageConditions() { … … 114 123 /** 115 124 * <p> 116 * TODO: comment117 * </p> 118 * 119 * @return 125 * Returns the parameters of the event generated by this rule. 126 * </p> 127 * 128 * @return the event parameters 120 129 */ 121 130 List<Term> getEventParameters() { … … 125 134 /** 126 135 * <p> 127 * TODO: comment128 * </p> 129 * 130 * @return 136 * Returns the replay specification defined by this rule. 137 * </p> 138 * 139 * @return the replay specification 131 140 */ 132 141 List<ReplayMessageSpec> getReplayMessageSpecifications() { … … 136 145 /** 137 146 * <p> 138 * TODO comment147 * Helper class that describes conditions on the message sequence when matching this rule. 139 148 * </p> 140 149 * 141 * @version $Revision: $ $Date: 22.08.2012$142 * @author 2012, last modified by $Author: patrick$150 * @version 1.0 151 * @author Steffen Herbold, Patrick Harms 143 152 */ 144 153 class MessageCondition { … … 146 155 /** 147 156 * <p> 148 * true, if the condition defines to match several conditions157 * True, if the condition defines to match several conditions 149 158 * </p> 150 159 */ 151 160 private boolean matchMultiple; 152 153 /** 154 * <p> 155 * the type of the message matched by the condition161 162 /** 163 * <p> 164 * Type of the message matched by the condition 156 165 * </p> 157 166 */ … … 160 169 /** 161 170 * <p> 162 * the term conditions associatewith the rule condition171 * Term conditions associated with the rule condition 163 172 * </p> 164 173 */ … … 167 176 /** 168 177 * <p> 169 * the list of messages to be stored, if the message matches, for continuing the170 * ruleapplication178 * List of messages to be stored, if the message matches, for continuing the rule 179 * application 171 180 * </p> 172 181 */ … … 175 184 /** 176 185 * <p> 177 * TODO: comment178 * </p> 179 * 186 * Constructor. Creates a new MessageCondition. 187 * </p> 188 * 180 189 * @param msgChild 190 * JDOM element that describes the message condition 181 191 */ 182 192 @SuppressWarnings("unchecked") … … 185 195 this.messageType = 186 196 WindowsMessageType.parseMessageType(msgChild.getAttributeValue("type")); 187 197 188 198 this.attributeConditions = new ArrayList<AttributeCondition>(); 189 199 for (Element childElement : (List<Element>) msgChild.getChildren("equals", namespace)) { 190 200 attributeConditions.add(new AttributeCondition(childElement)); 191 201 } 192 202 193 203 this.messagesToStore = new ArrayList<Term>(); 194 204 for (Element childElement : (List<Element>) msgChild.getChildren("store", namespace)) { 195 205 messagesToStore.add(new Term(childElement)); 196 206 } 197 for (Element childElement : 198 (List<Element>) msgChild.getChildren("storeSeq", namespace)) 207 for (Element childElement : (List<Element>) msgChild.getChildren("storeSeq", namespace)) 199 208 { 200 209 messagesToStore.add(new Term(childElement)); … … 203 212 204 213 /** 205 * @return the matchMultiple 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 206 221 */ 207 222 boolean matchMultiple() { … … 211 226 /** 212 227 * <p> 213 * TODO: comment214 * </p> 215 * 216 * @return 228 * Returns the type of the matched messages. 229 * </p> 230 * 231 * @return the message type 217 232 */ 218 233 WindowsMessageType getMessageType() { … … 222 237 /** 223 238 * <p> 224 * TODO: comment225 * </p> 226 * 227 * @return 239 * Returns the attribute conditions of the message condition. 240 * </p> 241 * 242 * @return the attribute conditions 228 243 */ 229 244 List<AttributeCondition> getAttributeConditions() { … … 232 247 233 248 /** 234 * @return the valuesToStore 249 * <p> 250 * Returns messages, that have eventually been stored as part of the condition. 251 * </p> 252 * 253 * @return the stored messages 235 254 */ 236 255 ArrayList<Term> getMessagesToStore() { … … 242 261 /** 243 262 * <p> 244 * TODO comment263 * Helper class that defines attribute conditions for matching messages. 245 264 * </p> 246 265 * 247 * @version $Revision: $ $Date: 22.08.2012$248 * @author 2012, last modified by $Author: patrick$266 * @version 1.0 267 * @author Steffen Herbold, Patrick Harms 249 268 */ 250 269 class AttributeCondition { … … 252 271 /** 253 272 * <p> 254 * the left hand side of the condition273 * Left hand side of the condition. 255 274 * </p> 256 275 */ 257 276 private Term leftHandSide; 258 259 /** 260 * <p> 261 * the left hand side of the condition277 278 /** 279 * <p> 280 * Reft hand side of the condition. 262 281 * </p> 263 282 */ … … 266 285 /** 267 286 * <p> 268 * TODO: comment 269 * </p> 270 * 271 * @param childElement 287 * Constructor. Creates a new AttributeCondition. 288 * </p> 289 * 290 * @param conditionElement 291 * JDOM element that describes the condition 272 292 */ 273 293 private AttributeCondition(Element conditionElement) { … … 275 295 this.rightHandSide = new Term((Element) conditionElement.getChildren().get(1)); 276 296 } 277 278 /** 279 * @return the leftHandSide 297 298 /** 299 * <p> 300 * Returns the left hand side of the condition. 301 * </p> 302 * 303 * @return the left hand side 280 304 */ 281 305 Term getLeftHandSide() { … … 284 308 285 309 /** 286 * @return the rightHandSide 310 * <p> 311 * Returns the right hand side of the condition. 312 * </p> 313 * 314 * @return the right hand side 287 315 */ 288 316 Term getRightHandSide() { … … 294 322 /** 295 323 * <p> 296 * TODO comment324 * Helper class that defines terms to define conditions. 297 325 * </p> 298 326 * 299 * @version $Revision: $ $Date: 22.08.2012$300 * @author 2012, last modified by $Author: patrick$327 * @version 1.0 328 * @author Steffen Herbold, Patrick Harms 301 329 */ 302 330 class Term { … … 304 332 /** 305 333 * <p> 306 * the name of the term334 * Name of the term. 307 335 * </p> 308 336 */ 309 337 private String name; 310 311 /** 312 * <p> 313 * the value of the term, if it is a constValue, null instead338 339 /** 340 * <p> 341 * Value of the term, if it is a constValue; null otherwise. 314 342 * </p> 315 343 */ … … 318 346 /** 319 347 * <p> 320 * the variable name of the object, i.e. a message, of which a parameter is identified if321 * t he term is a winInfoValue or a msgInfoValue; null instead348 * 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. 322 350 * </p> 323 351 */ … … 326 354 /** 327 355 * <p> 328 * the name of the parameter of the object, e.g. a message, of which a parameter is329 * i dentified if the term is a paramValue, null instead356 * 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. 330 358 * </p> 331 359 */ … … 334 362 /** 335 363 * <p> 336 * the variable name of the message sequence denoted by the term in case of a seqValue;337 * null instead364 * Variable name of the message sequence denoted by the term in case of a seqValue; null 365 * otherwise. 338 366 * </p> 339 367 */ … … 342 370 /** 343 371 * <p> 344 * the name of the parameter of the sequence of which a parameter is345 * identified if the term is a seqValue, null instead372 * Name of the parameter of the sequence of which a parameter is identified if the term is a 373 * seqValue; null otherwise. 346 374 * </p> 347 375 */ … … 350 378 /** 351 379 * <p> 352 * the name of the parameter of the window of the object, e.g. a message, of which a353 * parameter is identified if the term is a winInfoValue, null instead380 * 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. 354 382 * </p> 355 383 */ … … 358 386 /** 359 387 * <p> 360 * the name of the info of the message of which a parameter is identified if the361 * term is a msgInfoValue, null instead388 * Name of the info of the message of which a parameter is identified if the term is a 389 * msgInfoValue; null otherwise. 362 390 * </p> 363 391 */ … … 366 394 /** 367 395 * <p> 368 * the name of the parameter of the message into which a value shall be stored if the369 * term is a resolveHwnd, null instead396 * Name of the parameter of the message into which a value shall be stored if the term is a 397 * resolveHwnd, null otherwise 370 398 * </p> 371 399 */ … … 374 402 /** 375 403 * <p> 376 * the list of handles to be resolved in case the term is a store or storeSeq, null instead404 * List of handles to be resolved in case the term is a store or storeSeq; null otherwise. 377 405 * </p> 378 406 */ … … 381 409 /** 382 410 * <p> 383 * TODO: comment 384 * </p> 385 * 386 * @param object 411 * Constructor. Creates a new Term. 412 * </p> 413 * 414 * @param termElement 415 * JDOM element that describes the term 387 416 */ 388 417 @SuppressWarnings("unchecked") 389 418 private Term(Element termElement) { 390 419 this.name = termElement.getName(); 391 420 392 421 if ("constValue".equals(name)) { 393 422 this.value = termElement.getAttributeValue("value"); … … 434 463 435 464 /** 465 * <p> 466 * Returns the name of the term. 467 * </p> 468 * 436 469 * @return the name 437 470 */ … … 441 474 442 475 /** 476 * <p> 477 * Returns the value of the term. 478 * </p> 479 * 443 480 * @return the value 444 481 */ … … 448 485 449 486 /** 450 * @return the object 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 451 492 */ 452 493 String getMessageId() { … … 455 496 456 497 /** 457 * @return the objectParameter 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 458 503 */ 459 504 String getMessageParameterName() { … … 462 507 463 508 /** 464 * @return the sequenceId 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 465 514 */ 466 515 String getSequenceId() { … … 469 518 470 519 /** 520 * <p> 521 * Returns the name of the message parameter that is resolved as part of this term. 522 * </p> 523 * 471 524 * @return the sequenceParameter 472 525 */ … … 476 529 477 530 /** 478 * @return the windowParameter 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 479 536 */ 480 537 String getWindowParameterName() { … … 483 540 484 541 /** 485 * @return the messageParameter 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 486 547 */ 487 548 String getMessageInfoName() { … … 490 551 491 552 /** 492 * @return the storeParameter 553 * <p> 554 * Returns the object Id under which a message will be stored. 555 * </p> 556 * 557 * @return the object Id 493 558 */ 494 559 String getStoreParameterName() { … … 497 562 498 563 /** 499 * @return the resolveHandles 564 * <p> 565 * Returns all terms that are responsible to resolve HWNDs. 566 * </p> 567 * 568 * @return the terms 500 569 */ 501 570 List<Term> getResolveHandles() { … … 504 573 505 574 } 506 507 /** 508 * <p> 509 * TODO comment575 576 /** 577 * <p> 578 * Helper class that defines the replay specification part of rules. 510 579 * </p> 511 580 * 512 * @version $Revision: $ $Date: 22.08.2012$513 * @author 2012, last modified by $Author: patrick$581 * @version 1.0 582 * @author Steffen Herbold, Patrick Harms 514 583 */ 515 584 class ReplayMessageSpec { … … 517 586 /** 518 587 * <p> 519 * determines, if this specification defines one, or a sequence of messages588 * Determines if this specification defines one, or a sequence of messages. 520 589 * </p> 521 590 */ 522 591 private boolean generateSingleMessage; 523 524 /** 525 * <p> 526 * the id of a concrete message of message sequence to be replayed as is592 593 /** 594 * <p> 595 * Object Id of a concrete message of message sequence to be replayed as is. 527 596 * </p> 528 597 */ 529 598 private String replayObjectId; 530 599 600 /** 601 * <p> 602 * Term describing the type of the generated message. 603 * </p> 604 */ 531 605 private Term type; 532 606 607 /** 608 * <p> 609 * Term describing the target of the generated message. 610 * </p> 611 */ 533 612 private Term target; 534 613 614 /** 615 * <p> 616 * Term describing the LO word of the LParam of the generated message. 617 * </p> 618 */ 535 619 private Term lparamLoWord; 536 620 621 /** 622 * <p> 623 * Term describing the HI word of the LParam of the generated message. 624 * </p> 625 */ 537 626 private Term lparamHiWord; 538 627 628 /** 629 * <p> 630 * Term describing the LParam of the generated message. 631 * </p> 632 */ 539 633 private Term lparam; 540 634 635 /** 636 * <p> 637 * Term describing the LO word of the WParam of the generated message. 638 * </p> 639 */ 541 640 private Term wparamLoWord; 542 641 642 /** 643 * <p> 644 * Term describing the HI word of the WParam of the generated message. 645 * </p> 646 */ 543 647 private Term wparamHiWord; 544 648 649 /** 650 * <p> 651 * Term describing the WParam of the generated message. 652 * </p> 653 */ 545 654 private Term wparam; 546 655 656 /** 657 * <p> 658 * Value in milliseconds that the replay waits until the the next message is replayed. 659 * </p> 660 */ 547 661 private int delay; 548 549 /** 550 * <p> 551 * TODO: comment 552 * </p> 553 * 554 * @param child 662 663 /** 664 * <p> 665 * Constructor. Creates a new ReplayMessageSpec. 666 * </p> 667 * 668 * @param replayMessageSpecElement 669 * JDOM element that describes the replay message specification 555 670 */ 556 671 @SuppressWarnings("unchecked") … … 569 684 } 570 685 } 571 686 572 687 this.delay = Integer.parseInt(replayMessageSpecElement.getAttributeValue("delay")); 573 688 574 689 if (children.size() > 1) { 575 690 for (Element child : children) { 576 691 Element termElement = (Element) child.getChildren().get(0); 577 692 578 693 if (child.getName().equals("type")) { 579 694 this.type = new Term(termElement); … … 581 696 else if (child.getName().equals("target")) { 582 697 this.target = new Term(termElement); 583 698 584 699 if (!generateSingleMessage) { 585 700 // in this case, the target is always a sequence value term, i.e. … … 595 710 new Term((Element) loWordElement.getChildren().get(0)); 596 711 } 597 712 598 713 Element hiWordElement = child.getChild("HIWORD", namespace); 599 714 if (hiWordElement != null) { 600 715 this.lparamHiWord = 601 716 new Term((Element) hiWordElement.getChildren().get(0)); 602 717 } 603 718 604 719 if ((lparamLoWord == null) && (lparamHiWord == null)) { 605 720 this.lparam = new Term(termElement); … … 612 727 new Term((Element) loWordElement.getChildren().get(0)); 613 728 } 614 729 615 730 Element hiWordElement = child.getChild("HIWORD", namespace); 616 731 if (hiWordElement != null) { 617 732 this.wparamHiWord = 618 733 new Term((Element) hiWordElement.getChildren().get(0)); 619 734 } 620 735 621 736 if ((wparamLoWord == null) && (wparamHiWord == null)) { 622 737 this.wparam = new Term(termElement); … … 629 744 /** 630 745 * <p> 631 * TODO: comment632 * </p> 633 * 634 * @return 746 * Determines if this specification defines one, or a sequence of messages. 747 * </p> 748 * 749 * @return true if only a single message is generated; false if a sequence is generated 635 750 */ 636 751 boolean generateSingleMessage() { … … 640 755 /** 641 756 * <p> 642 * TODO: comment643 * </p> 644 * 645 * @return 757 * Returns the object Id from which the message is generated. 758 * </p> 759 * 760 * @return the object Id 646 761 */ 647 762 String getReplayObjectId() { … … 650 765 651 766 /** 652 * @return the type 767 * <p> 768 * Returns the term that describes the type of the generated message. 769 * </p> 770 * 771 * @return the type term 653 772 */ 654 773 Term getType() { … … 657 776 658 777 /** 659 * @return the target 778 * <p> 779 * Returns the term that describes the target of the generated message. 780 * </p> 781 * 782 * @return the target term 660 783 */ 661 784 Term getTarget() { … … 664 787 665 788 /** 666 * @return the lparamLoWord 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 667 794 */ 668 795 Term getLparamLoWord() { … … 671 798 672 799 /** 673 * @return the lparamHiWord 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 674 805 */ 675 806 Term getLparamHiWord() { … … 678 809 679 810 /** 680 * @return the lparam 811 * <p> 812 * Returns the term that describes the LParam of the generated message. 813 * </p> 814 * 815 * @return the LParam term 681 816 */ 682 817 Term getLparam() { … … 685 820 686 821 /** 687 * @return the wparamLoWord 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 688 827 */ 689 828 Term getWparamLoWord() { … … 692 831 693 832 /** 694 * @return the wparamHiWord 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 695 838 */ 696 839 Term getWparamHiWord() { … … 699 842 700 843 /** 701 * @return the wparam 844 * <p> 845 * Returns the term that describes the WParam of the generated message. 846 * </p> 847 * 848 * @return the WParam term 702 849 */ 703 850 Term getWparam() { … … 706 853 707 854 /** 855 * <p> 856 * Returns the delay during the replay after this message is sent. 857 * </p> 858 * 708 859 * @return the delay 709 860 */
Note: See TracChangeset
for help on using the changeset viewer.