Top Constructors Methods
liquibase.util

public Class TableOutput

extends Object
Class Inheritance
Imports
liquibase.exception.LiquibaseException, java.io.IOException, .Writer, java.util.ArrayList, .Arrays, .Collections, .List, java.util.stream.Collectors, .IntStream

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static boolean
public static List<Integer>

Returns:

an empty immutable list if the provided table is empty
computeMaxWidths
(List<List<String>>
the provided table to compute widths from
rows
)

Compute the size of the largest string of each column of the provided table

public static List<Integer>

Returns:

an empty immutable list if the provided table is empty
computeMaxWidths
(String[][]
the provided table to compute widths from
rows
)

Compute the size of the largest string of each column of the provided table

private static int

Returns:

the new current running width
doAppend
(int
the current running width
runningWidth
,
String
the part to append
part
,
int
the maxwidth for this column
maxWidth
,
StringBuilder
the string builder result to append to
result
)

Append the specified part of a string to the string builder and add spaces where needed.

private static int

Returns:

the new current running width (which is always 0, since the line has been filled to the end with spaces)
fillLineWithSpaces
(int
the current running width
runningWidth
,
int
the max width for the column
maxWidth
,
StringBuilder
the result to append spaces to
result
)

Given a current running width and a max width, fill the remaining space on the current line with spaces.

public static void
formatOutput(List<List<String>>
2-dimensional array of data
table
,
List<Integer>
Maximum widths of each column to control wrapping
maxWidths
,
boolean
If true then add "-" to format string
leftJustifiedRows
,
Writer
Writer to use for output
writer
)

This method outputs the input data in a tabular format with wrapping of lines

public static void
formatOutput(List<List<String>>
2-dimensional array of data
table
,
int[]
Maximum widths of each column to control wrapping
maxWidths
,
boolean
If true then add "-" to format string
leftJustifiedRows
,
Writer
Writer to use for output
writer
)

This method outputs the input data in a tabular format with wrapping of lines

public static void
formatOutput(String[][]
2-dimensional array of data
table
,
int[]
Maximum widths of each column to control wrapping
maxWidths
,
boolean
If true then add "-" to format string
leftJustifiedRows
,
Writer
Writer to use for output
writer
)

This method outputs the input data in a tabular format with wrapping of lines

public static void
formatOutput(String[][]
2-dimensional array of data
table
,
List<Integer>
Maximum widths of each column to control wrapping
maxWidths
,
boolean
If true then add "-" to format string
leftJustifiedRows
,
Writer
Writer to use for output
writer
)

This method outputs the input data in a tabular format with wrapping of lines

public static void
formatUnwrappedOutput(List<List<String>>
2-dimensional array of data
table
,
boolean
If true then add "-" to format string
leftJustifiedRows
,
Writer
Writer to use for output
writer
)

This method outputs the input data in a tabular format *without* wrapping of lines

private static String
padColumn(String col, int maxWidth)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

TableOutputback to summary
public TableOutput()

Method Detail

allEmptyStringsback to summary
private static boolean allEmptyStrings(String[] strings)
computeMaxWidthsback to summary
public static List<Integer> computeMaxWidths(List<List<String>> rows)

Compute the size of the largest string of each column of the provided table

Parameters
rows:List<List<String>>

the provided table to compute widths from

Returns:List<Integer>

an empty immutable list if the provided table is empty

Exceptions
RuntimeException:
if rows is null or the column count is not the same for every row
computeMaxWidthsback to summary
public static List<Integer> computeMaxWidths(String[][] rows)

Compute the size of the largest string of each column of the provided table

Parameters
rows:String[][]

the provided table to compute widths from

Returns:List<Integer>

an empty immutable list if the provided table is empty

Exceptions
RuntimeException:
if rows is null or the column count is not the same for every row
doAppendback to summary
private static int doAppend(int runningWidth, String part, int maxWidth, StringBuilder result)

Append the specified part of a string to the string builder and add spaces where needed.

Parameters
runningWidth:int

the current running width

part:String

the part to append

maxWidth:int

the maxwidth for this column

result:StringBuilder

the string builder result to append to

Returns:int

the new current running width

fillLineWithSpacesback to summary
private static int fillLineWithSpaces(int runningWidth, int maxWidth, StringBuilder result)

Given a current running width and a max width, fill the remaining space on the current line with spaces.

Parameters
runningWidth:int

the current running width

maxWidth:int

the max width for the column

result:StringBuilder

the result to append spaces to

Returns:int

the new current running width (which is always 0, since the line has been filled to the end with spaces)

formatOutputback to summary
public static void formatOutput(List<List<String>> table, List<Integer> maxWidths, boolean leftJustifiedRows, Writer writer) throws LiquibaseException

This method outputs the input data in a tabular format with wrapping of lines

Parameters
table:List<List<String>>

2-dimensional array of data

maxWidths:List<Integer>

Maximum widths of each column to control wrapping

leftJustifiedRows:boolean

If true then add "-" to format string

writer:Writer

Writer to use for output

formatOutputback to summary
public static void formatOutput(List<List<String>> table, int[] maxWidths, boolean leftJustifiedRows, Writer writer) throws LiquibaseException

This method outputs the input data in a tabular format with wrapping of lines

Parameters
table:List<List<String>>

2-dimensional array of data

maxWidths:int[]

Maximum widths of each column to control wrapping

leftJustifiedRows:boolean

If true then add "-" to format string

writer:Writer

Writer to use for output

formatOutputback to summary
public static void formatOutput(String[][] table, int[] maxWidths, boolean leftJustifiedRows, Writer writer) throws LiquibaseException

This method outputs the input data in a tabular format with wrapping of lines

Parameters
table:String[][]

2-dimensional array of data

maxWidths:int[]

Maximum widths of each column to control wrapping

leftJustifiedRows:boolean

If true then add "-" to format string

writer:Writer

Writer to use for output

formatOutputback to summary
public static void formatOutput(String[][] table, List<Integer> maxWidths, boolean leftJustifiedRows, Writer writer) throws LiquibaseException

This method outputs the input data in a tabular format with wrapping of lines

Parameters
table:String[][]

2-dimensional array of data

maxWidths:List<Integer>

Maximum widths of each column to control wrapping

leftJustifiedRows:boolean

If true then add "-" to format string

writer:Writer

Writer to use for output

formatUnwrappedOutputback to summary
public static void formatUnwrappedOutput(List<List<String>> table, boolean leftJustifiedRows, Writer writer) throws LiquibaseException

This method outputs the input data in a tabular format *without* wrapping of lines

Parameters
table:List<List<String>>

2-dimensional array of data

leftJustifiedRows:boolean

If true then add "-" to format string

writer:Writer

Writer to use for output

padColumnback to summary
private static String padColumn(String col, int maxWidth)