kg.apc.jmeter.config
Class VariableFromCsvFileReader

java.lang.Object
  extended by kg.apc.jmeter.config.VariableFromCsvFileReader

public class VariableFromCsvFileReader
extends Object

Author:
Stephane Hoblingre

Constructor Summary
VariableFromCsvFileReader(BufferedReader input)
          Initialize a new CSV reader with a BufferedReader as input.
VariableFromCsvFileReader(String csvFileName)
          Initialize a new CSV reader for the named file.
 
Method Summary
 Map<String,String> getDataAsMap(String prefix, String separator)
          Parses (name, value) pairs from the input and returns the result as a Map.
 Map<String,String> getDataAsMap(String prefix, String separator, int skipLines)
          Parses (name, value) pairs from the input and returns the result as a Map, with the option to skip the first line.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VariableFromCsvFileReader

public VariableFromCsvFileReader(String csvFileName)
Initialize a new CSV reader for the named file.

Parameters:
csvFileName - name of the CSV input file

VariableFromCsvFileReader

public VariableFromCsvFileReader(BufferedReader input)
Initialize a new CSV reader with a BufferedReader as input.

Parameters:
input - the CSV input
Method Detail

getDataAsMap

public Map<String,String> getDataAsMap(String prefix,
                                       String separator)
Parses (name, value) pairs from the input and returns the result as a Map. The name is taken from the first column and value from the second column. If an input line contains only one column its value is defaulted to an empty string. Any extra columns are ignored.

Parameters:
prefix - a prefix to apply to the mapped variable names
separator - the field delimiter
Returns:
a map of (name, value) pairs

getDataAsMap

public Map<String,String> getDataAsMap(String prefix,
                                       String separator,
                                       int skipLines)
Parses (name, value) pairs from the input and returns the result as a Map, with the option to skip the first line. The name is taken from the first column and value from the second column. If an input line contains only one column its value is defaulted to an empty string. Any extra columns are ignored. If the input contains headers, call with skipLines equal to the number of lines of headers. A negative value for skipLines yields the same result as 0.

Parameters:
prefix - a prefix to apply to the mapped variable names
separator - the field delimiter
skipLines - the number of lines at the beginning of the input to skip
Returns:
a map of (name, value) pairs


Copyright © 2014. All Rights Reserved.