Returns a textual representation of the table. @return text
()
| 98 | * @return text |
| 99 | */ |
| 100 | public byte[] finish() { |
| 101 | final int[] ind = new int[header.size()]; |
| 102 | final int size = header.size(); |
| 103 | for(int s = 0; s < size; ++s) { |
| 104 | for(final TokenList e : contents) { |
| 105 | ind[s] = Math.max(ind[s], e.get(s).length); |
| 106 | } |
| 107 | ind[s] = Math.max(ind[s], header.get(s).length); |
| 108 | } |
| 109 | |
| 110 | final TokenBuilder tb = new TokenBuilder(); |
| 111 | for(int u = 0; u < size; ++u) { |
| 112 | final byte[] s = header.get(u); |
| 113 | final int is = ind[u] - s.length + DIST; |
| 114 | tb.add(s); |
| 115 | for(int i = 0; i < is; ++i) tb.add(' '); |
| 116 | } |
| 117 | tb.add(NL); |
| 118 | for(int u = 0; u < size; ++u) { |
| 119 | for(int i = 0; i < ind[u] + (u + 1 == size ? 0 : DIST); ++i) tb.add('-'); |
| 120 | } |
| 121 | tb.add(NL); |
| 122 | for(final TokenList e : contents) { |
| 123 | for(int u = 0; u < size; ++u) { |
| 124 | final byte[] s = e.get(u); |
| 125 | final int is = ind[u] - s.length; |
| 126 | if(u < align.size() && align.get(u)) { |
| 127 | for(int i = 0; i < is; ++i) tb.add(' '); |
| 128 | tb.add(s); |
| 129 | } else { |
| 130 | tb.add(s); |
| 131 | for(int i = 0; i < is; ++i) tb.add(' '); |
| 132 | } |
| 133 | for(int i = 0; i < DIST; ++i) tb.add(' '); |
| 134 | } |
| 135 | tb.add(NL); |
| 136 | } |
| 137 | if(description != null) { |
| 138 | tb.add(NL).addExt(description, contents.size()).add(DOT); |
| 139 | } |
| 140 | return tb.finish(); |
| 141 | } |
| 142 | |
| 143 | @Override |
| 144 | public String toString() { |
no test coverage detected