View Javadoc

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