public class AsciiTable extends Object implements IsTable
An ASCII table with some formatting options.
| Modifier and Type | Field and Description |
|---|---|
protected int |
colNumber
Number of columns for the table.
|
protected AT_Context |
ctx
The table context with optional settings for the table.
|
protected AT_Renderer |
renderer
The renderer for the paragraph, default is
AP_Renderer. |
protected LinkedList<AT_Row> |
rows
Rows of the table.
|
| Constructor and Description |
|---|
AsciiTable()
Creates a new ASCII table with a default context.
|
AsciiTable(AT_Context ctx)
Creates a new ASCII table with given context.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addHeavyRule()
Adds a rule with heavy (super emphasized) style row to the table.
|
void |
addLightRule()
Adds a rule with light (less emphasized) style row to the table.
|
AT_Row |
addRow(Collection<?> columns)
Adds a content row to the table.
|
AT_Row |
addRow(Object... columns)
Adds a content row to the table.
|
void |
addRule()
Adds a rule row to the table using the default style
TableRowStyle.NORMAL. |
void |
addRule(TableRowStyle style)
Adds a rule row to the table with a given style.
|
void |
addStrongRule()
Adds a rule with strong (emphasized) style row to the table.
|
int |
getColNumber()
Returns the set number of columns in the table.
|
AT_Context |
getContext()
Returns the table context.
|
LinkedList<AT_Row> |
getRawContent() |
AT_Renderer |
getRenderer() |
String |
render() |
String |
render(int width) |
Collection<String> |
renderAsCollection() |
Collection<String> |
renderAsCollection(int width) |
AsciiTable |
setCharTranslator(CharacterTranslator charTranslator)
Sets the character translator for all cells in the table.
|
AsciiTable |
setHtmlElementTranslator(HtmlElementTranslator htmlElementTranslator)
Sets the HTML entity translator for all cells in the table.
|
AsciiTable |
setPadding(int padding)
Sets all padding for all cells in the table to the same value.
|
AsciiTable |
setPaddingBottom(int paddingBottom)
Sets the bottom padding for all cells in the table.
|
AsciiTable |
setPaddingBottomChar(Character paddingBottomChar)
Sets the bottom padding character for all cells in the table.
|
AsciiTable |
setPaddingLeft(int paddingLeft)
Sets the left padding for all cells in the table.
|
AsciiTable |
setPaddingLeftChar(Character paddingLeftChar)
Sets the left padding character for all cells in the table.
|
AsciiTable |
setPaddingLeftRight(int padding)
Sets left and right padding for all cells in the table.
|
AsciiTable |
setPaddingLeftRight(int paddingLeft,
int paddingRight)
Sets left and right padding for all cells in the table (only if both values are not smaller than 0).
|
AsciiTable |
setPaddingRight(int paddingRight)
Sets the right padding for all cells in the table.
|
AsciiTable |
setPaddingRightChar(Character paddingRightChar)
Sets the right padding character for all cells in the table.
|
AsciiTable |
setPaddingTop(int paddingTop)
Sets the top padding for all cells in the table.
|
AsciiTable |
setPaddingTopBottom(int padding)
Sets top and bottom padding for all cells in the table.
|
AsciiTable |
setPaddingTopBottom(int paddingTop,
int paddingBottom)
Sets top and bottom padding for all cells in the table (only if both values are not smaller than 0).
|
AsciiTable |
setPaddingTopChar(Character paddingTopChar)
Sets the top padding character for all cells in the table.
|
AsciiTable |
setRenderer(AT_Renderer renderer)
Sets the table renderer.
|
AsciiTable |
setTargetTranslator(TargetTranslator targetTranslator)
Sets the target translator for all cells in the table.
|
AsciiTable |
setTextAlignment(TextAlignment textAlignment)
Sets the text alignment for all cells in the table.
|
StrBuilder |
toLog() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitprotected AT_Context ctx
The table context with optional settings for the table.
protected AT_Renderer renderer
The renderer for the paragraph, default is AP_Renderer.
protected final LinkedList<AT_Row> rows
Rows of the table.
protected int colNumber
Number of columns for the table.
public AsciiTable()
Creates a new ASCII table with a default context.
public AsciiTable(AT_Context ctx)
Creates a new ASCII table with given context.
ctx - the table context, default context created if nullpublic final AT_Row addRow(Collection<?> columns) throws NullPointerException, AsciiTableException
Adds a content row to the table.
For the first content row added, the number of objects given here determines the number of columns in the table.
For every subsequent content row, the array must have an entry for each column,
i.e. the size of the array must be the same as the result of getColNumber().
columns - content of the columns for the row, must not be null{@link - NullPointerException} if columns was null{@link - AsciiTableException} if columns does not have the correct size (more or less entries than columns defined for the table)NullPointerExceptionAsciiTableExceptionpublic final AT_Row addRow(Object... columns) throws NullPointerException, AsciiTableException
Adds a content row to the table.
For the first content row added, the number of objects given here determines the number of columns in the table.
For every subsequent content row, the array must have an entry for each column,
i.e. the size of the array must be the same as the result of getColNumber().
columns - content of the columns for the row, must not be null{@link - NullPointerException} if columns was null{@link - AsciiTableException} if columns does not have the correct size (more or less entries than columns defined for the table)NullPointerExceptionAsciiTableExceptionpublic final void addRule()
Adds a rule row to the table using the default style TableRowStyle.NORMAL.
public final void addRule(TableRowStyle style)
Adds a rule row to the table with a given style.
style - the rule style, must not be null nor TableRowStyle.UNKNOWN{@link - NullPointerException} if style was null{@link - IllegalArgumentException} if style was TableRowStyle.UNKNOWNpublic final void addStrongRule()
Adds a rule with strong (emphasized) style row to the table.
public final void addHeavyRule()
Adds a rule with heavy (super emphasized) style row to the table.
public final void addLightRule()
Adds a rule with light (less emphasized) style row to the table.
public int getColNumber()
Returns the set number of columns in the table.
public AT_Context getContext()
Returns the table context.
getContext in interface IsTablegetContext in interface HasObjectContextpublic LinkedList<AT_Row> getRawContent()
getRawContent in interface IsDocumentElementgetRawContent in interface IsTablepublic AT_Renderer getRenderer()
getRenderer in interface IsTablegetRenderer in interface HasRendererpublic String render()
render in interface DoesRenderpublic String render(int width)
render in interface DoesRenderToWidthpublic Collection<String> renderAsCollection()
renderAsCollection in interface RendersToClusterpublic Collection<String> renderAsCollection(int width)
renderAsCollection in interface RendersToClusterWidthpublic AsciiTable setRenderer(AT_Renderer renderer)
Sets the table renderer.
renderer - new renderer, ignored if nullpublic StrBuilder toLog()
toLog in interface HasToLogpublic AsciiTable setPadding(int padding)
Sets all padding for all cells in the table to the same value.
padding - new padding for top, bottom, left, and right, ignored if smaller than 0public AsciiTable setPaddingBottom(int paddingBottom)
Sets the bottom padding for all cells in the table.
paddingBottom - new padding, ignored if smaller than 0public AsciiTable setPaddingBottomChar(Character paddingBottomChar)
Sets the bottom padding character for all cells in the table.
paddingBottomChar - new padding character, ignored if nullpublic AsciiTable setPaddingLeft(int paddingLeft)
Sets the left padding for all cells in the table.
paddingLeft - new padding, ignored if smaller than 0public AsciiTable setPaddingLeftChar(Character paddingLeftChar)
Sets the left padding character for all cells in the table.
paddingLeftChar - new padding character, ignored if nullpublic AsciiTable setPaddingLeftRight(int padding)
Sets left and right padding for all cells in the table.
padding - new padding for left and right, ignored if smaller than 0public AsciiTable setPaddingLeftRight(int paddingLeft, int paddingRight)
Sets left and right padding for all cells in the table (only if both values are not smaller than 0).
paddingLeft - new left padding, ignored if smaller than 0paddingRight - new right padding, ignored if smaller than 0public AsciiTable setPaddingRight(int paddingRight)
Sets the right padding for all cells in the table.
paddingRight - new padding, ignored if smaller than 0public AsciiTable setPaddingRightChar(Character paddingRightChar)
Sets the right padding character for all cells in the table.
paddingRightChar - new padding character, ignored if nullpublic AsciiTable setPaddingTop(int paddingTop)
Sets the top padding for all cells in the table.
paddingTop - new padding, ignored if smaller than 0public AsciiTable setPaddingTopBottom(int padding)
Sets top and bottom padding for all cells in the table.
padding - new padding for top and bottom, ignored if smaller than 0public AsciiTable setPaddingTopBottom(int paddingTop, int paddingBottom)
Sets top and bottom padding for all cells in the table (only if both values are not smaller than 0).
paddingTop - new top padding, ignored if smaller than 0paddingBottom - new bottom padding, ignored if smaller than 0public AsciiTable setPaddingTopChar(Character paddingTopChar)
Sets the top padding character for all cells in the table.
paddingTopChar - new padding character, ignored if nullpublic AsciiTable setTextAlignment(TextAlignment textAlignment)
Sets the text alignment for all cells in the table.
textAlignment - new text alignmentNullPointerException - if the argument was null{@link - NullPointerException} if the argument was nullpublic AsciiTable setTargetTranslator(TargetTranslator targetTranslator)
Sets the target translator for all cells in the table. It will also remove any other translator set. Nothing will happen if the argument is null.
targetTranslator - translatorpublic AsciiTable setHtmlElementTranslator(HtmlElementTranslator htmlElementTranslator)
Sets the HTML entity translator for all cells in the table. It will also remove any other translator set. Nothing will happen if the argument is null.
htmlElementTranslator - translatorpublic AsciiTable setCharTranslator(CharacterTranslator charTranslator)
Sets the character translator for all cells in the table. It will also remove any other translator set. Nothing will happen if the argument is null.
charTranslator - translatorCopyright © 2014–2017. All rights reserved.