Skip to content

Commit fa1fbc5

Browse files
author
chengyitian
committed
AJ-455: BasicTable support replaceColName method.
1 parent a776ef7 commit fa1fbc5

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/com/xxdb/data/BasicTable.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,22 @@ public void setColName (final List<String> colNames) {
120120
}
121121
}
122122

123-
}
123+
/**
124+
* replace a specific colName.
125+
* @param originalColName
126+
* @param newColName
127+
*/
128+
public void replaceColName(String originalColName, String newColName) {
129+
if (Utils.isEmpty(originalColName))
130+
throw new RuntimeException("colName cannot be null.");
131+
132+
if (this.colNames.contains(originalColName)) {
133+
int index = colNames.indexOf(originalColName);
134+
colNames.set(index, newColName);
135+
} else {
136+
throw new RuntimeException("colName '" + originalColName +"' does not exist in table.");
137+
}
138+
}
124139

125140
public void setColumns (final List<Vector> cols) {
126141
columns.clear();

0 commit comments

Comments
 (0)