Add a row of entries to the table Each row must be the same length and contain no nulls @param cells the cells to add
(String... cells)
| 152 | * @param cells the cells to add |
| 153 | */ |
| 154 | public void addRow(String... cells) { |
| 155 | if (mTableContents.size() > 0 && mTableContents.get(0).size() != cells.length) { |
| 156 | throw new SlimException("Mismatching number of columns in table formatter"); |
| 157 | } |
| 158 | if (cells.length < mAlignment.length) { |
| 159 | throw new SlimException("Too many alignment values supplied for number of columns supplied in row"); |
| 160 | } |
| 161 | if (mColumnWidths == null) { |
| 162 | mColumnWidths = new int[cells.length]; |
| 163 | } |
| 164 | final ArrayList<String> cellList = new ArrayList<>(cells.length); |
| 165 | int col = 0; |
| 166 | for (final String cell : cells) { |
| 167 | if (cell == null) { |
| 168 | throw new SlimException("Null provided as value in table formatters"); |
| 169 | } |
| 170 | cellList.add(cell); |
| 171 | mColumnWidths[col] = Math.max(mColumnWidths[col], cell.length()); |
| 172 | ++col; |
| 173 | } |
| 174 | mTableContents.add(cellList); |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * Add a separator line to the table. |