Optimize placeholder parsing and replacement

The patch applies several optimizations to the Formats#replaceKeywords
algorithm:

- Copy input to char[] to avoid repeated range checks in String#charAt

- Use ArrayDeque rather than synchronized Stack

- Write to existing StringBuilder rather than returning String, thus
  avoiding unnecessary copying of the output

- Only read the input once - the old algorithm used several passes
  to process nested placeholders

- Don't use an explicit state machine - use Java's control flow
  statements instead

- Specify a length when creating StringBuilders - for the common case
  of placeholder less values, this avoid resizing StringBuilders

- Reduce use of StringBuilder#append(char) and instead append a
  range of the input array. This reduces the number of capacity checks
  the StringBuilder has to do.

I had to adjust several unit tests. To me those tests looked like
encoding perculiarities of the old parser rather than intended behaviour.

Target: trunk
Require-notes: no
Require-book: no
Acked-by: Paul Millar <paul.millar@desy.de>
Patch: http://rb.dcache.org/r/5833/