Package com.google.gerrit.server.ioutil
Class ColumnFormatter
- java.lang.Object
-
- com.google.gerrit.server.ioutil.ColumnFormatter
-
public class ColumnFormatter extends Object
Simple output formatter for column-oriented data, writing its output to aPrintWriter
object. Handles escaping of the column data so that the resulting output is unambiguous and reasonably safe and machine parsable.
-
-
Constructor Summary
Constructors Constructor Description ColumnFormatter(PrintWriter out, char columnSeparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addColumn(String content)
Adds a text string as a new column in the current line of output, taking care of escaping as necessary.void
finish()
Finishes the output by flushing the current line and takes care of any other cleanup action.void
nextLine()
Flushes the current line of output and makes the formatter ready to start receiving new column data for a new line (or end-of-file).
-
-
-
Constructor Detail
-
ColumnFormatter
public ColumnFormatter(PrintWriter out, char columnSeparator)
- Parameters:
out
- The writer to which output should be sent.columnSeparator
- A character that should serve as the separator token between columns of output. As only non-printable characters in the column text are ever escaped, the column separator must be a non-printable character if the output needs to be unambiguously parsed.
-
-
Method Detail
-
addColumn
public void addColumn(String content)
Adds a text string as a new column in the current line of output, taking care of escaping as necessary.- Parameters:
content
- the string to add.
-
finish
public void finish()
Finishes the output by flushing the current line and takes care of any other cleanup action.
-
nextLine
public void nextLine()
Flushes the current line of output and makes the formatter ready to start receiving new column data for a new line (or end-of-file). If the current line is empty nothing is done, i.e. consecutive calls to this method without intervening calls toaddColumn(java.lang.String)
will be squashed.
-
-