public final class CSVSaveService extends Object
Modifier and Type | Field and Description |
---|---|
static String |
CSV_BYTES |
static String |
CSV_CONNECT_TIME |
static String |
CSV_ELAPSED |
static String |
CSV_ENCODING |
static String |
CSV_ERROR_COUNT |
static String |
CSV_FILENAME |
static String |
CSV_HOSTNAME |
static String |
CSV_IDLETIME |
static String |
CSV_LATENCY |
static String |
CSV_SAMPLE_COUNT |
static String |
CSV_SENT_BYTES |
static String |
CSV_THREAD_COUNT1 |
static String |
CSV_THREAD_COUNT2 |
static String |
CSV_URL |
static String |
DATA_TYPE |
static String |
FAILURE_MESSAGE |
static String |
LABEL |
static char |
QUOTING_CHAR |
static String |
RESPONSE_CODE |
static String |
RESPONSE_MESSAGE |
static String |
SUCCESSFUL |
static String |
THREAD_NAME |
static String |
TIME_STAMP |
static String |
VARIABLE_NAME_QUOTE_CHAR |
Modifier and Type | Method and Description |
---|---|
static String[] |
csvReadFile(BufferedReader infile,
char delim)
Reads from file and splits input into strings according to the delimiter,
taking note of quoted strings.
|
static String[] |
csvSplitString(String line,
char delim)
Reads from String and splits into strings according to the delimiter,
taking note of quoted strings.
|
static SampleSaveConfiguration |
getSampleSaveConfiguration(String headerLine,
String filename)
Parse a CSV header line
|
static String |
printableFieldNamesToString()
Generates the field names for the output file
|
static String |
printableFieldNamesToString(SampleSaveConfiguration saveConfig)
Generates the field names for the output file
|
static void |
processSamples(String filename,
Visualizer visualizer,
ResultCollector resultCollector)
Read Samples from a file; handles quoted strings.
|
static String |
quoteDelimiters(String input,
char[] specialChars)
Returns a
String value for a character-delimited column
value enclosed in the quote character, if required. |
static String |
resultToDelimitedString(SampleEvent event)
Convert a result into a string, where the fields of the result are
separated by the default delimiter.
|
static String |
resultToDelimitedString(SampleEvent event,
SampleResult sample,
SampleSaveConfiguration saveConfig,
String delimiter)
Convert a result into a string, where the fields of the result are
separated by a specified String.
|
static String |
resultToDelimitedString(SampleEvent event,
String delimiter)
Convert a result into a string, where the fields of the result are
separated by a specified String.
|
static void |
saveCSVStats(DefaultTableModel model,
FileWriter writer)
Method saves aggregate statistics (with header names) as CSV from a table
model.
|
static void |
saveCSVStats(DefaultTableModel model,
FileWriter writer,
boolean saveHeaders)
Method saves aggregate statistics as CSV from a table model.
|
static void |
saveCSVStats(List<?> data,
Writer writer)
Method will save aggregate statistics as CSV.
|
static void |
saveCSVStats(List<?> data,
Writer writer,
String[] headers)
Method will save aggregate statistics as CSV.
|
static void |
saveSampleResult(SampleEvent event,
PrintWriter out) |
public static final String DATA_TYPE
public static final String FAILURE_MESSAGE
public static final String LABEL
public static final String RESPONSE_CODE
public static final String RESPONSE_MESSAGE
public static final String SUCCESSFUL
public static final String THREAD_NAME
public static final String TIME_STAMP
public static final String CSV_ELAPSED
public static final String CSV_BYTES
public static final String CSV_SENT_BYTES
public static final String CSV_THREAD_COUNT1
public static final String CSV_THREAD_COUNT2
public static final String CSV_SAMPLE_COUNT
public static final String CSV_ERROR_COUNT
public static final String CSV_URL
public static final String CSV_FILENAME
public static final String CSV_LATENCY
public static final String CSV_CONNECT_TIME
public static final String CSV_ENCODING
public static final String CSV_HOSTNAME
public static final String CSV_IDLETIME
public static final String VARIABLE_NAME_QUOTE_CHAR
public static final char QUOTING_CHAR
public static void processSamples(String filename, Visualizer visualizer, ResultCollector resultCollector) throws IOException
filename
- input filevisualizer
- where to send the resultsresultCollector
- the parent collectorIOException
- when the file referenced by filename
can't be
read correctlypublic static String printableFieldNamesToString()
public static String printableFieldNamesToString(SampleSaveConfiguration saveConfig)
saveConfig
- the configuration of what is to be savedpublic static SampleSaveConfiguration getSampleSaveConfiguration(String headerLine, String filename)
headerLine
- from CSV filefilename
- name of file (for log message only)public static void saveCSVStats(List<?> data, Writer writer) throws IOException
data
- List of data rowswriter
- output writerIOException
- when writing to writer
failspublic static void saveCSVStats(List<?> data, Writer writer, String[] headers) throws IOException
data
- List of data rowswriter
- output fileheaders
- header names (if non-null)IOException
- when writing to writer
failspublic static void saveCSVStats(DefaultTableModel model, FileWriter writer) throws IOException
saveCSVStats(List, Writer, String[])
except
that there is no need to create a List containing the data.model
- table model containing the datawriter
- output fileIOException
- when writing to writer
failspublic static void saveCSVStats(DefaultTableModel model, FileWriter writer, boolean saveHeaders) throws IOException
saveCSVStats(List, Writer, String[])
except that there is no
need to create a List containing the data.model
- table model containing the datawriter
- output filesaveHeaders
- whether or not to save headersIOException
- when writing to writer
failspublic static String resultToDelimitedString(SampleEvent event)
event
- the sample event to be convertedpublic static String resultToDelimitedString(SampleEvent event, String delimiter)
event
- the sample event to be converteddelimiter
- the separation stringpublic static String resultToDelimitedString(SampleEvent event, SampleResult sample, SampleSaveConfiguration saveConfig, String delimiter)
event
- the sample event to be convertedsample
- SampleResult
to logsaveConfig
- SampleSaveConfiguration
to use for loggingdelimiter
- the separation stringpublic static String quoteDelimiters(String input, char[] specialChars)
Returns a String
value for a character-delimited column
value enclosed in the quote character, if required.
If the value contains a special character, then the String value is returned enclosed in the quote character.
Any quote characters in the value are doubled up.
If the value does not contain any special characters, then the String value is returned unchanged.
N.B. The list of special characters includes the quote character.
input
- the input column String, may be null (without enclosing
delimiters)specialChars
- special characters; second one must be the quote
characternull
for null string inputpublic static String[] csvReadFile(BufferedReader infile, char delim) throws IOException
Handles DOS (CRLF), Unix (LF), and Mac (CR) line-endings equally.
A blank line - or a quoted blank line - both return an array containing a single empty String.
infile
- input file - must support mark(1)delim
- delimiter (e.g. comma)IOException
- also for unexpected quote characterspublic static String[] csvSplitString(String line, char delim) throws IOException
line
- input line - not null
delim
- delimiter (e.g. comma)IOException
- also for unexpected quote characterspublic static void saveSampleResult(SampleEvent event, PrintWriter out)
event
- SampleEvent
out
- PrintWriter
to which samples will be writtenCopyright © 1998-2019 Apache Software Foundation. All Rights Reserved.