/**
* {@inheritDoc}
*/
public void iterationStart(LoopIterationEvent iterEvent) {
FileServer server = FileServer.getFileServer();
final JMeterContext context = getThreadContext();
if (vars == null) {
String _fileName = getFilename();
String mode = getShareMode();
int modeInt = CSVDataSetBeanInfo.getShareModeAsInt(mode);
switch(modeInt){
case CSVDataSetBeanInfo.SHARE_ALL:
alias = _fileName;
break;
case CSVDataSetBeanInfo.SHARE_GROUP:
alias = _fileName+"@"+System.identityHashCode(context.getThreadGroup());
break;
case CSVDataSetBeanInfo.SHARE_THREAD:
alias = _fileName+"@"+System.identityHashCode(context.getThread());
break;
default:
alias = _fileName+"@"+mode; // user-specified key
break;
}
final String names = getVariableNames();
if (names == null || names.length()==0) {
String header = server.reserveFile(_fileName, getFileEncoding(), alias, true);
try {
vars = CSVSaveService.csvSplitString(header, getDelimiter().charAt(0));
firstLineIsNames = true;
} catch (IOException e) {
log.warn("Could not split CSV header line",e);
}
} else {
server.reserveFile(_fileName, getFileEncoding(), alias);
vars = JOrphanUtils.split(names, ","); // $NON-NLS-1$
}
}
String delim = getDelimiter();
if (delim.equals("\\t")) { // $NON-NLS-1$
delim = "\t";// Make it easier to enter a Tab // $NON-NLS-1$
} else if (delim.length()==0){
log.warn("Empty delimiter converted to ','");
delim=",";
}
// TODO: fetch this once as per vars above?
JMeterVariables threadVars = context.getVariables();
String line = null;
try {
line = server.readLine(alias, getRecycle(), firstLineIsNames);
} catch (IOException e) { // treat the same as EOF
log.error(e.toString());
}
if (line!=null) {// i.e. not EOF
try {