Coverage Report - org.apache.maven.plugin.resources.HelpMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
HelpMojo
0%
0/247
0%
0/70
5
 
 1  
 package org.apache.maven.plugin.resources;
 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-resources-plugin.<br/> Call <pre>  mvn resources:help -Ddetail=true -Dgoal=&lt;goal-name&gt;</pre> to display parameter details.
 12  
  *
 13  
  * @version generated on Thu Feb 24 20:51:30 CET 2011
 14  
  * @author org.apache.maven.tools.plugin.generator.PluginHelpGenerator (version 2.7)
 15  
  * @goal help
 16  
  * @requiresProject false
 17  
  * @threadSafe
 18  
  */
 19  0
 public class HelpMojo
 20  
     extends AbstractMojo
 21  
 {
 22  
     /**
 23  
      * If <code>true</code>, display all settable properties for each goal.
 24  
      * 
 25  
      * @parameter expression="${detail}" default-value="false"
 26  
      */
 27  
     private boolean detail;
 28  
 
 29  
     /**
 30  
      * The name of the goal for which to show help. If unspecified, all goals will be displayed.
 31  
      * 
 32  
      * @parameter expression="${goal}"
 33  
      */
 34  
     private java.lang.String goal;
 35  
 
 36  
     /**
 37  
      * The maximum length of a display line, should be positive.
 38  
      * 
 39  
      * @parameter expression="${lineLength}" default-value="80"
 40  
      */
 41  
     private int lineLength;
 42  
 
 43  
     /**
 44  
      * The number of spaces per indentation level, should be positive.
 45  
      * 
 46  
      * @parameter expression="${indentSize}" default-value="2"
 47  
      */
 48  
     private int indentSize;
 49  
 
 50  
 
 51  
     /** {@inheritDoc} */
 52  
     public void execute()
 53  
         throws MojoExecutionException
 54  
     {
 55  0
         if ( lineLength <= 0 )
 56  
         {
 57  0
             getLog().warn( "The parameter 'lineLength' should be positive, using '80' as default." );
 58  0
             lineLength = 80;
 59  
         }
 60  0
         if ( indentSize <= 0 )
 61  
         {
 62  0
             getLog().warn( "The parameter 'indentSize' should be positive, using '2' as default." );
 63  0
             indentSize = 2;
 64  
         }
 65  
 
 66  0
         StringBuffer sb = new StringBuffer();
 67  
 
 68  0
         append( sb, "org.apache.maven.plugins:maven-resources-plugin:2.5", 0 );
 69  0
         append( sb, "", 0 );
 70  
 
 71  0
         append( sb, "Maven Resources Plugin", 0 );
 72  0
         append( sb, "The Resources Plugin handles the copying of project resources to the output directory. There are two different kinds of resources: main resources and test resources. The difference is that the main resources are the resources associated to the main source code while the test resources are associated to the test source code. Thus, this allows the separation of resources for the main source code and its unit tests.", 1 );
 73  0
         append( sb, "", 0 );
 74  
 
 75  0
         if ( goal == null || goal.length() <= 0 )
 76  
         {
 77  0
             append( sb, "This plugin has 4 goals:", 0 );
 78  0
             append( sb, "", 0 );
 79  
         }
 80  
 
 81  0
         if ( goal == null || goal.length() <= 0 || "copy-resources".equals( goal ) )
 82  
         {
 83  0
             append( sb, "resources:copy-resources", 0 );
 84  0
             append( sb, "Copy resources of the configured plugin attribute resources", 1 );
 85  0
             append( sb, "", 0 );
 86  0
             if ( detail )
 87  
             {
 88  0
                 append( sb, "Available parameters:", 1 );
 89  0
                 append( sb, "", 0 );
 90  
 
 91  0
                 append( sb, "delimiters", 2 );
 92  0
                 append( sb, "Set of delimiters for expressions to filter within the resources. These delimiters are specified in the form \'beginToken*endToken\'. If no \'*\' is given, the delimiter is assumed to be the same for start and end.\n\nSo, the default filtering delimiters might be specified as:\n\n<delimiters>\n\u00a0\u00a0<delimiter>${*}</delimiter>\n\u00a0\u00a0<delimiter>@</delimiter>\n</delimiters>\n\nSince the \'@\' delimiter is the same on both ends, we don\'t need to specify \'@*@\' (though we can).\n", 3 );
 93  0
                 append( sb, "", 0 );
 94  
 
 95  0
                 append( sb, "encoding (Default: ${project.build.sourceEncoding})", 2 );
 96  0
                 append( sb, "The character encoding scheme to be applied when filtering resources.", 3 );
 97  0
                 append( sb, "Expression: ${encoding}", 3 );
 98  0
                 append( sb, "", 0 );
 99  
 
 100  0
                 append( sb, "escapeString", 2 );
 101  0
                 append( sb, "Expression preceded with the String won\'t be interpolated \\${foo} will be replaced with ${foo}", 3 );
 102  0
                 append( sb, "Expression: ${maven.resources.escapeString}", 3 );
 103  0
                 append( sb, "", 0 );
 104  
 
 105  0
                 append( sb, "escapeWindowsPaths (Default: true)", 2 );
 106  0
                 append( sb, "Whether to escape backslashes and colons in windows-style paths.", 3 );
 107  0
                 append( sb, "Expression: ${maven.resources.escapeWindowsPaths}", 3 );
 108  0
                 append( sb, "", 0 );
 109  
 
 110  0
                 append( sb, "filters", 2 );
 111  0
                 append( sb, "The list of extra filter properties files to be used along with System properties, project properties, and filter properties files specified in the POM build/filters section, which should be used for the filtering during the current mojo execution.\nNormally, these will be configured from a plugin\'s execution section, to provide a different set of filters for a particular execution. For instance, starting in Maven 2.2.0, you have the option of configuring executions with the id\'s default-resources and default-testResources to supply different configurations for the two different types of resources. By supplying extraFilters configurations, you can separate which filters are used for which type of resource.", 3 );
 112  0
                 append( sb, "", 0 );
 113  
 
 114  0
                 append( sb, "includeEmptyDirs (Default: false)", 2 );
 115  0
                 append( sb, "Copy any empty directories included in the Ressources.", 3 );
 116  0
                 append( sb, "Expression: ${maven.resources.includeEmptyDirs}", 3 );
 117  0
                 append( sb, "", 0 );
 118  
 
 119  0
                 append( sb, "mavenFilteringHints", 2 );
 120  0
                 append( sb, "List of plexus components hint which implements MavenResourcesFiltering.filterResources(). They will be executed after the resources copying/filtering.\n", 3 );
 121  0
                 append( sb, "", 0 );
 122  
 
 123  0
                 append( sb, "nonFilteredFileExtensions", 2 );
 124  0
                 append( sb, "Additional file extensions to not apply filtering (already defined are : jpg, jpeg, gif, bmp, png)", 3 );
 125  0
                 append( sb, "", 0 );
 126  
 
 127  0
                 append( sb, "outputDirectory", 2 );
 128  0
                 append( sb, "The output directory into which to copy the resources.", 3 );
 129  0
                 append( sb, "Required: Yes", 3 );
 130  0
                 append( sb, "", 0 );
 131  
 
 132  0
                 append( sb, "overwrite (Default: false)", 2 );
 133  0
                 append( sb, "Overwrite existing files even if the destination files are newer.", 3 );
 134  0
                 append( sb, "Expression: ${maven.resources.overwrite}", 3 );
 135  0
                 append( sb, "", 0 );
 136  
 
 137  0
                 append( sb, "resources", 2 );
 138  0
                 append( sb, "The list of resources we want to transfer. See the Maven Model for a description of how to code the resources element.", 3 );
 139  0
                 append( sb, "Required: Yes", 3 );
 140  0
                 append( sb, "", 0 );
 141  
 
 142  0
                 append( sb, "supportMultiLineFiltering (Default: false)", 2 );
 143  0
                 append( sb, "stop searching endToken at the end of line", 3 );
 144  0
                 append( sb, "Expression: ${maven.resources.supportMultiLineFiltering}", 3 );
 145  0
                 append( sb, "", 0 );
 146  
 
 147  0
                 append( sb, "useBuildFilters (Default: true)", 2 );
 148  0
                 append( sb, "If false, don\'t use the filters specified in the build/filters section of the POM when processing resources in this mojo execution.\nSee also: ResourcesMojo.buildFilters and ResourcesMojo.filters", 3 );
 149  0
                 append( sb, "", 0 );
 150  
 
 151  0
                 append( sb, "useDefaultDelimiters (Default: true)", 2 );
 152  0
                 append( sb, "(no description available)", 3 );
 153  0
                 append( sb, "", 0 );
 154  
             }
 155  
         }
 156  
 
 157  0
         if ( goal == null || goal.length() <= 0 || "help".equals( goal ) )
 158  
         {
 159  0
             append( sb, "resources:help", 0 );
 160  0
             append( sb, "Display help information on maven-resources-plugin.\nCall\n\u00a0\u00a0mvn\u00a0resources:help\u00a0-Ddetail=true\u00a0-Dgoal=<goal-name>\nto display parameter details.", 1 );
 161  0
             append( sb, "", 0 );
 162  0
             if ( detail )
 163  
             {
 164  0
                 append( sb, "Available parameters:", 1 );
 165  0
                 append( sb, "", 0 );
 166  
 
 167  0
                 append( sb, "detail (Default: false)", 2 );
 168  0
                 append( sb, "If true, display all settable properties for each goal.", 3 );
 169  0
                 append( sb, "Expression: ${detail}", 3 );
 170  0
                 append( sb, "", 0 );
 171  
 
 172  0
                 append( sb, "goal", 2 );
 173  0
                 append( sb, "The name of the goal for which to show help. If unspecified, all goals will be displayed.", 3 );
 174  0
                 append( sb, "Expression: ${goal}", 3 );
 175  0
                 append( sb, "", 0 );
 176  
 
 177  0
                 append( sb, "indentSize (Default: 2)", 2 );
 178  0
                 append( sb, "The number of spaces per indentation level, should be positive.", 3 );
 179  0
                 append( sb, "Expression: ${indentSize}", 3 );
 180  0
                 append( sb, "", 0 );
 181  
 
 182  0
                 append( sb, "lineLength (Default: 80)", 2 );
 183  0
                 append( sb, "The maximum length of a display line, should be positive.", 3 );
 184  0
                 append( sb, "Expression: ${lineLength}", 3 );
 185  0
                 append( sb, "", 0 );
 186  
             }
 187  
         }
 188  
 
 189  0
         if ( goal == null || goal.length() <= 0 || "resources".equals( goal ) )
 190  
         {
 191  0
             append( sb, "resources:resources", 0 );
 192  0
             append( sb, "Copy resources for the main source code to the main output directory. Always uses the project.build.resources element to specify the resources to copy.", 1 );
 193  0
             append( sb, "", 0 );
 194  0
             if ( detail )
 195  
             {
 196  0
                 append( sb, "Available parameters:", 1 );
 197  0
                 append( sb, "", 0 );
 198  
 
 199  0
                 append( sb, "delimiters", 2 );
 200  0
                 append( sb, "Set of delimiters for expressions to filter within the resources. These delimiters are specified in the form \'beginToken*endToken\'. If no \'*\' is given, the delimiter is assumed to be the same for start and end.\n\nSo, the default filtering delimiters might be specified as:\n\n<delimiters>\n\u00a0\u00a0<delimiter>${*}</delimiter>\n\u00a0\u00a0<delimiter>@</delimiter>\n</delimiters>\n\nSince the \'@\' delimiter is the same on both ends, we don\'t need to specify \'@*@\' (though we can).\n", 3 );
 201  0
                 append( sb, "", 0 );
 202  
 
 203  0
                 append( sb, "encoding (Default: ${project.build.sourceEncoding})", 2 );
 204  0
                 append( sb, "The character encoding scheme to be applied when filtering resources.", 3 );
 205  0
                 append( sb, "Expression: ${encoding}", 3 );
 206  0
                 append( sb, "", 0 );
 207  
 
 208  0
                 append( sb, "escapeString", 2 );
 209  0
                 append( sb, "Expression preceded with the String won\'t be interpolated \\${foo} will be replaced with ${foo}", 3 );
 210  0
                 append( sb, "Expression: ${maven.resources.escapeString}", 3 );
 211  0
                 append( sb, "", 0 );
 212  
 
 213  0
                 append( sb, "escapeWindowsPaths (Default: true)", 2 );
 214  0
                 append( sb, "Whether to escape backslashes and colons in windows-style paths.", 3 );
 215  0
                 append( sb, "Expression: ${maven.resources.escapeWindowsPaths}", 3 );
 216  0
                 append( sb, "", 0 );
 217  
 
 218  0
                 append( sb, "filters", 2 );
 219  0
                 append( sb, "The list of extra filter properties files to be used along with System properties, project properties, and filter properties files specified in the POM build/filters section, which should be used for the filtering during the current mojo execution.\nNormally, these will be configured from a plugin\'s execution section, to provide a different set of filters for a particular execution. For instance, starting in Maven 2.2.0, you have the option of configuring executions with the id\'s default-resources and default-testResources to supply different configurations for the two different types of resources. By supplying extraFilters configurations, you can separate which filters are used for which type of resource.", 3 );
 220  0
                 append( sb, "", 0 );
 221  
 
 222  0
                 append( sb, "includeEmptyDirs (Default: false)", 2 );
 223  0
                 append( sb, "Copy any empty directories included in the Ressources.", 3 );
 224  0
                 append( sb, "Expression: ${maven.resources.includeEmptyDirs}", 3 );
 225  0
                 append( sb, "", 0 );
 226  
 
 227  0
                 append( sb, "mavenFilteringHints", 2 );
 228  0
                 append( sb, "List of plexus components hint which implements MavenResourcesFiltering.filterResources(). They will be executed after the resources copying/filtering.\n", 3 );
 229  0
                 append( sb, "", 0 );
 230  
 
 231  0
                 append( sb, "nonFilteredFileExtensions", 2 );
 232  0
                 append( sb, "Additional file extensions to not apply filtering (already defined are : jpg, jpeg, gif, bmp, png)", 3 );
 233  0
                 append( sb, "", 0 );
 234  
 
 235  0
                 append( sb, "outputDirectory (Default: ${project.build.outputDirectory})", 2 );
 236  0
                 append( sb, "The output directory into which to copy the resources.", 3 );
 237  0
                 append( sb, "Required: Yes", 3 );
 238  0
                 append( sb, "", 0 );
 239  
 
 240  0
                 append( sb, "overwrite (Default: false)", 2 );
 241  0
                 append( sb, "Overwrite existing files even if the destination files are newer.", 3 );
 242  0
                 append( sb, "Expression: ${maven.resources.overwrite}", 3 );
 243  0
                 append( sb, "", 0 );
 244  
 
 245  0
                 append( sb, "supportMultiLineFiltering (Default: false)", 2 );
 246  0
                 append( sb, "stop searching endToken at the end of line", 3 );
 247  0
                 append( sb, "Expression: ${maven.resources.supportMultiLineFiltering}", 3 );
 248  0
                 append( sb, "", 0 );
 249  
 
 250  0
                 append( sb, "useBuildFilters (Default: true)", 2 );
 251  0
                 append( sb, "If false, don\'t use the filters specified in the build/filters section of the POM when processing resources in this mojo execution.\nSee also: ResourcesMojo.buildFilters and ResourcesMojo.filters", 3 );
 252  0
                 append( sb, "", 0 );
 253  
 
 254  0
                 append( sb, "useDefaultDelimiters (Default: true)", 2 );
 255  0
                 append( sb, "(no description available)", 3 );
 256  0
                 append( sb, "", 0 );
 257  
             }
 258  
         }
 259  
 
 260  0
         if ( goal == null || goal.length() <= 0 || "testResources".equals( goal ) )
 261  
         {
 262  0
             append( sb, "resources:testResources", 0 );
 263  0
             append( sb, "Copy resources for the test source code to the test output directory. Always uses the project.build.testResources element to specify the resources to copy.", 1 );
 264  0
             append( sb, "", 0 );
 265  0
             if ( detail )
 266  
             {
 267  0
                 append( sb, "Available parameters:", 1 );
 268  0
                 append( sb, "", 0 );
 269  
 
 270  0
                 append( sb, "delimiters", 2 );
 271  0
                 append( sb, "Set of delimiters for expressions to filter within the resources. These delimiters are specified in the form \'beginToken*endToken\'. If no \'*\' is given, the delimiter is assumed to be the same for start and end.\n\nSo, the default filtering delimiters might be specified as:\n\n<delimiters>\n\u00a0\u00a0<delimiter>${*}</delimiter>\n\u00a0\u00a0<delimiter>@</delimiter>\n</delimiters>\n\nSince the \'@\' delimiter is the same on both ends, we don\'t need to specify \'@*@\' (though we can).\n", 3 );
 272  0
                 append( sb, "", 0 );
 273  
 
 274  0
                 append( sb, "encoding (Default: ${project.build.sourceEncoding})", 2 );
 275  0
                 append( sb, "The character encoding scheme to be applied when filtering resources.", 3 );
 276  0
                 append( sb, "Expression: ${encoding}", 3 );
 277  0
                 append( sb, "", 0 );
 278  
 
 279  0
                 append( sb, "escapeString", 2 );
 280  0
                 append( sb, "Expression preceded with the String won\'t be interpolated \\${foo} will be replaced with ${foo}", 3 );
 281  0
                 append( sb, "Expression: ${maven.resources.escapeString}", 3 );
 282  0
                 append( sb, "", 0 );
 283  
 
 284  0
                 append( sb, "escapeWindowsPaths (Default: true)", 2 );
 285  0
                 append( sb, "Whether to escape backslashes and colons in windows-style paths.", 3 );
 286  0
                 append( sb, "Expression: ${maven.resources.escapeWindowsPaths}", 3 );
 287  0
                 append( sb, "", 0 );
 288  
 
 289  0
                 append( sb, "filters", 2 );
 290  0
                 append( sb, "The list of extra filter properties files to be used along with System properties, project properties, and filter properties files specified in the POM build/filters section, which should be used for the filtering during the current mojo execution.\nNormally, these will be configured from a plugin\'s execution section, to provide a different set of filters for a particular execution. For instance, starting in Maven 2.2.0, you have the option of configuring executions with the id\'s default-resources and default-testResources to supply different configurations for the two different types of resources. By supplying extraFilters configurations, you can separate which filters are used for which type of resource.", 3 );
 291  0
                 append( sb, "", 0 );
 292  
 
 293  0
                 append( sb, "includeEmptyDirs (Default: false)", 2 );
 294  0
                 append( sb, "Copy any empty directories included in the Ressources.", 3 );
 295  0
                 append( sb, "Expression: ${maven.resources.includeEmptyDirs}", 3 );
 296  0
                 append( sb, "", 0 );
 297  
 
 298  0
                 append( sb, "mavenFilteringHints", 2 );
 299  0
                 append( sb, "List of plexus components hint which implements MavenResourcesFiltering.filterResources(). They will be executed after the resources copying/filtering.\n", 3 );
 300  0
                 append( sb, "", 0 );
 301  
 
 302  0
                 append( sb, "nonFilteredFileExtensions", 2 );
 303  0
                 append( sb, "Additional file extensions to not apply filtering (already defined are : jpg, jpeg, gif, bmp, png)", 3 );
 304  0
                 append( sb, "", 0 );
 305  
 
 306  0
                 append( sb, "outputDirectory", 2 );
 307  0
                 append( sb, "The output directory into which to copy the resources.", 3 );
 308  0
                 append( sb, "Required: Yes", 3 );
 309  0
                 append( sb, "Expression: ${project.build.testOutputDirectory}", 3 );
 310  0
                 append( sb, "", 0 );
 311  
 
 312  0
                 append( sb, "overwrite (Default: false)", 2 );
 313  0
                 append( sb, "Overwrite existing files even if the destination files are newer.", 3 );
 314  0
                 append( sb, "Expression: ${maven.resources.overwrite}", 3 );
 315  0
                 append( sb, "", 0 );
 316  
 
 317  0
                 append( sb, "supportMultiLineFiltering (Default: false)", 2 );
 318  0
                 append( sb, "stop searching endToken at the end of line", 3 );
 319  0
                 append( sb, "Expression: ${maven.resources.supportMultiLineFiltering}", 3 );
 320  0
                 append( sb, "", 0 );
 321  
 
 322  0
                 append( sb, "useBuildFilters (Default: true)", 2 );
 323  0
                 append( sb, "If false, don\'t use the filters specified in the build/filters section of the POM when processing resources in this mojo execution.\nSee also: ResourcesMojo.buildFilters and ResourcesMojo.filters", 3 );
 324  0
                 append( sb, "", 0 );
 325  
 
 326  0
                 append( sb, "useDefaultDelimiters (Default: true)", 2 );
 327  0
                 append( sb, "(no description available)", 3 );
 328  0
                 append( sb, "", 0 );
 329  
             }
 330  
         }
 331  
 
 332  0
         if ( getLog().isInfoEnabled() )
 333  
         {
 334  0
             getLog().info( sb.toString() );
 335  
         }
 336  0
     }
 337  
 
 338  
     /**
 339  
      * <p>Repeat a String <code>n</code> times to form a new string.</p>
 340  
      *
 341  
      * @param str String to repeat
 342  
      * @param repeat number of times to repeat str
 343  
      * @return String with repeated String
 344  
      * @throws NegativeArraySizeException if <code>repeat < 0</code>
 345  
      * @throws NullPointerException if str is <code>null</code>
 346  
      */
 347  
     private static String repeat( String str, int repeat )
 348  
     {
 349  0
         StringBuffer buffer = new StringBuffer( repeat * str.length() );
 350  
 
 351  0
         for ( int i = 0; i < repeat; i++ )
 352  
         {
 353  0
             buffer.append( str );
 354  
         }
 355  
 
 356  0
         return buffer.toString();
 357  
     }
 358  
 
 359  
     /** 
 360  
      * Append a description to the buffer by respecting the indentSize and lineLength parameters.
 361  
      * <b>Note</b>: The last character is always a new line.
 362  
      * 
 363  
      * @param sb The buffer to append the description, not <code>null</code>.
 364  
      * @param description The description, not <code>null</code>.
 365  
      * @param indent The base indentation level of each line, must not be negative.
 366  
      */
 367  
     private void append( StringBuffer sb, String description, int indent )
 368  
     {
 369  0
         for ( Iterator it = toLines( description, indent, indentSize, lineLength ).iterator(); it.hasNext(); )
 370  
         {
 371  0
             sb.append( it.next().toString() ).append( '\n' );
 372  
         }
 373  0
     }
 374  
 
 375  
     /** 
 376  
      * Splits the specified text into lines of convenient display length.
 377  
      * 
 378  
      * @param text The text to split into lines, must not be <code>null</code>.
 379  
      * @param indent The base indentation level of each line, must not be negative.
 380  
      * @param indentSize The size of each indentation, must not be negative.
 381  
      * @param lineLength The length of the line, must not be negative.
 382  
      * @return The sequence of display lines, never <code>null</code>.
 383  
      * @throws NegativeArraySizeException if <code>indent < 0</code>
 384  
      */
 385  
     private static List toLines( String text, int indent, int indentSize, int lineLength )
 386  
     {
 387  0
         List lines = new ArrayList();
 388  
 
 389  0
         String ind = repeat( "\t", indent );
 390  0
         String[] plainLines = text.split( "(\r\n)|(\r)|(\n)" );
 391  0
         for ( int i = 0; i < plainLines.length; i++ )
 392  
         {
 393  0
             toLines( lines, ind + plainLines[i], indentSize, lineLength );
 394  
         }
 395  
 
 396  0
         return lines;
 397  
     }
 398  
 
 399  
     /** 
 400  
      * Adds the specified line to the output sequence, performing line wrapping if necessary.
 401  
      * 
 402  
      * @param lines The sequence of display lines, must not be <code>null</code>.
 403  
      * @param line The line to add, must not be <code>null</code>.
 404  
      * @param indentSize The size of each indentation, must not be negative.
 405  
      * @param lineLength The length of the line, must not be negative.
 406  
      */
 407  
     private static void toLines( List lines, String line, int indentSize, int lineLength )
 408  
     {
 409  0
         int lineIndent = getIndentLevel( line );
 410  0
         StringBuffer buf = new StringBuffer( 256 );
 411  0
         String[] tokens = line.split( " +" );
 412  0
         for ( int i = 0; i < tokens.length; i++ )
 413  
         {
 414  0
             String token = tokens[i];
 415  0
             if ( i > 0 )
 416  
             {
 417  0
                 if ( buf.length() + token.length() >= lineLength )
 418  
                 {
 419  0
                     lines.add( buf.toString() );
 420  0
                     buf.setLength( 0 );
 421  0
                     buf.append( repeat( " ", lineIndent * indentSize ) );
 422  
                 }
 423  
                 else
 424  
                 {
 425  0
                     buf.append( ' ' );
 426  
                 }
 427  
             }
 428  0
             for ( int j = 0; j < token.length(); j++ )
 429  
             {
 430  0
                 char c = token.charAt( j );
 431  0
                 if ( c == '\t' )
 432  
                 {
 433  0
                     buf.append( repeat( " ", indentSize - buf.length() % indentSize ) );
 434  
                 }
 435  0
                 else if ( c == '\u00A0' )
 436  
                 {
 437  0
                     buf.append( ' ' );
 438  
                 }
 439  
                 else
 440  
                 {
 441  0
                     buf.append( c );
 442  
                 }
 443  
             }
 444  
         }
 445  0
         lines.add( buf.toString() );
 446  0
     }
 447  
 
 448  
     /** 
 449  
      * Gets the indentation level of the specified line.
 450  
      * 
 451  
      * @param line The line whose indentation level should be retrieved, must not be <code>null</code>.
 452  
      * @return The indentation level of the line.
 453  
      */
 454  
     private static int getIndentLevel( String line )
 455  
     {
 456  0
         int level = 0;
 457  0
         for ( int i = 0; i < line.length() && line.charAt( i ) == '\t'; i++ )
 458  
         {
 459  0
             level++;
 460  
         }
 461  0
         for ( int i = level + 1; i <= level + 4 && i < line.length(); i++ )
 462  
         {
 463  0
             if ( line.charAt( i ) == '\t' )
 464  
             {
 465  0
                 level++;
 466  0
                 break;
 467  
             }
 468  
         }
 469  0
         return level;
 470  
     }
 471  
 }