View Javadoc
1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.benchmark;
5   
6   /**
7    * A wrapped StringBuilder that appends a variable number of text segments efficiently 
8    * and always appends the specified carriage return terminator.
9    * 
10   * @author Brian Remedios
11   */
12  public class StringBuilderCR {
13  
14  	private final String cr;
15  	private final StringBuilder sb = new StringBuilder();
16  	
17  	public StringBuilderCR(String theCR) {
18  		cr = theCR;
19  	}
20  	
21  	public StringBuilderCR(String initialText, String theCR) {
22  		this(theCR);
23  		appendLn(initialText);
24  	}
25  	
26  	public void appendLn(String... chunks) {
27  		
28  		for (String chunk : chunks) {
29  			sb.append(chunk);
30  		}
31  		sb.append(cr);
32  	}
33  	
34  	public String toString() {
35  		return sb.toString();
36  	}
37  }