Package net.minecraftforge.common.util
Class TextTable
- java.lang.Object
-
- net.minecraftforge.common.util.TextTable
-
public class TextTable extends java.lang.Object
Utility to format data into a textual (markdown-compliant) table.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TextTable.Alignment
static class
TextTable.Column
static class
TextTable.Row
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<TextTable.Column>
columns
private java.util.List<TextTable.Row>
rows
-
Constructor Summary
Constructors Constructor Description TextTable(java.util.List<TextTable.Column> columns)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(java.lang.Object... values)
void
append(java.lang.StringBuilder destination, java.lang.String lineEnding)
Appends the data formatted as a table to the given string builder.java.lang.String
build(java.lang.String lineEnding)
void
clear()
static TextTable.Column
column(java.lang.String header)
static TextTable.Column
column(java.lang.String header, TextTable.Alignment alignment)
java.util.List<TextTable.Column>
getColumns()
private void
printRow(java.lang.StringBuilder destination, java.util.List<java.lang.String> values)
private void
printSeparators(java.lang.StringBuilder destination)
-
-
-
Field Detail
-
columns
private final java.util.List<TextTable.Column> columns
-
rows
private final java.util.List<TextTable.Row> rows
-
-
Constructor Detail
-
TextTable
public TextTable(java.util.List<TextTable.Column> columns)
-
-
Method Detail
-
column
public static TextTable.Column column(java.lang.String header)
-
column
public static TextTable.Column column(java.lang.String header, TextTable.Alignment alignment)
-
build
public java.lang.String build(java.lang.String lineEnding)
-
append
public void append(java.lang.StringBuilder destination, java.lang.String lineEnding)
Appends the data formatted as a table to the given string builder. The padding character used for the column alignments is a single space (' '), the separate between column headers and values is a dash ('-'). Note that you *have* to specify a line ending, '\n' isn't used by default.The generated table is compliant with the markdown file format.
- Parameters:
destination
- a string builder to append the table tolineEnding
- the line ending to use for each row of the table
-
printSeparators
private void printSeparators(java.lang.StringBuilder destination)
-
printRow
private void printRow(java.lang.StringBuilder destination, java.util.List<java.lang.String> values)
-
add
public void add(@Nonnull java.lang.Object... values)
-
clear
public void clear()
-
getColumns
public java.util.List<TextTable.Column> getColumns()
-
-