MCPcopy Create free account
hub / github.com/RealTimeGenomics/rtg-tools / toString

Method toString

src/main/java/com/rtg/util/TextTable.java:218–245  ·  view source on GitHub ↗

Add formatted table to string builder @param sb string builder to append to

(StringBuilder sb)

Source from the content-addressed store, hash-verified

216 * @param sb string builder to append to
217 */
218 public void toString(StringBuilder sb) {
219 final int rows = mTableContents.size();
220 if (rows > 0) {
221 final int columns = mTableContents.get(0).size();
222 if (columns > 0) {
223 final int[] maxLengths = mColumnWidths;
224 final long totalWidth = getTotalWidth();
225 for (final ArrayList<String> row : mTableContents) {
226 if (row == SEPARATOR) {
227 for (long j = 0; j < totalWidth; ++j) {
228 sb.append('-');
229 }
230 } else {
231 for (int j = 0; j < columns; ++j) {
232 if (j == 0) {
233 appendSpaces(sb, mInitialIndent);
234 } else {
235 appendSpaces(sb, mTabWidth);
236 }
237 final Align align = j < mAlignment.length ? mAlignment[j] : mDefaultAlignment;
238 align.appendCell(sb, maxLengths[j], row.get(j));
239 }
240 }
241 sb.append(StringUtils.LS);
242 }
243 }
244 }
245 }
246
247 /**
248 * Output the table as basic tab separated

Callers 5

testDefaultMethod · 0.95
testIndentMethod · 0.95
writeSummaryMethod · 0.95
mainExecMethod · 0.95

Calls 7

getTotalWidthMethod · 0.95
appendSpacesMethod · 0.95
appendCellMethod · 0.95
getMethod · 0.65
appendMethod · 0.65
toStringMethod · 0.65
sizeMethod · 0.45

Tested by 3

testDefaultMethod · 0.76
testIndentMethod · 0.76