MCPcopy Index your code
hub / github.com/processing/processing / trim

Method trim

core/src/processing/data/Table.java:4060–4089  ·  view source on GitHub ↗

@webref table:method @brief Trims whitespace from values @see Table#removeTokens(String)

()

Source from the content-addressed store, hash-verified

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) {

Callers

nothing calls this directly

Calls 12

trimMethod · 0.95
getColumnCountMethod · 0.95
isEmptyArrayMethod · 0.95
getStringColumnMethod · 0.95
setColumnCountMethod · 0.95
removeColumnMethod · 0.95
lastRowIndexMethod · 0.95
getStringRowMethod · 0.95
setRowCountMethod · 0.95
getRowCountMethod · 0.95
removeRowMethod · 0.95
getColumnIndexMethod · 0.95

Tested by

no test coverage detected