public class ComplexStringFormatter extends Object
The string form of a data structure might look like this:
HolderOfSeveralComponents[@1023948fe,
AComponentThing[@dc0048ba],
AThingWithSurprisingFormatting,
ThingWithOneComponent[@120985093,
HoldsNoComponents[@99999999]
],
ThingWithNoHashCodeAndAMap[
map={
one,
two,
three
}
],
AnotherThingWithSurprisingFormatting
]
Created by following these rules:
create stack holding line number: size of stack is indent level
on [ or { -- write "[" or "{", add line number to stack. If next character is not @, } or ], line-break.
on , -- write ",", line-break
on ] or } -- pop, if same line number, write "]" or "}"
if different line number, line-break (indent plus 1), write "]" or "}"
where each line-break includes indentation, and skipping any subsequent spaces.
| Constructor and Description |
|---|
ComplexStringFormatter(String rawString) |
ComplexStringFormatter(String rawString,
String indentText) |
Copyright © 2016. All rights reserved.