This class has been posted first time on the Groovy-User Mailing List by Raffaele Castagno in this format:
and later "groovyfied" by Gavin Grover:
First version is here only as an example of the "groovify process". Of course, the Gavin's version is better.
This class emulate the output of most RDBMS consoles (ie. Oracle SQL*, MySql).
Here's an usage example (again, grooved up by Gavin):
This is the output:
Actually is really limited: column width must be declared, and strings are truncated to that given size.
The version below is part of a larger project that you are free to grab and use for you own. The main project wiki page is
here. We prefer static typing for our larger projects, so we have modified the original code to suit our style. Hope it is useful for you. Victor Vlasenko authored most of this enhancement under contract for Build Lackey Labs, and I helped clean up the code a bit for presentation on this site .
This enhancement enables wrapping-to-multi-lines for column text
that exceeds the width of a given column. We break out word boundaries
(white space) where possible, The implementation we built on truncated
the overly long column value instead of wrapping it.