Jolo is a small Java library for printing text tables. Given all of the work I do with Hyperion and the Essbase Java API, I needed a library for nicely printing out some data on the command-line one day and the only things I could find off the shelf had hard to use APIs that required a lot of boilerplate code. So I rolled my own with a focus on a very tight and simple API while still maintaining some flexibility. The result is Jolo.

Here’s a quick example from the README:

public void testPrintTableWithColumns() {

    // setup table definition with column names/widths
    TableColumnList tcl = new TableColumnList.Builder()
        .add("Name", 40)
        .add("City", 15)
        .add("State", 2)
        .build();

    // createRandomRows is a helper function in this case but would otherwise
    // be your data that is an Iterable<List<Something>>.
    Iterable<List<? extends Object>> data = createRandomRows(10, 3);

    // create the printer and print the data
    TablePrinter tp = new TablePrinter();
    tp.outputTable(tcl, data);
}

And here’s what the output looks like (but imaging your own data of course, not this random stuff).

+----------------------------------------+---------------+--+
|Name                                    |City           |St|
+----------------------------------------+---------------+--+
|n;l                                     |jhFDSmn;klq[   |;k|
|klq[poias                               |a,.mzx;lk;:KLFl|x;|
|.mz                                     |DSmn;klq[poiasd|mn|
|x;lk;:KLF                               |a,.mzx;lk;:KLFl|Fl|
|FDSmn;klq[poiasd;lkmnz.,xm              |a,.mzx;lk;:KLFl|kj|
|hFDSmn;klq[poiasd;lkmnz.,xmn;l          |;:KLFlkjhFDSmn;|.m|
|F                                       |zx;lk;:KLFlkjhF|LF|
|q[poiasd;lkmnz.,xmn;l                   |:KLFlkjhFDSmn;k|,.|
|,.mzx;lk;:KLFlkjhFDSmn;klq[poiasd;lkmnz.|,.mzx;lk;:KLFlk|a,|
|lq[poiasd;                              |x;lk;:KLFlkjhFD|;l|
+----------------------------------------+---------------+--+

More Information

As with most of my projects these days, you can view the full repo at on Jolo’s GitHub page. The source code is released under the Apache Software License, version 2. At the moment it’s not quite as documented as some of my other things, but the API is pretty straightforward so the example should be enough to get going.

One thought on “Jolo

Leave a Reply

Your email address will not be published.