private VoltTable createReplicatedTable(int numberOfItems, int indexBase, StringBuilder sb) {
return createReplicatedTable(numberOfItems, indexBase, sb, false);
}
private VoltTable createReplicatedTable(int numberOfItems, int indexBase, StringBuilder sb, boolean generateCSV) {
VoltTable repl_table = new VoltTable(new ColumnInfo("RT_ID", VoltType.INTEGER), new ColumnInfo("RT_NAME", VoltType.STRING), new ColumnInfo("RT_INTVAL", VoltType.INTEGER), new ColumnInfo(
"RT_FLOATVAL", VoltType.FLOAT));
char delimeter = generateCSV ? ',' : '\t';
for (int i = indexBase; i < numberOfItems + indexBase; i++) {
String stringVal = null;
String escapedVal = null;
if (sb != null) {
if (generateCSV) {
int escapable = i % 5;
switch (escapable) {
case 0:
stringVal = "name_" + i;
escapedVal = "name_" + i;
break;
case 1:
stringVal = "na,me_" + i;
escapedVal = "\"na,me_" + i + "\"";
break;
case 2:
stringVal = "na\"me_" + i;
escapedVal = "\"na\"\"me_" + i + "\"";
break;
case 3:
stringVal = "na\rme_" + i;
escapedVal = "\"na\rme_" + i + "\"";
break;
case 4:
stringVal = "na\nme_" + i;
escapedVal = "\"na\nme_" + i + "\"";
break;
}
} else {
int escapable = i % 5;
switch (escapable) {
case 0:
stringVal = "name_" + i;
escapedVal = "name_" + i;
break;
case 1:
stringVal = "na\tme_" + i;
escapedVal = "na\\tme_" + i;
break;
case 2:
stringVal = "na\nme_" + i;
escapedVal = "na\\nme_" + i;
break;
case 3:
stringVal = "na\rme_" + i;
escapedVal = "na\\rme_" + i;
break;
case 4:
stringVal = "na\\me_" + i;
escapedVal = "na\\\\me_" + i;
break;
}
}
} else {
stringVal = "name_" + i;
}
Object[] row = new Object[] { i, stringVal, i, new Double(i) };
if (sb != null) {
sb.append(i).append(delimeter).append(escapedVal).append(delimeter);
sb.append(i).append(delimeter).append(new Double(i).toString()).append('\n');
}
repl_table.addRow(row);
}
return repl_table;
}