Java™ Pretty Printer Library v0.5

Package de.uka.ilkd.pp

A package to pretty-print information using line breaks and indentation.


Interface Summary
Backend<Exc extends Exception> The backend for a Layouter.
PrettyPrintable An interface for objects that can pretty print themselves.

Class Summary
DataLayouter<Exc extends Exception> An extension of Layouter to print arbitrary Java data.
Layouter<Exc extends Exception> Pretty-print information formatted using line breaks and indentation.
StringBackend A Backend which appends all output to a StringBuilder or StringBuffer.
WriterBackend A Backend which writes all output to a

Enum Summary
Layouter.BreakConsistency An enum type to distinguish consistent and inconsistent blocks.
Layouter.IndentationBase An enum type to distinguish indentation relative to the current position or relative to the surrounding block's indentation level

Exception Summary
NoExceptions A dummy Exception type parameter.
UnbalancedBlocksException Thrown by many methods of Layouter to indicate illegal usage.

Package de.uka.ilkd.pp Description

A package to pretty-print information using line breaks and indentation. For instance, it can be used to print

    while (i>0) {
instead of
    while (i>0) { i
    --; j++;}
if a maximum line width of 15 characters is chosen. The frontend to the Pretty-Printer is the Layouter class. You may configure what happens with the output by implemenenting the Backend interface, or by using one of the standard implementations StringBackend and WriterBackend.

A particularly common use is to print arbitrary data structures like with the Object.toString() method, but formatted using whitespace and indentation. This is supported by the DataLayouter class, which provides for standard layouts for collections, arrays, and maps, but also allows new classes to implement the PrettyPrintable interface to specify their preferred layout.

Martin Giese