public class TableBuilder extends AbstractTableWriter implements org.apache.commons.lang3.builder.Builder<Table>
Builder to construct tables.
Constructor and Description |
---|
TableBuilder(java.util.List<java.lang.String> columns) |
TableBuilder(TableLayout layout)
Construct a new builder using a particular layout.
|
Modifier and Type | Method and Description |
---|---|
void |
addRow(java.util.List<?> row)
Add a row to the table.
|
void |
addRow(java.lang.Object... row)
Add a row to the table.
|
Table |
build() |
void |
close()
Finish the table.
|
void |
flush()
Flush the writer, causing all currently-written rows to be flushed to output.
|
TableLayout |
getLayout()
Get the layout of this table.
|
void |
writeRow(java.util.List<?> row)
Write a row to the table.
|
checkRowWidth, writeRow
public TableBuilder(TableLayout layout)
Construct a new builder using a particular layout.
layout
- The table layout.public TableBuilder(java.util.List<java.lang.String> columns)
public TableLayout getLayout()
TableWriter
Get the layout of this table.
getLayout
in interface TableWriter
public void close()
TableWriter
Finish the table. Depending on how it was constructed, some underlying resource may be closed.
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface TableWriter
public void flush() throws java.io.IOException
TableWriter
Flush the writer, causing all currently-written rows to be flushed to output.
flush
in interface TableWriter
java.io.IOException
- if an error occurs while flushing output.public void writeRow(java.util.List<?> row)
TableWriter
Write a row to the table. This method is thread-safe.
writeRow
in interface TableWriter
row
- A row of values. If the table requires more columns, the remaining columns are empty. The row is copied if necessary; the caller is free to re-use the same array for returnValue calls.public void addRow(java.util.List<?> row)
Add a row to the table.
row
- The row to add.java.lang.IllegalArgumentException
- if the row has the wrong length.public void addRow(java.lang.Object... row)
Add a row to the table.
row
- The row to add.java.lang.IllegalArgumentException
- if the row has the wrong length.