Coverage Report - org.apache.maven.plugin.checkstyle.HelpMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
HelpMojo
0%
0/276
0%
0/62
4.667
 
 1  
 package org.apache.maven.plugin.checkstyle;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.Iterator;
 5  
 import java.util.List;
 6  
 
 7  
 import org.apache.maven.plugin.AbstractMojo;
 8  
 import org.apache.maven.plugin.MojoExecutionException;
 9  
 
 10  
 /**
 11  
  * Display help information on maven-checkstyle-plugin.<br/> Call <pre>  mvn checkstyle:help -Ddetail=true -Dgoal=&lt;goal-name&gt;</pre> to display parameter details.
 12  
  *
 13  
  * @version generated on Mon Feb 08 13:58:50 CET 2010
 14  
  * @author org.apache.maven.tools.plugin.generator.PluginHelpGenerator (version 2.5.1)
 15  
  * @goal help
 16  
  * @requiresProject false
 17  
  */
 18  0
 public class HelpMojo
 19  
     extends AbstractMojo
 20  
 {
 21  
     /**
 22  
      * If <code>true</code>, display all settable properties for each goal.
 23  
      * 
 24  
      * @parameter expression="${detail}" default-value="false"
 25  
      */
 26  
     private boolean detail;
 27  
 
 28  
     /**
 29  
      * The name of the goal for which to show help. If unspecified, all goals will be displayed.
 30  
      * 
 31  
      * @parameter expression="${goal}"
 32  
      */
 33  
     private java.lang.String goal;
 34  
 
 35  
     /**
 36  
      * The maximum length of a display line, should be positive.
 37  
      * 
 38  
      * @parameter expression="${lineLength}" default-value="80"
 39  
      */
 40  
     private int lineLength;
 41  
 
 42  
     /**
 43  
      * The number of spaces per indentation level, should be positive.
 44  
      * 
 45  
      * @parameter expression="${indentSize}" default-value="2"
 46  
      */
 47  
     private int indentSize;
 48  
 
 49  
 
 50  
     /** {@inheritDoc} */
 51  
     public void execute()
 52  
         throws MojoExecutionException
 53  
     {
 54  0
         if ( lineLength <= 0 )
 55  
         {
 56  0
             getLog().warn( "The parameter 'lineLength' should be positive, using '80' as default." );
 57  0
             lineLength = 80;
 58  
         }
 59  0
         if ( indentSize <= 0 )
 60  
         {
 61  0
             getLog().warn( "The parameter 'indentSize' should be positive, using '2' as default." );
 62  0
             indentSize = 2;
 63  
         }
 64  
 
 65  0
         StringBuffer sb = new StringBuffer();
 66  
 
 67  0
         append( sb, "org.apache.maven.plugins:maven-checkstyle-plugin:2.5", 0 );
 68  0
         append( sb, "", 0 );
 69  
 
 70  0
         append( sb, "Maven Checkstyle Plugin", 0 );
 71  0
         append( sb, "Generates a report on violations of code style and optionally fails the build if violations are detected.", 1 );
 72  0
         append( sb, "", 0 );
 73  
 
 74  0
         if ( goal == null || goal.length() <= 0 )
 75  
         {
 76  0
             append( sb, "This plugin has 3 goals:", 0 );
 77  0
             append( sb, "", 0 );
 78  
         }
 79  
 
 80  0
         if ( goal == null || goal.length() <= 0 || "check".equals( goal ) )
 81  
         {
 82  0
             append( sb, "checkstyle:check", 0 );
 83  0
             append( sb, "Perform a violation check against the last Checkstyle run to see if there are any violations. It reads the Checkstyle output file, counts the number of violations found and displays it on the console.", 1 );
 84  0
             append( sb, "", 0 );
 85  0
             if ( detail )
 86  
             {
 87  0
                 append( sb, "Available parameters:", 1 );
 88  0
                 append( sb, "", 0 );
 89  
 
 90  0
                 append( sb, "cacheFile (Default: ${project.build.directory}/checkstyle-cachefile)", 2 );
 91  0
                 append( sb, "Specifies the cache file used to speed up Checkstyle on successive runs.", 3 );
 92  0
                 append( sb, "", 0 );
 93  
 
 94  0
                 append( sb, "configLocation (Default: config/sun_checks.xml)", 2 );
 95  0
                 append( sb, "Specifies the location of the XML configuration to use.\n\nPotential values are a filesystem path, a URL, or a classpath resource. This parameter expects that the contents of the location conform to the xml format (Checkstyle Checker module) configuration of rulesets.\n\nThis parameter is resolved as resource, URL, then file. If successfully resolved, the contents of the configuration is copied into the ${project.build.directory}/checkstyle-configuration.xml file before being passed to Checkstyle as a configuration.\n\nThere are 4 predefined rulesets.\n\n-\tconfig/sun_checks.xml: Sun Checks.\n-\tconfig/turbine_checks.xml: Turbine Checks.\n-\tconfig/avalon_checks.xml: Avalon Checks.\n-\tconfig/maven_checks.xml: Maven Source Checks.\n", 3 );
 96  0
                 append( sb, "", 0 );
 97  
 
 98  0
                 append( sb, "consoleOutput (Default: false)", 2 );
 99  0
                 append( sb, "Output errors to console.", 3 );
 100  0
                 append( sb, "", 0 );
 101  
 
 102  0
                 append( sb, "encoding (Default: ${project.build.sourceEncoding})", 2 );
 103  0
                 append( sb, "The file encoding to use when reading the source files. If the property project.build.sourceEncoding is not set, the platform default encoding is used. Note: This parameter always overrides the property charset from Checkstyle\'s TreeWalker module.", 3 );
 104  0
                 append( sb, "", 0 );
 105  
 
 106  0
                 append( sb, "excludes", 2 );
 107  0
                 append( sb, "Specifies the names filter of the source files to be excluded for Checkstyle.", 3 );
 108  0
                 append( sb, "", 0 );
 109  
 
 110  0
                 append( sb, "failOnViolation (Default: true)", 2 );
 111  0
                 append( sb, "Do we fail the build on a violation?", 3 );
 112  0
                 append( sb, "", 0 );
 113  
 
 114  0
                 append( sb, "failsOnError (Default: false)", 2 );
 115  0
                 append( sb, "Specifies if the build should fail upon a violation.", 3 );
 116  0
                 append( sb, "", 0 );
 117  
 
 118  0
                 append( sb, "headerLocation (Default: LICENSE.txt)", 2 );
 119  0
                 append( sb, "Specifies the location of the License file (a.k.a. the header file) that can be used by Checkstyle to verify that source code has the correct license header.\n\nYou need to use ${checkstyle.header.file} in your Checkstyle xml configuration to reference the name of this header file.\n\nFor instance:\n\n<module name=\'RegexpHeader\'> <property name=\'headerFile\' value=\'${checkstyle.header.file}\'/> </module>\n", 3 );
 120  0
                 append( sb, "", 0 );
 121  
 
 122  0
                 append( sb, "includes (Default: **/*.java)", 2 );
 123  0
                 append( sb, "Specifies the names filter of the source files to be used for Checkstyle.", 3 );
 124  0
                 append( sb, "", 0 );
 125  
 
 126  0
                 append( sb, "includeTestSourceDirectory (Default: ${false})", 2 );
 127  0
                 append( sb, "Include or not the test source directory to be used for Checkstyle.", 3 );
 128  0
                 append( sb, "", 0 );
 129  
 
 130  0
                 append( sb, "logViolationsToConsole (Default: false)", 2 );
 131  0
                 append( sb, "Output the detected violations to the console.", 3 );
 132  0
                 append( sb, "", 0 );
 133  
 
 134  0
                 append( sb, "maxAllowedViolations (Default: 0)", 2 );
 135  0
                 append( sb, "The maximum number of allowed violations. The execution fails only if the number of violations is above this limit.", 3 );
 136  0
                 append( sb, "", 0 );
 137  
 
 138  0
                 append( sb, "outputFile (Default: ${project.build.directory}/checkstyle-result.xml)", 2 );
 139  0
                 append( sb, "Specifies the path and filename to save the Checkstyle output. The format of the output file is determined by the outputFileFormat parameter.", 3 );
 140  0
                 append( sb, "", 0 );
 141  
 
 142  0
                 append( sb, "outputFileFormat (Default: xml)", 2 );
 143  0
                 append( sb, "Specifies the format of the output to be used when writing to the output file. Valid values are \'plain\' and \'xml\'.", 3 );
 144  0
                 append( sb, "", 0 );
 145  
 
 146  0
                 append( sb, "propertiesLocation", 2 );
 147  0
                 append( sb, "Specifies the location of the properties file.\n\nThis parameter is resolved as URL, File then resource. If successfully resolved, the contents of the properties location is copied into the ${project.build.directory}/checkstyle-checker.properties file before being passed to Checkstyle for loading.\n\nThe contents of the propertiesLocation will be made available to Checkstyle for specifying values for parameters within the xml configuration (specified in the configLocation parameter).\n", 3 );
 148  0
                 append( sb, "", 0 );
 149  
 
 150  0
                 append( sb, "propertyExpansion", 2 );
 151  0
                 append( sb, "Allows for specifying raw property expansion information.", 3 );
 152  0
                 append( sb, "", 0 );
 153  
 
 154  0
                 append( sb, "skip (Default: false)", 2 );
 155  0
                 append( sb, "Skip entire check.", 3 );
 156  0
                 append( sb, "", 0 );
 157  
 
 158  0
                 append( sb, "skipExec (Default: false)", 2 );
 159  0
                 append( sb, "Skip checktyle execution will only scan the outputFile.", 3 );
 160  0
                 append( sb, "", 0 );
 161  
 
 162  0
                 append( sb, "sourceDirectory (Default: ${project.build.sourceDirectory})", 2 );
 163  0
                 append( sb, "Specifies the location of the source directory to be used for Checkstyle.", 3 );
 164  0
                 append( sb, "", 0 );
 165  
 
 166  0
                 append( sb, "suppressionsFileExpression (Default: checkstyle.suppressions.file)", 2 );
 167  0
                 append( sb, "The key to be used in the properties for the suppressions file.", 3 );
 168  0
                 append( sb, "", 0 );
 169  
 
 170  0
                 append( sb, "suppressionsLocation", 2 );
 171  0
                 append( sb, "Specifies the location of the suppressions XML file to use.\n\nThis parameter is resolved as resource, URL, then file. If successfully resolved, the contents of the suppressions XML is copied into the ${project.build.directory}/checkstyle-supressions.xml file before being passed to Checkstyle for loading.\n\nSee suppressionsFileExpression for the property that will be made available to your checkstyle configuration.\n", 3 );
 172  0
                 append( sb, "", 0 );
 173  
 
 174  0
                 append( sb, "testSourceDirectory (Default: ${project.build.testSourceDirectory})", 2 );
 175  0
                 append( sb, "Specifies the location of the test source directory to be used for Checkstyle.", 3 );
 176  0
                 append( sb, "", 0 );
 177  
 
 178  0
                 append( sb, "useFile", 2 );
 179  0
                 append( sb, "If null, the Checkstyle plugin will display violations on stdout. Otherwise, a text file will be created with the violations.", 3 );
 180  0
                 append( sb, "", 0 );
 181  
 
 182  0
                 append( sb, "violationSeverity (Default: error)", 2 );
 183  0
                 append( sb, "The lowest severity level that is considered a violation. Valid values are \'error\', \'warning\' and \'info\'.", 3 );
 184  0
                 append( sb, "", 0 );
 185  
             }
 186  
         }
 187  
 
 188  0
         if ( goal == null || goal.length() <= 0 || "checkstyle".equals( goal ) )
 189  
         {
 190  0
             append( sb, "checkstyle:checkstyle", 0 );
 191  0
             append( sb, "Perform a Checkstyle analysis, and generate a report on violations.", 1 );
 192  0
             append( sb, "", 0 );
 193  0
             if ( detail )
 194  
             {
 195  0
                 append( sb, "Available parameters:", 1 );
 196  0
                 append( sb, "", 0 );
 197  
 
 198  0
                 append( sb, "cacheFile (Default: ${project.build.directory}/checkstyle-cachefile)", 2 );
 199  0
                 append( sb, "Specifies the cache file used to speed up Checkstyle on successive runs.", 3 );
 200  0
                 append( sb, "", 0 );
 201  
 
 202  0
                 append( sb, "configLocation (Default: config/sun_checks.xml)", 2 );
 203  0
                 append( sb, "Specifies the location of the XML configuration to use.\n\nPotential values are a filesystem path, a URL, or a classpath resource. This parameter expects that the contents of the location conform to the xml format (Checkstyle Checker module) configuration of rulesets.\n\nThis parameter is resolved as resource, URL, then file. If successfully resolved, the contents of the configuration is copied into the ${project.build.directory}/checkstyle-configuration.xml file before being passed to Checkstyle as a configuration.\n\nThere are 4 predefined rulesets.\n\n-\tconfig/sun_checks.xml: Sun Checks.\n-\tconfig/turbine_checks.xml: Turbine Checks.\n-\tconfig/avalon_checks.xml: Avalon Checks.\n-\tconfig/maven_checks.xml: Maven Source Checks.\n", 3 );
 204  0
                 append( sb, "", 0 );
 205  
 
 206  0
                 append( sb, "consoleOutput (Default: false)", 2 );
 207  0
                 append( sb, "Output errors to console.", 3 );
 208  0
                 append( sb, "", 0 );
 209  
 
 210  0
                 append( sb, "enableFilesSummary (Default: true)", 2 );
 211  0
                 append( sb, "Specifies if the Files summary should be enabled or not.", 3 );
 212  0
                 append( sb, "", 0 );
 213  
 
 214  0
                 append( sb, "enableRSS (Default: true)", 2 );
 215  0
                 append( sb, "Specifies if the RSS should be enabled or not.", 3 );
 216  0
                 append( sb, "", 0 );
 217  
 
 218  0
                 append( sb, "enableRulesSummary (Default: true)", 2 );
 219  0
                 append( sb, "Specifies if the Rules summary should be enabled or not.", 3 );
 220  0
                 append( sb, "", 0 );
 221  
 
 222  0
                 append( sb, "enableSeveritySummary (Default: true)", 2 );
 223  0
                 append( sb, "Specifies if the Severity summary should be enabled or not.", 3 );
 224  0
                 append( sb, "", 0 );
 225  
 
 226  0
                 append( sb, "encoding (Default: ${project.build.sourceEncoding})", 2 );
 227  0
                 append( sb, "The file encoding to use when reading the source files. If the property project.build.sourceEncoding is not set, the platform default encoding is used. Note: This parameter always overrides the property charset from Checkstyle\'s TreeWalker module.", 3 );
 228  0
                 append( sb, "", 0 );
 229  
 
 230  0
                 append( sb, "excludes", 2 );
 231  0
                 append( sb, "Specifies the names filter of the source files to be excluded for Checkstyle.", 3 );
 232  0
                 append( sb, "", 0 );
 233  
 
 234  0
                 append( sb, "failsOnError (Default: false)", 2 );
 235  0
                 append( sb, "Specifies if the build should fail upon a violation.", 3 );
 236  0
                 append( sb, "", 0 );
 237  
 
 238  0
                 append( sb, "format (Default: sun)", 2 );
 239  0
                 append( sb, "Deprecated. Use configLocation instead.", 3 );
 240  0
                 append( sb, "", 0 );
 241  0
                 append( sb, "Specifies what predefined check set to use. Available sets are \'sun\' (for the Sun coding conventions), \'turbine\', and \'avalon\'.", 3 );
 242  0
                 append( sb, "", 0 );
 243  
 
 244  0
                 append( sb, "headerFile", 2 );
 245  0
                 append( sb, "Deprecated. Use headerLocation instead.", 3 );
 246  0
                 append( sb, "", 0 );
 247  0
                 append( sb, "Specifies the location of the License file (a.k.a. the header file) that is used by Checkstyle to verify that source code has the correct license header.", 3 );
 248  0
                 append( sb, "", 0 );
 249  
 
 250  0
                 append( sb, "headerLocation (Default: LICENSE.txt)", 2 );
 251  0
                 append( sb, "Specifies the location of the License file (a.k.a. the header file) that can be used by Checkstyle to verify that source code has the correct license header.\n\nYou need to use ${checkstyle.header.file} in your Checkstyle xml configuration to reference the name of this header file.\n\nFor instance:\n\n<module name=\'RegexpHeader\'> <property name=\'headerFile\' value=\'${checkstyle.header.file}\'/> </module>\n", 3 );
 252  0
                 append( sb, "", 0 );
 253  
 
 254  0
                 append( sb, "includes (Default: **/*.java)", 2 );
 255  0
                 append( sb, "Specifies the names filter of the source files to be used for Checkstyle.", 3 );
 256  0
                 append( sb, "", 0 );
 257  
 
 258  0
                 append( sb, "includeTestSourceDirectory (Default: ${false})", 2 );
 259  0
                 append( sb, "Include or not the test source directory to be used for Checkstyle.", 3 );
 260  0
                 append( sb, "", 0 );
 261  
 
 262  0
                 append( sb, "linkXRef (Default: true)", 2 );
 263  0
                 append( sb, "Link the violation line numbers to the source xref. Will link automatically if Maven JXR plugin is being used.", 3 );
 264  0
                 append( sb, "", 0 );
 265  
 
 266  0
                 append( sb, "outputDirectory (Default: ${project.reporting.outputDirectory})", 2 );
 267  0
                 append( sb, "The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from the command line. If the goal is run indirectly as part of a site generation, the output directory configured in Maven Site Plugin is used instead.", 3 );
 268  0
                 append( sb, "", 0 );
 269  
 
 270  0
                 append( sb, "outputFile (Default: ${project.build.directory}/checkstyle-result.xml)", 2 );
 271  0
                 append( sb, "Specifies the path and filename to save the checkstyle output. The format of the output file is determined by the outputFileFormat parameter.", 3 );
 272  0
                 append( sb, "", 0 );
 273  
 
 274  0
                 append( sb, "outputFileFormat (Default: xml)", 2 );
 275  0
                 append( sb, "Specifies the format of the output to be used when writing to the output file. Valid values are \'plain\' and \'xml\'.", 3 );
 276  0
                 append( sb, "", 0 );
 277  
 
 278  0
                 append( sb, "packageNamesFile", 2 );
 279  0
                 append( sb, "Deprecated. Use packageNamesLocation instead.", 3 );
 280  0
                 append( sb, "", 0 );
 281  0
                 append( sb, "Specifies the location of the package names XML to be used to configure Checkstyle.", 3 );
 282  0
                 append( sb, "", 0 );
 283  
 
 284  0
                 append( sb, "packageNamesLocation", 2 );
 285  0
                 append( sb, "Specifies the location of the package names XML to be used to configure the Checkstyle Packages.\n\nThis parameter is resolved as resource, URL, then file. If resolved to a resource, or a URL, the contents of the package names XML is copied into the ${project.build.directory}/checkstyle-packagenames.xml file before being passed to Checkstyle for loading.\n", 3 );
 286  0
                 append( sb, "", 0 );
 287  
 
 288  0
                 append( sb, "propertiesFile", 2 );
 289  0
                 append( sb, "Deprecated. Use propertiesLocation instead.", 3 );
 290  0
                 append( sb, "", 0 );
 291  0
                 append( sb, "Specifies the location of the Checkstyle properties file that will be used to check the source.", 3 );
 292  0
                 append( sb, "", 0 );
 293  
 
 294  0
                 append( sb, "propertiesLocation", 2 );
 295  0
                 append( sb, "Specifies the location of the properties file.\n\nThis parameter is resolved as URL, File then resource. If successfully resolved, the contents of the properties location is copied into the ${project.build.directory}/checkstyle-checker.properties file before being passed to Checkstyle for loading.\n\nThe contents of the propertiesLocation will be made available to Checkstyle for specifying values for parameters within the xml configuration (specified in the configLocation parameter).\n", 3 );
 296  0
                 append( sb, "", 0 );
 297  
 
 298  0
                 append( sb, "propertiesURL", 2 );
 299  0
                 append( sb, "Deprecated. Use propertiesLocation instead.", 3 );
 300  0
                 append( sb, "", 0 );
 301  0
                 append( sb, "Specifies the URL of the Checkstyle properties that will be used to check the source.", 3 );
 302  0
                 append( sb, "", 0 );
 303  
 
 304  0
                 append( sb, "propertyExpansion", 2 );
 305  0
                 append( sb, "Allows for specifying raw property expansion information.", 3 );
 306  0
                 append( sb, "", 0 );
 307  
 
 308  0
                 append( sb, "skip (Default: false)", 2 );
 309  0
                 append( sb, "Skip entire check.", 3 );
 310  0
                 append( sb, "", 0 );
 311  
 
 312  0
                 append( sb, "sourceDirectory (Default: ${project.build.sourceDirectory})", 2 );
 313  0
                 append( sb, "Specifies the location of the source directory to be used for Checkstyle.", 3 );
 314  0
                 append( sb, "", 0 );
 315  
 
 316  0
                 append( sb, "suppressionsFile", 2 );
 317  0
                 append( sb, "Deprecated. Use suppressionsLocation instead.", 3 );
 318  0
                 append( sb, "", 0 );
 319  0
                 append( sb, "Specifies the location of the suppressions XML file to use. The plugin defines a Checkstyle property named checkstyle.suppressions.file with the value of this property. This allows using the Checkstyle property in your own custom checkstyle configuration file when specifying a suppressions file.", 3 );
 320  0
                 append( sb, "", 0 );
 321  
 
 322  0
                 append( sb, "suppressionsFileExpression (Default: checkstyle.suppressions.file)", 2 );
 323  0
                 append( sb, "The key to be used in the properties for the suppressions file.", 3 );
 324  0
                 append( sb, "", 0 );
 325  
 
 326  0
                 append( sb, "suppressionsLocation", 2 );
 327  0
                 append( sb, "Specifies the location of the suppressions XML file to use.\n\nThis parameter is resolved as resource, URL, then file. If successfully resolved, the contents of the suppressions XML is copied into the ${project.build.directory}/checkstyle-supressions.xml file before being passed to Checkstyle for loading.\n\nSee suppressionsFileExpression for the property that will be made available to your checkstyle configuration.\n", 3 );
 328  0
                 append( sb, "", 0 );
 329  
 
 330  0
                 append( sb, "testSourceDirectory (Default: ${project.build.testSourceDirectory})", 2 );
 331  0
                 append( sb, "Specifies the location of the test source directory to be used for Checkstyle.", 3 );
 332  0
                 append( sb, "", 0 );
 333  
 
 334  0
                 append( sb, "useFile", 2 );
 335  0
                 append( sb, "If null, the Checkstyle plugin will display violations on stdout. Otherwise, a text file will be created with the violations.", 3 );
 336  0
                 append( sb, "", 0 );
 337  
 
 338  0
                 append( sb, "xrefLocation (Default: ${project.reporting.outputDirectory}/xref)", 2 );
 339  0
                 append( sb, "Location of the Xrefs to link to.", 3 );
 340  0
                 append( sb, "", 0 );
 341  
             }
 342  
         }
 343  
 
 344  0
         if ( goal == null || goal.length() <= 0 || "help".equals( goal ) )
 345  
         {
 346  0
             append( sb, "checkstyle:help", 0 );
 347  0
             append( sb, "Display help information on maven-checkstyle-plugin.\nCall\n\u00a0\u00a0mvn\u00a0checkstyle:help\u00a0-Ddetail=true\u00a0-Dgoal=<goal-name>\nto display parameter details.", 1 );
 348  0
             append( sb, "", 0 );
 349  0
             if ( detail )
 350  
             {
 351  0
                 append( sb, "Available parameters:", 1 );
 352  0
                 append( sb, "", 0 );
 353  
 
 354  0
                 append( sb, "detail (Default: false)", 2 );
 355  0
                 append( sb, "If true, display all settable properties for each goal.", 3 );
 356  0
                 append( sb, "", 0 );
 357  
 
 358  0
                 append( sb, "goal", 2 );
 359  0
                 append( sb, "The name of the goal for which to show help. If unspecified, all goals will be displayed.", 3 );
 360  0
                 append( sb, "", 0 );
 361  
 
 362  0
                 append( sb, "indentSize (Default: 2)", 2 );
 363  0
                 append( sb, "The number of spaces per indentation level, should be positive.", 3 );
 364  0
                 append( sb, "", 0 );
 365  
 
 366  0
                 append( sb, "lineLength (Default: 80)", 2 );
 367  0
                 append( sb, "The maximum length of a display line, should be positive.", 3 );
 368  0
                 append( sb, "", 0 );
 369  
             }
 370  
         }
 371  
 
 372  0
         if ( getLog().isInfoEnabled() )
 373  
         {
 374  0
             getLog().info( sb.toString() );
 375  
         }
 376  0
     }
 377  
 
 378  
     /**
 379  
      * <p>Repeat a String <code>n</code> times to form a new string.</p>
 380  
      *
 381  
      * @param str String to repeat
 382  
      * @param repeat number of times to repeat str
 383  
      * @return String with repeated String
 384  
      * @throws NegativeArraySizeException if <code>repeat < 0</code>
 385  
      * @throws NullPointerException if str is <code>null</code>
 386  
      */
 387  
     private static String repeat( String str, int repeat )
 388  
     {
 389  0
         StringBuffer buffer = new StringBuffer( repeat * str.length() );
 390  
 
 391  0
         for ( int i = 0; i < repeat; i++ )
 392  
         {
 393  0
             buffer.append( str );
 394  
         }
 395  
 
 396  0
         return buffer.toString();
 397  
     }
 398  
 
 399  
     /** 
 400  
      * Append a description to the buffer by respecting the indentSize and lineLength parameters.
 401  
      * <b>Note</b>: The last character is always a new line.
 402  
      * 
 403  
      * @param sb The buffer to append the description, not <code>null</code>.
 404  
      * @param description The description, not <code>null</code>.
 405  
      * @param indent The base indentation level of each line, must not be negative.
 406  
      */
 407  
     private void append( StringBuffer sb, String description, int indent )
 408  
     {
 409  0
         for ( Iterator it = toLines( description, indent, indentSize, lineLength ).iterator(); it.hasNext(); )
 410  
         {
 411  0
             sb.append( it.next().toString() ).append( '\n' );
 412  
         }
 413  0
     }
 414  
 
 415  
     /** 
 416  
      * Splits the specified text into lines of convenient display length.
 417  
      * 
 418  
      * @param text The text to split into lines, must not be <code>null</code>.
 419  
      * @param indent The base indentation level of each line, must not be negative.
 420  
      * @param indentSize The size of each indentation, must not be negative.
 421  
      * @param lineLength The length of the line, must not be negative.
 422  
      * @return The sequence of display lines, never <code>null</code>.
 423  
      * @throws NegativeArraySizeException if <code>indent < 0</code>
 424  
      */
 425  
     private static List toLines( String text, int indent, int indentSize, int lineLength )
 426  
     {
 427  0
         List lines = new ArrayList();
 428  
 
 429  0
         String ind = repeat( "\t", indent );
 430  0
         String[] plainLines = text.split( "(\r\n)|(\r)|(\n)" );
 431  0
         for ( int i = 0; i < plainLines.length; i++ )
 432  
         {
 433  0
             toLines( lines, ind + plainLines[i], indentSize, lineLength );
 434  
         }
 435  
 
 436  0
         return lines;
 437  
     }
 438  
 
 439  
     /** 
 440  
      * Adds the specified line to the output sequence, performing line wrapping if necessary.
 441  
      * 
 442  
      * @param lines The sequence of display lines, must not be <code>null</code>.
 443  
      * @param line The line to add, must not be <code>null</code>.
 444  
      * @param indentSize The size of each indentation, must not be negative.
 445  
      * @param lineLength The length of the line, must not be negative.
 446  
      */
 447  
     private static void toLines( List lines, String line, int indentSize, int lineLength )
 448  
     {
 449  0
         int lineIndent = getIndentLevel( line );
 450  0
         StringBuffer buf = new StringBuffer( 256 );
 451  0
         String[] tokens = line.split( " +" );
 452  0
         for ( int i = 0; i < tokens.length; i++ )
 453  
         {
 454  0
             String token = tokens[i];
 455  0
             if ( i > 0 )
 456  
             {
 457  0
                 if ( buf.length() + token.length() >= lineLength )
 458  
                 {
 459  0
                     lines.add( buf.toString() );
 460  0
                     buf.setLength( 0 );
 461  0
                     buf.append( repeat( " ", lineIndent * indentSize ) );
 462  
                 }
 463  
                 else
 464  
                 {
 465  0
                     buf.append( ' ' );
 466  
                 }
 467  
             }
 468  0
             for ( int j = 0; j < token.length(); j++ )
 469  
             {
 470  0
                 char c = token.charAt( j );
 471  0
                 if ( c == '\t' )
 472  
                 {
 473  0
                     buf.append( repeat( " ", indentSize - buf.length() % indentSize ) );
 474  
                 }
 475  0
                 else if ( c == '\u00A0' )
 476  
                 {
 477  0
                     buf.append( ' ' );
 478  
                 }
 479  
                 else
 480  
                 {
 481  0
                     buf.append( c );
 482  
                 }
 483  
             }
 484  
         }
 485  0
         lines.add( buf.toString() );
 486  0
     }
 487  
 
 488  
     /** 
 489  
      * Gets the indentation level of the specified line.
 490  
      * 
 491  
      * @param line The line whose indentation level should be retrieved, must not be <code>null</code>.
 492  
      * @return The indentation level of the line.
 493  
      */
 494  
     private static int getIndentLevel( String line )
 495  
     {
 496  0
         int level = 0;
 497  0
         for ( int i = 0; i < line.length() && line.charAt( i ) == '\t'; i++ )
 498  
         {
 499  0
             level++;
 500  
         }
 501  0
         for ( int i = level + 1; i <= level + 4 && i < line.length(); i++ )
 502  
         {
 503  0
             if ( line.charAt( i ) == '\t' )
 504  
             {
 505  0
                 level++;
 506  0
                 break;
 507  
             }
 508  
         }
 509  0
         return level;
 510  
     }
 511  
 }