closing up Table work, moving functions a bit, hide unapproved

This commit is contained in:
benfry
2012-12-09 21:02:53 +00:00
parent 0949ce213f
commit 982db8e89d
2 changed files with 76 additions and 72 deletions

View File

@@ -2223,53 +2223,6 @@ public class Table {
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/**
* Remove any of the specified characters from the entire table.
*/
public void removeTokens(String tokens) {
for (int col = 0; col < getColumnCount(); col++) {
removeTokens(tokens, col);
}
}
/**
* Removed any of the specified characters from a column. For instance,
* the following code removes dollar signs and commas from column 2:
* <pre>
* table.removeTokens(",$", 2);
* </pre>
*/
public void removeTokens(String tokens, int column) {
for (int row = 0; row < rowCount; row++) {
String s = getString(row, column);
if (s != null) {
char[] c = s.toCharArray();
int index = 0;
for (int j = 0; j < c.length; j++) {
if (tokens.indexOf(c[j]) == -1) {
if (index != j) {
c[index] = c[j];
}
index++;
}
}
if (index != c.length) {
setString(row, column, new String(c, 0, index));
}
}
}
}
public void removeTokens(String tokens, String columnName) {
removeTokens(tokens, getColumnIndex(columnName));
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/**
* Return the row that contains the first String that matches.
* @param value the String to match
@@ -2574,6 +2527,53 @@ public class Table {
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/**
* Remove any of the specified characters from the entire table.
*/
public void removeTokens(String tokens) {
for (int col = 0; col < getColumnCount(); col++) {
removeTokens(tokens, col);
}
}
/**
* Removed any of the specified characters from a column. For instance,
* the following code removes dollar signs and commas from column 2:
* <pre>
* table.removeTokens(",$", 2);
* </pre>
*/
public void removeTokens(String tokens, int column) {
for (int row = 0; row < rowCount; row++) {
String s = getString(row, column);
if (s != null) {
char[] c = s.toCharArray();
int index = 0;
for (int j = 0; j < c.length; j++) {
if (tokens.indexOf(c[j]) == -1) {
if (index != j) {
c[index] = c[j];
}
index++;
}
}
if (index != c.length) {
setString(row, column, new String(c, 0, index));
}
}
}
}
public void removeTokens(String tokens, String columnName) {
removeTokens(tokens, getColumnIndex(columnName));
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
public void trim() {
for (int col = 0; col < getColumnCount(); col++) {
trim(col);