Package com.google.gerrit.server.ioutil
Class ColumnFormatter
java.lang.Object
com.google.gerrit.server.ioutil.ColumnFormatter
Simple output formatter for column-oriented data, writing its output to a
PrintWriter
object. Handles escaping of the column data so that the resulting output is
unambiguous and reasonably safe and machine parsable.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 Details
-
ColumnFormatter
- 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 Details
-
addColumn
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.
-