Package com.vladsch.flexmark.util.format
Class MarkdownTable
- java.lang.Object
-
- com.vladsch.flexmark.util.format.MarkdownTable
-
public class MarkdownTable extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MarkdownTable.IndexSpanOffset
-
Field Summary
Fields Modifier and Type Field Description static NumericSuffixPredicate
ALL_SUFFIXES_NO_SORT
static NumericSuffixPredicate
ALL_SUFFIXES_SORT
TableSection
body
TableSection
caption
static CharPredicate
COLON_TRIM_CHARS
TableSection
header
static NumericSuffixPredicate
NO_SUFFIXES
TableFormatOptions
options
TableSection
separator
-
Constructor Summary
Constructors Constructor Description MarkdownTable(java.lang.CharSequence tableChars, DataHolder options)
MarkdownTable(java.lang.CharSequence tableChars, TableFormatOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addCell(TableCell cell)
boolean
addTrackedOffset(int offset)
Deprecated.UseaddTrackedOffset(TrackedOffset)
To create: TrackedOffset.track(offset)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, java.lang.Character c, boolean afterDelete)
Deprecated.UseaddTrackedOffset(TrackedOffset)
To create: TrackedOffset.track(offset, c, afterDelete)boolean
addTrackedOffset(TrackedOffset trackedOffset)
static void
appendFormattedCaption(LineAppendable out, BasedSequence caption, TableFormatOptions options)
void
appendTable(LineAppendable out)
void
deleteColumns(int column, int count)
void
deleteRows(int rowIndex, int count)
void
fillMissingColumns()
void
fillMissingColumns(java.lang.Integer minColumn)
void
finalizeTable()
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)
static java.lang.String
formattedCaption(BasedSequence caption, TableFormatOptions options)
java.util.List<TableRow>
getAllContentRows()
int
getAllContentRowsCount()
java.util.List<TableRow>
getAllRows()
int
getAllRowsCount()
TableSection
getAllRowsSection(int index)
java.util.List<TableRow>
getAllSectionRows()
int
getAllSectionsRowsCount()
int
getBodyRowCount()
BasedSequence
getCaption()
TableCell
getCaptionCell()
int
getCaptionRowCount()
TableCellOffsetInfo
getCellOffsetInfo(int offset)
java.lang.CharSequence
getFormatTableIndentPrefix()
boolean
getHaveCaption()
boolean
getHeader()
int
getHeadingRowCount()
int
getMaxBodyColumns()
int
getMaxColumns()
int
getMaxColumnsWithoutColumns(boolean withSeparator, int... skipColumns)
int
getMaxColumnsWithoutRows(boolean withSeparator, int... skipRows)
int
getMaxHeadingColumns()
int
getMaxSeparatorColumns()
int
getMinColumns()
int
getMinColumnsWithoutColumns(boolean withSeparator, int... skipColumns)
int
getMinColumnsWithoutRows(boolean withSeparator, int... skipRows)
int
getSeparatorRowCount()
java.lang.CharSequence
getTableChars()
int
getTableStartOffset()
TrackedOffset
getTrackedOffset(int offset)
int
getTrackedOffsetIndex(int offset)
java.util.List<TrackedOffset>
getTrackedOffsets()
void
insertColumns(int column, int count)
void
insertRows(int rowIndex, int count)
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.boolean
isSeparator()
void
moveColumn(int fromColumn, int toColumn)
void
nextRow()
void
normalize()
void
setBody()
void
setCaption(java.lang.CharSequence caption)
void
setCaptionCell(TableCell captionCell)
void
setCaptionWithMarkers(Node tableCellNode, java.lang.CharSequence captionOpen, java.lang.CharSequence caption, java.lang.CharSequence captionClose)
void
setFormatTableIndentPrefix(java.lang.CharSequence formatTableIndentPrefix)
void
setHeader()
void
setHeader(boolean header)
void
setSeparator()
void
setSeparator(boolean separator)
MarkdownTable
sorted(ColumnSort[] columnSorts, int textCollectionFlags, NumericSuffixPredicate numericSuffixTester)
Sort tablejava.lang.String
toString()
MarkdownTable
transposed(int columnHeaders)
Transpose table
-
-
-
Field Detail
-
header
public final TableSection header
-
separator
public final TableSection separator
-
body
public final TableSection body
-
caption
public final TableSection caption
-
options
public TableFormatOptions options
-
COLON_TRIM_CHARS
public static final CharPredicate COLON_TRIM_CHARS
-
NO_SUFFIXES
public static final NumericSuffixPredicate NO_SUFFIXES
-
ALL_SUFFIXES_SORT
public static final NumericSuffixPredicate ALL_SUFFIXES_SORT
-
ALL_SUFFIXES_NO_SORT
public static final NumericSuffixPredicate ALL_SUFFIXES_NO_SORT
-
-
Constructor Detail
-
MarkdownTable
public MarkdownTable(@NotNull java.lang.CharSequence tableChars, @Nullable DataHolder options)
-
MarkdownTable
public MarkdownTable(@NotNull java.lang.CharSequence tableChars, @Nullable TableFormatOptions options)
-
-
Method Detail
-
getTableChars
public java.lang.CharSequence getTableChars()
-
getCaptionCell
public TableCell getCaptionCell()
-
getFormatTableIndentPrefix
public java.lang.CharSequence getFormatTableIndentPrefix()
-
setFormatTableIndentPrefix
public void setFormatTableIndentPrefix(java.lang.CharSequence formatTableIndentPrefix)
-
setCaptionCell
public void setCaptionCell(TableCell captionCell)
-
getCaption
public BasedSequence getCaption()
-
setCaption
public void setCaption(java.lang.CharSequence caption)
-
setCaptionWithMarkers
public void setCaptionWithMarkers(Node tableCellNode, java.lang.CharSequence captionOpen, java.lang.CharSequence caption, java.lang.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
@NotNull public java.util.List<TrackedOffset> getTrackedOffsets()
-
getTrackedOffset
@Nullable public TrackedOffset getTrackedOffset(int offset)
-
getTrackedOffsetIndex
public int getTrackedOffsetIndex(int offset)
-
getTableStartOffset
public int getTableStartOffset()
-
getCellOffsetInfo
public TableCellOffsetInfo getCellOffsetInfo(int offset)
-
addTrackedOffset
@Deprecated public boolean addTrackedOffset(int offset)
Deprecated.UseaddTrackedOffset(TrackedOffset)
To create: TrackedOffset.track(offset)
-
addTrackedOffset
@Deprecated public boolean addTrackedOffset(int offset, boolean afterSpace)
Deprecated.UseaddTrackedOffset(TrackedOffset)
To create: TrackedOffset.track(offset, afterSpace)
-
addTrackedOffset
@Deprecated public boolean addTrackedOffset(int offset, boolean afterSpace, boolean afterDelete)
Deprecated.UseaddTrackedOffset(TrackedOffset)
To create: TrackedOffset.track(offset, afterSpace, afterDelete)
-
addTrackedOffset
@Deprecated public boolean addTrackedOffset(int offset, java.lang.Character c, boolean afterDelete)
Deprecated.UseaddTrackedOffset(TrackedOffset)
To create: TrackedOffset.track(offset, c, afterDelete)
-
addTrackedOffset
public boolean addTrackedOffset(@NotNull TrackedOffset trackedOffset)
-
getAllRows
public java.util.List<TableRow> getAllRows()
-
getAllContentRows
public java.util.List<TableRow> getAllContentRows()
-
getAllSectionRows
public java.util.List<TableRow> getAllSectionRows()
-
isAllRowsSeparator
public boolean isAllRowsSeparator(int index)
-
getAllRowsSection
public TableSection getAllRowsSection(int index)
-
getAllRowsCount
public int getAllRowsCount()
-
getAllContentRowsCount
public int getAllContentRowsCount()
-
getAllSectionsRowsCount
public int getAllSectionsRowsCount()
-
forAllRows
public void forAllRows(TableRowManipulator manipulator)
-
forAllRows
public void forAllRows(int startIndex, TableRowManipulator manipulator)
-
forAllRows
public void forAllRows(int startIndex, int count, TableRowManipulator manipulator)
-
forAllContentRows
public void forAllContentRows(TableRowManipulator manipulator)
-
forAllContentRows
public void forAllContentRows(int startIndex, TableRowManipulator manipulator)
-
forAllContentRows
public void forAllContentRows(int startIndex, int count, TableRowManipulator manipulator)
-
forAllSectionRows
public void forAllSectionRows(TableRowManipulator manipulator)
-
forAllSectionRows
public void forAllSectionRows(int startIndex, TableRowManipulator manipulator)
-
forAllSectionRows
public void forAllSectionRows(int startIndex, int count, TableRowManipulator manipulator)
-
forAllHeaderRows
public void forAllHeaderRows(TableRowManipulator manipulator)
-
forAllHeaderRows
public void forAllHeaderRows(int startIndex, TableRowManipulator manipulator)
-
forAllHeaderRows
public void forAllHeaderRows(int startIndex, int count, TableRowManipulator manipulator)
-
forAllBodyRows
public void forAllBodyRows(TableRowManipulator manipulator)
-
forAllBodyRows
public void forAllBodyRows(int startIndex, TableRowManipulator manipulator)
-
forAllBodyRows
public void forAllBodyRows(int startIndex, int count, TableRowManipulator manipulator)
-
deleteRows
public void deleteRows(int rowIndex, int count)
-
insertRows
public void insertRows(int rowIndex, int count)
-
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
-
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
public void addCell(@NotNull TableCell cell)
- Parameters:
cell
- cell to add
-
normalize
public void normalize()
-
finalizeTable
public void finalizeTable()
-
fillMissingColumns
public void fillMissingColumns()
-
fillMissingColumns
public void fillMissingColumns(java.lang.Integer minColumn)
-
transposed
public MarkdownTable transposed(int columnHeaders)
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 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
-
appendTable
public void appendTable(LineAppendable out)
-
appendFormattedCaption
public static void appendFormattedCaption(LineAppendable out, BasedSequence caption, TableFormatOptions options)
-
formattedCaption
public static java.lang.String formattedCaption(BasedSequence caption, TableFormatOptions options)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-