@webref table:method @brief Trims whitespace from values @see Table#removeTokens(String)
()
| 4058 | * @see Table#removeTokens(String) |
| 4059 | */ |
| 4060 | public void trim() { |
| 4061 | columnTitles = PApplet.trim(columnTitles); |
| 4062 | for (int col = 0; col < getColumnCount(); col++) { |
| 4063 | trim(col); |
| 4064 | } |
| 4065 | // remove empty columns |
| 4066 | int lastColumn = getColumnCount() - 1; |
| 4067 | //while (isEmptyColumn(lastColumn) && lastColumn >= 0) { |
| 4068 | while (isEmptyArray(getStringColumn(lastColumn)) && lastColumn >= 0) { |
| 4069 | lastColumn--; |
| 4070 | } |
| 4071 | setColumnCount(lastColumn + 1); |
| 4072 | |
| 4073 | // trim() works from both sides |
| 4074 | while (getColumnCount() > 0 && isEmptyArray(getStringColumn(0))) { |
| 4075 | removeColumn(0); |
| 4076 | } |
| 4077 | |
| 4078 | // remove empty rows (starting from the end) |
| 4079 | int lastRow = lastRowIndex(); |
| 4080 | //while (isEmptyRow(lastRow) && lastRow >= 0) { |
| 4081 | while (isEmptyArray(getStringRow(lastRow)) && lastRow >= 0) { |
| 4082 | lastRow--; |
| 4083 | } |
| 4084 | setRowCount(lastRow + 1); |
| 4085 | |
| 4086 | while (getRowCount() > 0 && isEmptyArray(getStringRow(0))) { |
| 4087 | removeRow(0); |
| 4088 | } |
| 4089 | } |
| 4090 | |
| 4091 | |
| 4092 | protected boolean isEmptyArray(String[] contents) { |
nothing calls this directly
no test coverage detected