View Javadoc
1 /* 2 ContractChecker 3 4 Copyright (C) 2003-2004 Jose San Leandro Armend?riz 5 jsanleandro@yahoo.es 6 chousz@yahoo.com 7 8 This library is free software; you can redistribute it and/or 9 modify it under the terms of the GNU General Public 10 License as published by the Free Software Foundation; either 11 version 2 of the License, or (at your option) any later version. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 General Public License for more details. 17 18 You should have received a copy of the GNU General Public 19 License along with this library; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 22 Thanks to ACM S.L. for distributing this library under the GPL license. 23 Contact info: jsanleandro@yahoo.es 24 Postal Address: c/Playa de Lagoa, 1 25 Urb. Valdecaba?as 26 Boadilla del monte 27 28660 Madrid 28 Spain 29 30 ****************************************************************************** 31 * 32 * Filename: $RCSfile: ContractCheckerAspectTemplate.java,v $ 33 * 34 * Author: Jose San Leandro Armend?riz 35 * 36 * Description: Template to generate AspectJ's aspect to ensure pre- and 37 * post-conditions are satisified. 38 * 39 * Last modified by: $Author: chous $ at $Date: 2004/01/11 19:44:06 $ 40 * 41 * File version: $Revision: 1.8 $ 42 * 43 * Project version: $Name: $ 44 * 45 * $Id: ContractCheckerAspectTemplate.java,v 1.8 2004/01/11 19:44:06 chous Exp $ 46 * 47 */ 48 package org.acmsl.contractchecker; 49 50 /* 51 * Importing some JDK classes. 52 */ 53 import java.util.ArrayList; 54 import java.util.Iterator; 55 import java.util.List; 56 import java.text.MessageFormat; 57 58 /* 59 * Importing Qdox classes. 60 */ 61 import com.thoughtworks.qdox.model.DocletTag; 62 import com.thoughtworks.qdox.model.JavaClass; 63 import com.thoughtworks.qdox.model.JavaMethod; 64 import com.thoughtworks.qdox.model.JavaParameter; 65 66 67 /*** 68 * Template to generate AspectJ's aspect to ensure pre- and 69 * post-conditions are satisfied. 70 * @author <a href="mailto:jsanleandro@yahoo.es" 71 >Jose San Leandro</a> 72 * @version $Revision: 1.8 $ 73 * @testcase test.org.acmsl.contractchecker.TestContractCheckerAspectTemplate 74 */ 75 public abstract class ContractCheckerAspectTemplate 76 { 77 /*** 78 * The default header. 79 */ 80 public static final String DEFAULT_HEADER = 81 "/*\n" 82 + " Contract Checker\n" 83 + "\n" 84 + " Copyright (C) 2003-2004 Jose San Leandro Armend?riz\n" 85 + " jsanleandro@yahoo.es\n" 86 + " chousz@yahoo.com\n" 87 + "\n" 88 + " This library is free software; you can redistribute it and/or\n" 89 + " modify it under the terms of the GNU General Public\n" 90 + " License as published by the Free Software Foundation; either\n" 91 + " version 2 of the License, or (at your option) any later " 92 + "version.\n" 93 + "\n" 94 + " This library is distributed in the hope that it will be " 95 + "useful,\n" 96 + " but WITHOUT ANY WARRANTY; without even the implied warranty " 97 + "of\n" 98 + " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " 99 + "GNU\n" 100 + " General Public License for more details.\n" 101 + "\n" 102 + " You should have received a copy of the GNU General Public\n" 103 + " License along with this library; if not, write to the Free " 104 + "Software\n" 105 + " Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA " 106 + "02111-1307 USA\n" 107 + "\n" 108 + " Thanks to ACM S.L. for distributing this library under the GPL " 109 + "license.\n" 110 + " Contact info: jsanleandro@yahoo.es\n" 111 + " Postal Address: c/Playa de Lagoa, 1\n" 112 + " Urb. Valdecaba?as\n" 113 + " Boadilla del monte\n" 114 + " 28660 Madrid\n" 115 + " Spain\n" 116 + "\n" 117 + " *****************************************************************" 118 + "*************\n" 119 + " *\n" 120 + " * Filename: $" + "RCSfile: $\n" 121 + " *\n" 122 + " * Author: ContractChecker\n" 123 + " *\n" 124 + " * Description: Checks all pre- and post-conditions are\n" 125 + " * satisfied.\n" 126 + " *\n" 127 + " * Last modified by: $" + "Author: $ at $" + "Date: $\n" 128 + " *\n" 129 + " * File version: $" + "Revision: $\n" 130 + " *\n" 131 + " * Project version: $" + "Name: $\n" 132 + " *\n" 133 + " * $" + "Id: $\n" 134 + " *\n" 135 + " */\n"; 136 137 /*** 138 * The default package declaration. 139 */ 140 public static final String DEFAULT_PACKAGE_DECLARATION = 141 "package {0};\n"; // package 142 143 /*** 144 * The default project imports. 145 */ 146 public static final String DEFAULT_PROJECT_IMPORTS_JAVADOC = 147 "\n" 148 + "/*\n" 149 + " * Importing project-specific classes.\n" 150 + " */\n"; 151 152 /*** 153 * The project imports. 154 */ 155 public static final String DEFAULT_PROJECT_IMPORTS = 156 "//import {0};\n"; // class' qualified name 157 158 /*** 159 * The default aspect Javadoc. 160 */ 161 public static final String DEFAULT_ASPECT_JAVADOC = 162 "\n" 163 + "/**\n" 164 + " * Checks all pre- and post-conditions are satisfied.\n" 165 + " * @author <a href=\"http://contractchecker.sourceforge.net\"\n" 166 + " * >ContractChecker</a>\n" 167 + " * @version $" + "Revision: $\n" 168 + " */\n"; 169 170 /*** 171 * The aspect definition. 172 */ 173 public static final String DEFAULT_ASPECT_DEFINITION = 174 "public aspect ContractChecking\n"; 175 176 /*** 177 * The aspect start. 178 */ 179 public static final String DEFAULT_ASPECT_START = "{"; 180 181 /*** 182 * The default precondition pointcut Javadoc. 183 */ 184 public static final String DEFAULT_PRECONDITION_POINTCUT = 185 "\n" 186 + " /**\n" 187 + " * The pointcut to intercept possible precondition violations on\n" 188 + " * {0}.{1}({2})\n" 189 + " * @see {0}#{1}({3})\n" 190 + " */\n" 191 + " pointcut precondition({3}):\n" 192 // method's parameter definition 193 + " call({5} {0}.{1}({4}))\n" 194 // return type - class - method name - parameter types 195 + " && args({2});\n\n"; 196 // parameter names 197 198 /*** 199 * The default exception declarations. 200 */ 201 public static final String DEFAULT_EXCEPTION_DECLARATION = 202 "// declare soft : {0} : precondition({1});\n\n"; 203 204 /*** 205 * The default precondition advice. 206 */ 207 public static final String DEFAULT_PRECONDITION_ADVICE = 208 " /**\n" 209 + " * Before reaching pointcut\n" 210 + " * precondition({0})\n" 211 + " */\n" 212 + " before ({0}) throws {1}: precondition({2})\n" 213 + " '{'\n" 214 + "{3}" 215 + " '}'\n\n"; 216 217 /*** 218 * The default precondition check. 219 */ 220 public static final String DEFAULT_PRECONDITION_CHECK = 221 " if (!({0}))\n" 222 + " '{'\n" 223 + " throw\n" 224 + " new {1}(\n" 225 + " \"Precondition [\"\n" 226 + " + \"{0}\"\n" 227 + " + \"] not satisfied.\");\n" 228 + " '}'\n\n"; 229 230 /*** 231 * The default aspect end. 232 */ 233 public static final String DEFAULT_ASPECT_END = "}\n"; 234 235 /*** 236 * The header. 237 */ 238 private String m__strHeader; 239 240 /*** 241 * The package declaration. 242 */ 243 private String m__strPackageDeclaration; 244 245 /*** 246 * The package name. 247 */ 248 private String m__strPackageName; 249 250 /*** 251 * The default exception. 252 */ 253 private String m__strViolationException; 254 255 /*** 256 * The project import Javadoc. 257 */ 258 private String m__strProjectImportsJavadoc; 259 260 /*** 261 * The project import statements. 262 */ 263 private String m__strProjectImports; 264 265 /*** 266 * The aspect Javadoc. 267 */ 268 private String m__strAspectJavadoc; 269 270 /*** 271 * The aspect definition. 272 */ 273 private String m__strAspectDefinition; 274 275 /*** 276 * The aspect start. 277 */ 278 private String m__strAspectStart; 279 280 /*** 281 * The precondition pointcut. 282 */ 283 private String m__strPreconditionPointcut; 284 285 /*** 286 * The exception declaration. 287 */ 288 private String m__strExceptionDeclaration; 289 290 /*** 291 * The precondition advice. 292 */ 293 private String m__strPreconditionAdvice; 294 295 /*** 296 * The precondition check. 297 */ 298 private String m__strPreconditionCheck; 299 300 /*** 301 * The aspect end. 302 */ 303 private String m__strAspectEnd; 304 305 /*** 306 * The class list. 307 */ 308 private List m__lClasses; 309 310 /*** 311 * Builds a ContractCheckerAspect using given information. 312 * @param header the header. 313 * @param packageDeclaration the package declaration. 314 * @param packageName the package name. 315 * @param defaultException the default exception. 316 * @param projectImportsJavadoc the project imports javadoc. 317 * @param projectImports the project imports. 318 * @param aspectJavadoc the aspect Javadoc. 319 * @param aspectDefinition the aspect definition. 320 * @param aspectStart the aspect start. 321 * @param preconditionPointcut the precondition pointcut. 322 * @param exceptionDeclaration the exception declaration. 323 * @param preconditionAdvice the precondition advice. 324 * @param preconditionCheck the precondition check. 325 * @param aspectEnd the aspect end. 326 */ 327 public ContractCheckerAspectTemplate( 328 String header, 329 String packageDeclaration, 330 String packageName, 331 String defaultException, 332 String projectImportsJavadoc, 333 String projectImports, 334 String aspectJavadoc, 335 String aspectDefinition, 336 String aspectStart, 337 String preconditionPointcut, 338 String exceptionDeclaration, 339 String preconditionAdvice, 340 String preconditionCheck, 341 String aspectEnd) 342 { 343 inmutableSetHeader(header); 344 inmutableSetPackageDeclaration(packageDeclaration); 345 inmutableSetPackageName(packageName); 346 inmutableSetViolationException(defaultException); 347 inmutableSetProjectImportsJavadoc(projectImportsJavadoc); 348 inmutableSetProjectImports(projectImports); 349 inmutableSetAspectJavadoc(aspectJavadoc); 350 inmutableSetAspectDefinition(aspectDefinition); 351 inmutableSetAspectStart(aspectStart); 352 inmutableSetPreconditionPointcut(preconditionPointcut); 353 inmutableSetExceptionDeclaration(exceptionDeclaration); 354 inmutableSetPreconditionAdvice(preconditionAdvice); 355 inmutableSetPreconditionCheck(preconditionCheck); 356 inmutableSetAspectEnd(aspectEnd); 357 } 358 359 /*** 360 * Builds a ContractCheckerAspectTemplate using given information. 361 * @param packageName the package name. 362 * @param defaultException the default exception. 363 */ 364 public ContractCheckerAspectTemplate( 365 String packageName, String defaultException) 366 { 367 this( 368 DEFAULT_HEADER, 369 DEFAULT_PACKAGE_DECLARATION, 370 packageName, 371 defaultException, 372 DEFAULT_PROJECT_IMPORTS_JAVADOC, 373 DEFAULT_PROJECT_IMPORTS, 374 DEFAULT_ASPECT_JAVADOC, 375 DEFAULT_ASPECT_DEFINITION, 376 DEFAULT_ASPECT_START, 377 DEFAULT_PRECONDITION_POINTCUT, 378 DEFAULT_EXCEPTION_DECLARATION, 379 DEFAULT_PRECONDITION_ADVICE, 380 DEFAULT_PRECONDITION_CHECK, 381 DEFAULT_ASPECT_END); 382 } 383 384 /*** 385 * Specifies the header. 386 * @param header the new header. 387 */ 388 private void inmutableSetHeader(String header) 389 { 390 m__strHeader = header; 391 } 392 393 /*** 394 * Specifies the header. 395 * @param header the new header. 396 */ 397 protected void setHeader(String header) 398 { 399 inmutableSetHeader(header); 400 } 401 402 /*** 403 * Retrieves the header. 404 * @return such information. 405 */ 406 public String getHeader() 407 { 408 return m__strHeader; 409 } 410 411 /*** 412 * Specifies the package declaration. 413 * @param packageDeclaration the new package declaration. 414 */ 415 private void inmutableSetPackageDeclaration(String packageDeclaration) 416 { 417 m__strPackageDeclaration = packageDeclaration; 418 } 419 420 /*** 421 * Specifies the package declaration. 422 * @param packageDeclaration the new package declaration. 423 */ 424 protected void setPackageDeclaration(String packageDeclaration) 425 { 426 inmutableSetPackageDeclaration(packageDeclaration); 427 } 428 429 /*** 430 * Retrieves the package declaration. 431 * @return such information. 432 */ 433 public String getPackageDeclaration() 434 { 435 return m__strPackageDeclaration; 436 } 437 438 /*** 439 * Specifies the package name. 440 * @param packageName the new package name. 441 */ 442 private void inmutableSetPackageName(String packageName) 443 { 444 m__strPackageName = packageName; 445 } 446 447 /*** 448 * Specifies the package name. 449 * @param packageName the new package name. 450 */ 451 protected void setPackageName(String packageName) 452 { 453 inmutableSetPackageName(packageName); 454 } 455 456 /*** 457 * Retrieves the package name. 458 * @return such information. 459 */ 460 public String getPackageName() 461 { 462 return m__strPackageName; 463 } 464 465 /*** 466 * Specifies the default exception. 467 * @param defaultException the new default exception. 468 */ 469 private void inmutableSetViolationException(String defaultException) 470 { 471 m__strViolationException = defaultException; 472 } 473 474 /*** 475 * Specifies the default exception. 476 * @param defaultException the new default exception. 477 */ 478 protected void setViolationException(String defaultException) 479 { 480 inmutableSetViolationException(defaultException); 481 } 482 483 /*** 484 * Retrieves the default exception. 485 * @return such information. 486 */ 487 public String getViolationException() 488 { 489 return m__strViolationException; 490 } 491 492 /*** 493 * Specifies the project imports' Javadoc. 494 * @param projectImports the new Javadoc for project imports. 495 */ 496 private void inmutableSetProjectImportsJavadoc(String javadocImports) 497 { 498 m__strProjectImportsJavadoc = javadocImports; 499 } 500 501 /*** 502 * Specifies the project imports' Javadoc. 503 * @param projectImports the new Javadoc for project imports. 504 */ 505 protected void setProjectImportsJavadoc(String javadocImports) 506 { 507 inmutableSetProjectImportsJavadoc(javadocImports); 508 } 509 510 /*** 511 * Retrieves the project imports' Javadoc. 512 * @return such information. 513 */ 514 public String getProjectImportsJavadoc() 515 { 516 return m__strProjectImportsJavadoc; 517 } 518 519 /*** 520 * Specifies the project imports. 521 * @param projectImports the new project imports. 522 */ 523 private void inmutableSetProjectImports(String projectImports) 524 { 525 m__strProjectImports = projectImports; 526 } 527 528 /*** 529 * Specifies the project imports. 530 * @param projectImports the new project imports. 531 */ 532 protected void setProjectImports(String projectImports) 533 { 534 inmutableSetProjectImports(projectImports); 535 } 536 537 /*** 538 * Retrieves the project imports. 539 * @return such information. 540 */ 541 public String getProjectImports() 542 { 543 return m__strProjectImports; 544 } 545 546 /*** 547 * Specifies the Javadoc for the aspect. 548 * @param javadoc the new javadoc. 549 */ 550 private void inmutableSetAspectJavadoc(String javadoc) 551 { 552 m__strAspectJavadoc = javadoc; 553 } 554 555 /*** 556 * Specifies the Javadoc for the aspect. 557 * @param javadoc the new javadoc. 558 */ 559 protected void setAspectJavadoc(String javadoc) 560 { 561 inmutableSetAspectJavadoc(javadoc); 562 } 563 564 /*** 565 * Retrieves the aspect javadoc. 566 * @return such information. 567 */ 568 public String getAspectJavadoc() 569 { 570 return m__strAspectJavadoc; 571 } 572 573 /*** 574 * Specifies the aspect definition. 575 * @param aspectDefinition the new aspect definition. 576 */ 577 private void inmutableSetAspectDefinition(String aspectDefinition) 578 { 579 m__strAspectDefinition = aspectDefinition; 580 } 581 582 /*** 583 * Specifies the aspect definition. 584 * @param aspectDefinition the new aspect definition. 585 */ 586 protected void setAspectDefinition(String aspectDefinition) 587 { 588 inmutableSetAspectDefinition(aspectDefinition); 589 } 590 591 /*** 592 * Retrieves the aspect definition. 593 * @return such information. 594 */ 595 public String getAspectDefinition() 596 { 597 return m__strAspectDefinition; 598 } 599 600 /*** 601 * Specifies the aspect start. 602 * @param aspectStart the new aspect start. 603 */ 604 private void inmutableSetAspectStart(String aspectStart) 605 { 606 m__strAspectStart = aspectStart; 607 } 608 609 /*** 610 * Specifies the aspect start. 611 * @param aspectStart the new aspect start. 612 */ 613 protected void setAspectStart(String aspectStart) 614 { 615 inmutableSetAspectStart(aspectStart); 616 } 617 618 /*** 619 * Retrieves the aspect start. 620 * @return such information. 621 */ 622 public String getAspectStart() 623 { 624 return m__strAspectStart; 625 } 626 627 /*** 628 * Specifies the precondition pointcut. 629 * @param preconditionPointcut the new pointcut. 630 */ 631 private void inmutableSetPreconditionPointcut(String preconditionPointcut) 632 { 633 m__strPreconditionPointcut = preconditionPointcut; 634 } 635 636 /*** 637 * Specifies the precondition pointcut. 638 * @param preconditionPointcut the new pointcut. 639 */ 640 protected void setPreconditionPointcut(String preconditionPointcut) 641 { 642 inmutableSetPreconditionPointcut(preconditionPointcut); 643 } 644 645 /*** 646 * Retrieves the precondition pointcut. 647 * @return such information. 648 */ 649 public String getPreconditionPointcut() 650 { 651 return m__strPreconditionPointcut; 652 } 653 654 /*** 655 * Specifies the exception declaration. 656 * @param exceptionDeclaration the new exception declaration. 657 */ 658 private void inmutableSetExceptionDeclaration(String exceptionDeclaration) 659 { 660 m__strExceptionDeclaration = exceptionDeclaration; 661 } 662 663 /*** 664 * Specifies the exception declaration. 665 * @param exceptionDeclaration the new exception declaration. 666 */ 667 protected void setExceptionDeclaration(String exceptionDeclaration) 668 { 669 inmutableSetExceptionDeclaration(exceptionDeclaration); 670 } 671 672 /*** 673 * Retrieves the exception declaration. 674 * @return such information. 675 */ 676 public String getExceptionDeclaration() 677 { 678 return m__strExceptionDeclaration; 679 } 680 681 /*** 682 * Specifies the precondition advice. 683 * @param preconditionAdvice the new advice. 684 */ 685 private void inmutableSetPreconditionAdvice(String preconditionAdvice) 686 { 687 m__strPreconditionAdvice = preconditionAdvice; 688 } 689 690 /*** 691 * Specifies the precondition advice. 692 * @param preconditionAdvice the new advice. 693 */ 694 protected void setPreconditionAdvice(String preconditionAdvice) 695 { 696 inmutableSetPreconditionAdvice(preconditionAdvice); 697 } 698 699 /*** 700 * Retrieves the precondition advice. 701 * @return such information. 702 */ 703 public String getPreconditionAdvice() 704 { 705 return m__strPreconditionAdvice; 706 } 707 708 /*** 709 * Specifies the precondition check. 710 * @param preconditionCheck the new check. 711 */ 712 private void inmutableSetPreconditionCheck(String preconditionCheck) 713 { 714 m__strPreconditionCheck = preconditionCheck; 715 } 716 717 /*** 718 * Specifies the precondition check. 719 * @param preconditionCheck the new check. 720 */ 721 protected void setPreconditionCheck(String preconditionCheck) 722 { 723 inmutableSetPreconditionCheck(preconditionCheck); 724 } 725 726 /*** 727 * Retrieves the precondition check. 728 * @return such information. 729 */ 730 public String getPreconditionCheck() 731 { 732 return m__strPreconditionCheck; 733 } 734 735 /*** 736 * Specifies the aspect end. 737 * @param aspectEnd the new aspect end. 738 */ 739 private void inmutableSetAspectEnd(String aspectEnd) 740 { 741 m__strAspectEnd = aspectEnd; 742 } 743 744 /*** 745 * Specifies the aspect end. 746 * @param aspectEnd the new aspect end. 747 */ 748 protected void setAspectEnd(String aspectEnd) 749 { 750 inmutableSetAspectEnd(aspectEnd); 751 } 752 753 /*** 754 * Retrieves the aspect end. 755 * @return such information. 756 */ 757 public String getAspectEnd() 758 { 759 return m__strAspectEnd; 760 } 761 762 /*** 763 * Specifies the classes. 764 * @param classes the class list. 765 */ 766 protected void setClasses(List classes) 767 { 768 m__lClasses = classes; 769 } 770 771 /*** 772 * Retrieves the classes. 773 * @return such collection. 774 */ 775 protected List getClasses() 776 { 777 return m__lClasses; 778 } 779 780 /*** 781 * Adds a new class. 782 * @param classMetaData the new class. 783 */ 784 public void addClass(JavaClass javaClass) 785 { 786 if (javaClass != null) 787 { 788 List t_lClasses = getClasses(); 789 790 if (t_lClasses == null) 791 { 792 t_lClasses = new ArrayList(); 793 setClasses(t_lClasses); 794 } 795 796 t_lClasses.add(javaClass); 797 } 798 } 799 800 /*** 801 * Retrieves the source code of the generated table repository. 802 * @return such source code. 803 */ 804 public String toString() 805 { 806 StringBuffer t_sbResult = new StringBuffer(); 807 808 Object[] t_aPackageName = new Object[]{getPackageName()}; 809 810 t_sbResult.append(getHeader()); 811 812 MessageFormat t_Formatter = 813 new MessageFormat(getPackageDeclaration()); 814 815 t_sbResult.append(t_Formatter.format(t_aPackageName)); 816 817 List t_lClasses = getClasses(); 818 819 if (t_lClasses != null) 820 { 821 Iterator t_itClasses = t_lClasses.iterator(); 822 823 if (t_itClasses.hasNext()) 824 { 825 t_sbResult.append(getProjectImportsJavadoc()); 826 } 827 828 MessageFormat t_ImportFormatter = 829 new MessageFormat(getProjectImports()); 830 831 while (t_itClasses.hasNext()) 832 { 833 JavaClass t_JavaClass = (JavaClass) t_itClasses.next(); 834 835 if (t_JavaClass != null) 836 { 837 t_sbResult.append( 838 t_ImportFormatter.format( 839 new Object[] 840 { 841 t_JavaClass.getFullyQualifiedName() 842 })); 843 } 844 } 845 } 846 847 t_sbResult.append(getAspectJavadoc()); 848 849 t_sbResult.append(getAspectDefinition()); 850 851 t_sbResult.append(getAspectStart()); 852 853 if (t_lClasses != null) 854 { 855 MessageFormat t_PreconditionPointcutFormatter = 856 new MessageFormat(getPreconditionPointcut()); 857 858 MessageFormat t_ExceptionDeclarationFormatter = 859 new MessageFormat(getExceptionDeclaration()); 860 861 MessageFormat t_PreconditionAdviceFormatter = 862 new MessageFormat(getPreconditionAdvice()); 863 864 MessageFormat t_PreconditionCheckFormatter = 865 new MessageFormat(getPreconditionCheck()); 866 867 Iterator t_itClasses = t_lClasses.iterator(); 868 869 while ( (t_itClasses != null) 870 && (t_itClasses.hasNext())) 871 { 872 JavaClass t_CurrentClass = (JavaClass) t_itClasses.next(); 873 874 if (t_CurrentClass != null) 875 { 876 JavaMethod[] t_aMethods = t_CurrentClass.getMethods(); 877 878 for (int t_iMethodIndex = 0; 879 t_iMethodIndex < t_aMethods.length; 880 t_iMethodIndex++) 881 { 882 if (t_aMethods[t_iMethodIndex] != null) 883 { 884 DocletTag[] t_aTags = 885 t_aMethods[t_iMethodIndex].getTagsByName( 886 ContractCheckerDoclet.PRECONDITION_TAG); 887 888 if ( (t_aTags != null) 889 && (t_aTags.length > 0)) 890 { 891 StringBuffer t_sbParameterNames = 892 new StringBuffer(); 893 894 StringBuffer t_sbParameterTypes = 895 new StringBuffer(); 896 897 StringBuffer t_sbParameterDeclaration = 898 new StringBuffer(); 899 900 StringBuffer t_sbChecks = 901 new StringBuffer(); 902 903 JavaParameter[] t_aParameters = 904 t_aMethods[t_iMethodIndex].getParameters(); 905 906 for (int t_iParamIndex = 0; 907 t_iParamIndex < t_aParameters.length; 908 t_iParamIndex++) 909 { 910 if (t_iParamIndex > 0) 911 { 912 t_sbParameterNames.append(", "); 913 914 t_sbParameterDeclaration.append(", "); 915 916 t_sbParameterTypes.append(", "); 917 } 918 919 t_sbParameterNames.append( 920 t_aParameters[t_iParamIndex].getName()); 921 922 t_sbParameterTypes.append( 923 t_aParameters[t_iParamIndex].getType()); 924 925 t_sbParameterDeclaration.append( 926 t_aParameters[t_iParamIndex].getType()); 927 928 t_sbParameterDeclaration.append(" "); 929 930 t_sbParameterDeclaration.append( 931 t_aParameters[t_iParamIndex].getName()); 932 } 933 934 t_sbResult.append( 935 t_PreconditionPointcutFormatter.format( 936 new Object[] 937 { 938 t_CurrentClass.getFullyQualifiedName(), 939 t_aMethods[t_iMethodIndex].getName(), 940 t_sbParameterNames, 941 t_sbParameterDeclaration, 942 t_sbParameterTypes, 943 t_aMethods[t_iMethodIndex].getReturns() 944 })); 945 946 for (int t_iTagIndex = 0; 947 t_iTagIndex < t_aTags.length; 948 t_iTagIndex++) 949 { 950 t_sbChecks.append( 951 t_PreconditionCheckFormatter.format( 952 new Object[] 953 { 954 t_aTags[t_iTagIndex].getValue(), 955 getViolationException() 956 })); 957 } 958 959 t_sbResult.append( 960 t_ExceptionDeclarationFormatter.format( 961 new Object[] 962 { 963 getViolationException(), 964 t_sbParameterTypes 965 })); 966 967 t_sbResult.append( 968 t_PreconditionAdviceFormatter.format( 969 new Object[] 970 { 971 t_sbParameterDeclaration, 972 getViolationException(), 973 t_sbParameterNames, 974 t_sbChecks 975 })); 976 977 } 978 } 979 } 980 } 981 } 982 } 983 984 t_sbResult.append(getAspectEnd()); 985 986 return t_sbResult.toString(); 987 } 988 }

This page was automatically generated by Maven