Package com.vladsch.flexmark.util.format
Class MarkdownTable
java.lang.Object
com.vladsch.flexmark.util.format.MarkdownTable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate CellAlignment[]
private final TableSection[]
private final TableSection[]
private final TableSection[]
private final TableSection[]
static final NumericSuffixPredicate
static final NumericSuffixPredicate
private final TableSection[]
final TableSection
final TableSection
static final CharPredicate
private int[]
(package private) CharSequence
final TableSection
private boolean
private boolean
static final NumericSuffixPredicate
final TableSection
private final CharSequence
private final @NotNull ArrayList<TrackedOffset>
-
Constructor Summary
ConstructorsConstructorDescriptionMarkdownTable
(@NotNull CharSequence tableChars, @Nullable DataHolder options) MarkdownTable
(@NotNull CharSequence tableChars, @Nullable TableFormatOptions options) -
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
addTrackedOffset
(int offset) Deprecated.boolean
addTrackedOffset
(int offset, boolean afterSpace) Deprecated.UseaddTrackedOffset(TrackedOffset)
To create: TrackedOffset.track(offset, afterSpace)boolean
addTrackedOffset
(int offset, boolean afterSpace, boolean afterDelete) Deprecated.UseaddTrackedOffset(TrackedOffset)
To create: TrackedOffset.track(offset, afterSpace, afterDelete)boolean
addTrackedOffset
(int offset, Character c, boolean afterDelete) Deprecated.UseaddTrackedOffset(TrackedOffset)
To create: TrackedOffset.track(offset, c, afterDelete)boolean
addTrackedOffset
(@NotNull TrackedOffset trackedOffset) private CellAlignment
adjustCellAlignment
(CellAlignment alignment) private int
aggregateTotalColumnsWithoutColumns
(TableSection[] sections, BiFunction<Integer, Integer, Integer> aggregator, int... skipColumns) private int
aggregateTotalColumnsWithoutRows
(TableSection[] sections, BiFunction<Integer, Integer, Integer> aggregator, int... skipRows) private void
appendColumnSpan
(LineAppendable out, int span, int cellInsideEndOffset, int trackedSpanOffset) (package private) int
appendDashes
(LineAppendable out, int dashCount, BasedSequence sepDashes, int dashOffset) static void
appendFormattedCaption
(LineAppendable out, BasedSequence caption, TableFormatOptions options) private void
appendRows
(LineAppendable out, List<TableRow> rows, boolean isHeader, CharSequence linePrefix) void
private BasedSequence
cellText
(List<TableCell> cells, int index, boolean withTrackedOffset, boolean isHeader, int width, CellAlignment alignment, Ref<Integer> delta) void
deleteColumns
(int column, int count) void
deleteRows
(int rowIndex, int count) void
void
fillMissingColumns
(Integer minColumn) void
private @Nullable TrackedOffset
findTrackedOffset
(int offset) void
forAllBodyRows
(int startIndex, int count, TableRowManipulator manipulator) void
forAllBodyRows
(int startIndex, TableRowManipulator manipulator) void
forAllBodyRows
(TableRowManipulator manipulator) void
forAllContentRows
(int startIndex, int count, TableRowManipulator manipulator) void
forAllContentRows
(int startIndex, TableRowManipulator manipulator) void
forAllContentRows
(TableRowManipulator manipulator) void
forAllHeaderRows
(int startIndex, int count, TableRowManipulator manipulator) void
forAllHeaderRows
(int startIndex, TableRowManipulator manipulator) void
forAllHeaderRows
(TableRowManipulator manipulator) void
forAllRows
(int startIndex, int count, TableRowManipulator manipulator) void
forAllRows
(int startIndex, TableRowManipulator manipulator) void
forAllRows
(TableRowManipulator manipulator) void
forAllSectionRows
(int startIndex, int count, TableRowManipulator manipulator) void
forAllSectionRows
(int startIndex, TableRowManipulator manipulator) void
forAllSectionRows
(TableRowManipulator manipulator) private void
forAllSectionsRows
(int startIndex, int count, TableSection[] sections, TableRowManipulator manipulator) static String
formattedCaption
(BasedSequence caption, TableFormatOptions options) int
int
getAllRowsSection
(int index) getAllSectionsRows
(TableSection... sections) int
int
int
getCellOffsetInfo
(int offset) boolean
boolean
int
int
int
int
getMaxColumnsWithoutColumns
(boolean withSeparator, int... skipColumns) int
getMaxColumnsWithoutRows
(boolean withSeparator, int... skipRows) int
int
int
int
getMinColumnsWithoutColumns
(boolean withSeparator, int... skipColumns) int
getMinColumnsWithoutRows
(boolean withSeparator, int... skipRows) int
int
@Nullable TrackedOffset
getTrackedOffset
(int offset) int
getTrackedOffsetIndex
(int offset) @NotNull List<TrackedOffset>
void
insertColumns
(int column, int count) void
insertRows
(int rowIndex, int count) private void
insertRows
(ArrayList<TableRow> rows, int index, int count, int maxColumns) boolean
isAllRowsEmptyAt
(int rowIndex) Test a row for having all empty columnsboolean
isAllRowsSeparator
(int index) boolean
isContentRowsEmptyAt
(int rowIndex) Test a row for having all empty columnsboolean
isEmptyColumn
(int column) Test all rows for having given column empty.private boolean
isEmptyRowAt
(int rowIndex, TableSection[] sections) Test a row for having all empty columnsboolean
void
moveColumn
(int fromColumn, int toColumn) void
nextRow()
void
private boolean
pipeNeedsSpaceAfter
(TableCell cell) private boolean
void
setBody()
void
setCaption
(CharSequence caption) void
setCaptionCell
(TableCell captionCell) void
setCaptionWithMarkers
(Node tableCellNode, CharSequence captionOpen, CharSequence caption, CharSequence captionClose) void
setFormatTableIndentPrefix
(CharSequence formatTableIndentPrefix) void
void
setHeader
(boolean header) void
void
setSeparator
(boolean separator) private boolean
setTrackedOffsetIndex
(int offset, int index) sorted
(ColumnSort[] columnSorts, int textCollectionFlags, @Nullable NumericSuffixPredicate numericSuffixTester) Sort tableprivate int
spanFixedWidth
(BitSet unfixedColumns, int col, int columnSpan) private int
spanWidth
(int col, int columnSpan) toString()
transposed
(int columnHeaders) Transpose table
-
Field Details
-
header
-
separator
-
body
-
caption
-
options
-
isHeading
private boolean isHeading -
isSeparator
private boolean isSeparator -
formatTableIndentPrefix
CharSequence formatTableIndentPrefix -
alignments
-
columnWidths
private int[] columnWidths -
trackedOffsets
-
ALL_SECTIONS
-
ALL_TABLE_ROWS
-
ALL_CONTENT_ROWS
-
ALL_HEADER_ROWS
-
ALL_BODY_ROWS
-
COLON_TRIM_CHARS
-
tableChars
-
NO_SUFFIXES
-
ALL_SUFFIXES_SORT
-
ALL_SUFFIXES_NO_SORT
-
-
Constructor Details
-
MarkdownTable
public MarkdownTable(@NotNull @NotNull CharSequence tableChars, @Nullable @Nullable DataHolder options) -
MarkdownTable
public MarkdownTable(@NotNull @NotNull CharSequence tableChars, @Nullable @Nullable TableFormatOptions options)
-
-
Method Details
-
getTableChars
-
getCaptionCell
-
getFormatTableIndentPrefix
-
setFormatTableIndentPrefix
-
setCaptionCell
-
getCaption
-
setCaption
-
setCaptionWithMarkers
public void setCaptionWithMarkers(Node tableCellNode, CharSequence captionOpen, CharSequence caption, CharSequence captionClose) -
getHeadingRowCount
public int getHeadingRowCount() -
getSeparatorRowCount
public int getSeparatorRowCount() -
getBodyRowCount
public int getBodyRowCount() -
getCaptionRowCount
public int getCaptionRowCount() -
getMaxHeadingColumns
public int getMaxHeadingColumns() -
getMaxSeparatorColumns
public int getMaxSeparatorColumns() -
getMaxBodyColumns
public int getMaxBodyColumns() -
getHaveCaption
public boolean getHaveCaption() -
getMinColumns
public int getMinColumns() -
getMaxColumns
public int getMaxColumns() -
getMinColumnsWithoutColumns
public int getMinColumnsWithoutColumns(boolean withSeparator, int... skipColumns) -
getMaxColumnsWithoutColumns
public int getMaxColumnsWithoutColumns(boolean withSeparator, int... skipColumns) -
getMinColumnsWithoutRows
public int getMinColumnsWithoutRows(boolean withSeparator, int... skipRows) -
getMaxColumnsWithoutRows
public int getMaxColumnsWithoutRows(boolean withSeparator, int... skipRows) -
getTrackedOffsets
-
findTrackedOffset
-
getTrackedOffset
-
getTrackedOffsetIndex
public int getTrackedOffsetIndex(int offset) -
getTableStartOffset
public int getTableStartOffset() -
getCellOffsetInfo
-
addTrackedOffset
Deprecated.UseaddTrackedOffset(TrackedOffset)
To create: TrackedOffset.track(offset) -
addTrackedOffset
Deprecated.UseaddTrackedOffset(TrackedOffset)
To create: TrackedOffset.track(offset, afterSpace) -
addTrackedOffset
Deprecated.UseaddTrackedOffset(TrackedOffset)
To create: TrackedOffset.track(offset, afterSpace, afterDelete) -
addTrackedOffset
Deprecated.UseaddTrackedOffset(TrackedOffset)
To create: TrackedOffset.track(offset, c, afterDelete) -
addTrackedOffset
-
getAllRows
-
getAllContentRows
-
getAllSectionRows
-
getAllSectionsRows
-
isAllRowsSeparator
public boolean isAllRowsSeparator(int index) -
getAllRowsSection
-
getAllRowsCount
public int getAllRowsCount() -
getAllContentRowsCount
public int getAllContentRowsCount() -
getAllSectionsRowsCount
public int getAllSectionsRowsCount() -
forAllRows
-
forAllRows
-
forAllRows
-
forAllContentRows
-
forAllContentRows
-
forAllContentRows
-
forAllSectionRows
-
forAllSectionRows
-
forAllSectionRows
-
forAllHeaderRows
-
forAllHeaderRows
-
forAllHeaderRows
-
forAllBodyRows
-
forAllBodyRows
-
forAllBodyRows
-
deleteRows
public void deleteRows(int rowIndex, int count) -
insertRows
public void insertRows(int rowIndex, int count) -
insertRows
-
insertColumns
public void insertColumns(int column, int count) -
deleteColumns
public void deleteColumns(int column, int count) -
moveColumn
public void moveColumn(int fromColumn, int toColumn) -
isEmptyColumn
public boolean isEmptyColumn(int column) Test all rows for having given column empty. All columns after row's max column are empty- Parameters:
column
- index in allRows list- Returns:
- true if column is empty for all rows, separator row excluded
-
isAllRowsEmptyAt
public boolean isAllRowsEmptyAt(int rowIndex) Test a row for having all empty columns- Parameters:
rowIndex
- index in allRows list- Returns:
- true if row is empty or is a separator row
-
isContentRowsEmptyAt
public boolean isContentRowsEmptyAt(int rowIndex) Test a row for having all empty columns- Parameters:
rowIndex
- index in allRows list- Returns:
- true if row is empty or is a separator row
-
isEmptyRowAt
Test a row for having all empty columns- Parameters:
rowIndex
- index in allRows listsections
- sections to use for rows array generation- Returns:
- true if row is empty or is a separator row
-
getHeader
public boolean getHeader() -
setHeader
public void setHeader(boolean header) -
isSeparator
public boolean isSeparator() -
setSeparator
public void setSeparator(boolean separator) -
setHeader
public void setHeader() -
setSeparator
public void setSeparator() -
setBody
public void setBody() -
nextRow
public void nextRow() -
addCell
- Parameters:
cell
- cell to add
-
normalize
public void normalize() -
finalizeTable
public void finalizeTable() -
fillMissingColumns
public void fillMissingColumns() -
fillMissingColumns
-
setTrackedOffsetIndex
private boolean setTrackedOffsetIndex(int offset, int index) -
transposed
Transpose table- Parameters:
columnHeaders
- number of first columns to use as header rows, 0..maxColumns- Returns:
- transposed table
-
sorted
public MarkdownTable sorted(ColumnSort[] columnSorts, int textCollectionFlags, @Nullable @Nullable NumericSuffixPredicate numericSuffixTester) Sort table- Parameters:
columnSorts
- column sort informationtextCollectionFlags
- collection flags to use for collecting cell textnumericSuffixTester
- predicate to test non-numeric suffix of numeric column content, return true if suffix is acceptable, null will result in all suffixes being accepted- Returns:
- sorted table
-
appendDashes
-
appendTable
-
appendFormattedCaption
public static void appendFormattedCaption(LineAppendable out, BasedSequence caption, TableFormatOptions options) -
formattedCaption
-
pipeNeedsSpaceBefore
-
pipeNeedsSpaceAfter
-
appendRows
private void appendRows(LineAppendable out, List<TableRow> rows, boolean isHeader, CharSequence linePrefix) -
appendColumnSpan
private void appendColumnSpan(LineAppendable out, int span, int cellInsideEndOffset, int trackedSpanOffset) -
cellText
private BasedSequence cellText(List<TableCell> cells, int index, boolean withTrackedOffset, boolean isHeader, int width, CellAlignment alignment, Ref<Integer> delta) -
spanWidth
private int spanWidth(int col, int columnSpan) -
spanFixedWidth
-
adjustCellAlignment
-
aggregateTotalColumnsWithoutColumns
private int aggregateTotalColumnsWithoutColumns(TableSection[] sections, BiFunction<Integer, Integer, Integer> aggregator, int... skipColumns) -
aggregateTotalColumnsWithoutRows
private int aggregateTotalColumnsWithoutRows(TableSection[] sections, BiFunction<Integer, Integer, Integer> aggregator, int... skipRows) -
forAllSectionsRows
private void forAllSectionsRows(int startIndex, int count, TableSection[] sections, TableRowManipulator manipulator) -
toString
-
addTrackedOffset(TrackedOffset)
To create: TrackedOffset.track(offset)