I like it when, every now and then, some ridiculously low-tech requirement comes along and I can spend a few minutes whipping up a class to make it easier and more flexible. Such things often go into the utility library and see a lot of reuse. An opportunity arose recently when I was working on an email notification and reporting engine strapped to a large database. Every day the data gets updated six ways from Sunday and we generate a bunch of naturally tabular data that has to get embedded into emails. The usual approach to this, for myself and everyone else on the team, is to hard code the output. Last night I was looking for something relaxing to work on, and I decided to whip up some stuff to make generating fixed-width text tables a lot easier. The result is a class called TextTable.
I don’t think TextTable is going to win me any ACM awards any time soon, but it’s one of those things that is pretty handy when you need it. I hope to add some extensions to it in the future to support proportional fonts. In the meantime, if you’re interested, you can download the source or read the project post.