Package com.overzealous.remark.util
Class MarkdownTable
- java.lang.Object
-
- com.overzealous.remark.util.MarkdownTable
-
public class MarkdownTable extends Object
Provides a class to contain the structure of an HTML table so it can be cleanly formatted as a plain text structure (either as Markdown or within a Markdown code block).- Author:
- Phil DeJarnett
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMarkdownTable.AlignmentSimple enum to manage the alignment of a column.
-
Constructor Summary
Constructors Constructor Description MarkdownTable()Creates a new, empty MarkdownTable
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<MarkdownTableCell>addBodyRow()Creates a new body row, and returns it so it can have cells added to it.List<MarkdownTableCell>addHeaderRow()Creates a new header row, and returns it so it can have cells added to it.intgetNumberOfColumns()Returns the total number of columns in this table.voidrenderTable(PrintWriter output, boolean allowColspan, boolean renderAsCode)Renders out the final table.
-
-
-
Method Detail
-
addHeaderRow
public List<MarkdownTableCell> addHeaderRow()
Creates a new header row, and returns it so it can have cells added to it.- Returns:
- A list that can have columns added to it.
-
addBodyRow
public List<MarkdownTableCell> addBodyRow()
Creates a new body row, and returns it so it can have cells added to it.- Returns:
- A list that can have columns added to it.
-
renderTable
public void renderTable(PrintWriter output, boolean allowColspan, boolean renderAsCode)
Renders out the final table. This process starts by calculating widths and alignment for the columns. The final output should be nicely spaced, centered, and look very clean.- Parameters:
output- The writer to receive the final output.allowColspan- If true, cells that span multiple columns are preserved. If false, they are rendered in their own column, then empty columns are placed after.renderAsCode- If true, the output is rendered as a code block
-
getNumberOfColumns
public int getNumberOfColumns()
Returns the total number of columns in this table. This takes into account colspans- Returns:
- The total number of columns in this table.
-
-