Appendables

In order to allow for mostly garbage-free behavior, standard Java string concatenation using the “+” operator is not ideal. Pronghorn has its own Appendables class that allows for garbage-free, single pass creation of text.

The API follows a fluent pattern where every method returns the same Appendable which was passed in. It is located in PronghornPipes.

Examples

Append Array

Append an array to a StringBuilder

byte[] a = new byte[1000];
Random r = new Random(101);
r.nextBytes(a);
StringBuilder str = new StringBuilder();
Appendables.appendArray(str, a);

Append Value

Append value(s) to an existing StringBuilder

StringBuilder str = new StringBuilder();
Appendables.appendValue(str, "Label: ", 5, " -Suffix");

Append Fixed Decimal Digits

Append fixed decimals to a StringBuilder

StringBuilder str = new StringBuilder();
Appendables.appendFixedDecimalDigits(str, -42,10 );

Append Base64-encoded String

Creates a Base64-encoded String and appends it

Append Base64-decoded String

Decodes a Base64 string and writes it to target

Append Epoch Time

Append an epoch time to a string

Append Hex Value

Convert an integer to its hex value and append that to the StringBuilder

Append Hex Fixed Value

Convert an integer to its fixed hex value and append that to the StringBuilder

Append Hex Array

Add hex array to the StringBuilder

Last updated