static TableContext of(AsciidocHandler handler, AttributeList attList, int lineNumber) { TableContext ctx = new TableContext(); ctx.handler = handler; ctx.attList = attList; ctx.columns = ColumnsContext.empty(attList); ctx.lineNumber = lineNumber; return ctx; }
void flush() { columns.commit(); handler.startTable(attList); handler.startColumnGroup(); ColumnContext col = columns.rootColumn; for (int i = 0; i < columns.count; i++) { handler.column(attList, col.width); col = col.next; } handler.endColumnGroup(); int fill = 0; CellContext cell = columns.rootCell; if (columns.header.equals(ColumnsContext.Header.Header)) { handler.startTableHeader(); handler.startTableRow(); while (cell != null && fill < columns.count) { fill++; handler.startTableHeaderCell(); handler.writeTableHeaderCellContent(cell.text); handler.endTableHeaderCell(); cell = cell.next; } handler.endTableRow(); handler.endTableHeader(); fill = 0; } handler.startTableBody(); while (cell != null) { if (fill == 0) { handler.startTableRow(); } fill++; handler.startTableCell(); handler.writeTableCellContent(cell.text); handler.endTableCell(); if (fill == columns.count) { handler.endTableRow(); fill = 0; } cell = cell.next; } handler.endTableBody(); handler.endTable(); }
void addCell(int lineNumber) { columns.addCell(lineNumber - this.lineNumber); }
static ColumnsContext empty(AttributeList attList) { ColumnsContext columns = new ColumnsContext(); columns.attList = attList; columns.header = Header.Undefined; return columns; }