MCPcopy Index your code
hub / github.com/benfry/processing4 / trim

Method trim

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

Trims leading and trailing whitespace, such as spaces and tabs, from String table values. If no column is specified, then the values in all columns and rows are trimmed. A specific column may be referenced by either its ID or title. @webref table:method @webBrief Trims whitespace from values @see

()

Source from the content-addressed store, hash-verified

4157 * @see Table#removeTokens(String)
4158 */
4159 public void trim() {
4160 columnTitles = PApplet.trim(columnTitles);
4161 for (int col = 0; col < getColumnCount(); col++) {
4162 trim(col);
4163 }
4164 // remove empty columns
4165 int lastColumn = getColumnCount() - 1;
4166 //while (isEmptyColumn(lastColumn) && lastColumn >= 0) {
4167 while (isEmptyArray(getStringColumn(lastColumn)) && lastColumn >= 0) {
4168 lastColumn--;
4169 }
4170 setColumnCount(lastColumn + 1);
4171
4172 // trim() works from both sides
4173 while (getColumnCount() > 0 && isEmptyArray(getStringColumn(0))) {
4174 removeColumn(0);
4175 }
4176
4177 // remove empty rows (starting from the end)
4178 int lastRow = lastRowIndex();
4179 //while (isEmptyRow(lastRow) && lastRow >= 0) {
4180 while (isEmptyArray(getStringRow(lastRow)) && lastRow >= 0) {
4181 lastRow--;
4182 }
4183 setRowCount(lastRow + 1);
4184
4185 while (getRowCount() > 0 && isEmptyArray(getStringRow(0))) {
4186 removeRow(0);
4187 }
4188 }
4189
4190
4191 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