/** * Generates the field names for the output file * * @return the field names as a string */ public static String printableFieldNamesToString() { return printableFieldNamesToString(_saveConfig); }
/** * Method will save aggregate statistics as CSV. For now I put it here. Not * sure if it should go in the newer SaveService instead of here. if we ever * decide to get rid of this class, we'll need to move this method to the * new save service. * * @param data * List of data rows * @param writer * output writer * @throws IOException * when writing to <code>writer</code> fails */ public static void saveCSVStats(List<?> data, Writer writer) throws IOException { saveCSVStats(data, writer, null); }
public void append(String s) { addDelim(); sb.append(quoteDelimiters(s, specials)); }
private static void writeFileStart(PrintWriter writer, SampleSaveConfiguration saveConfig) { if (saveConfig.saveAsXml()) { writer.print(XML_HEADER); // Write the EOL separately so we generate LF line ends on Unix and Windows writer.print("\n"); // $NON-NLS-1$ String pi=saveConfig.getXmlPi(); if (pi.length() > 0) { writer.println(pi); } // Can't do it as a static initialisation, because SaveService // is being constructed when this is called writer.print(TESTRESULTS_START_V1_1_PREVER); writer.print(SaveService.getVERSION()); writer.print(TESTRESULTS_START_V1_1_POSTVER); // Write the EOL separately so we generate LF line ends on Unix and Windows writer.print("\n"); // $NON-NLS-1$ } else if (saveConfig.saveFieldNames()) { writer.println(CSVSaveService.printableFieldNamesToString(saveConfig)); } }
/** * {@inheritDoc} */ @Override public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { ScriptWrapper wrap = new ScriptWrapper(); wrap.version = reader.getAttribute(ATT_VERSION); ConversionHelp.setInVersion(wrap.version);// Make sure decoding // follows input file reader.moveDown(); // Catch errors and rethrow as ConversionException so we get location details try { wrap.testPlan = (HashTree) context.convertAnother(wrap, getNextType(reader)); } catch (NoClassDefFoundError | Exception e) { throw createConversionException(e); } return wrap; }
public static void saveTree(HashTree tree, OutputStream out) throws IOException { // Get the OutputWriter to use OutputStreamWriter outputStreamWriter = getOutputStreamWriter(out); writeXmlHeader(outputStreamWriter); // Use deprecated method, to avoid duplicating code ScriptWrapper wrapper = new ScriptWrapper(); wrapper.testPlan = tree; JMXSAVER.toXML(wrapper, outputStreamWriter); outputStreamWriter.write('\n');// Ensure terminated properly outputStreamWriter.close(); }
/** * Convert a result into a string, where the fields of the result are * separated by a specified String. * * @param event * the sample event to be converted * @param delimiter * the separation string * @return the separated value representation of the result */ public static String resultToDelimitedString(SampleEvent event, final String delimiter) { return resultToDelimitedString(event, event.getResult(), event.getResult().getSaveConfig(), delimiter); }
public static void saveElement(Object el, OutputStream out) throws IOException { // Get the OutputWriter to use OutputStreamWriter outputStreamWriter = getOutputStreamWriter(out); writeXmlHeader(outputStreamWriter); // Use deprecated method, to avoid duplicating code JMXSAVER.toXML(el, outputStreamWriter); outputStreamWriter.close(); }
private static InputStreamReader getInputStreamReader(InputStream inStream) { // Check if we have a encoding to use from properties Charset charset = getFileEncodingCharset(); return new InputStreamReader(inStream, charset); }
public void append(boolean b) { addDelim(); sb.append(b); }
public void append(Object obj) { append(String.valueOf(obj)); }
public static Object loadElement(InputStream in) throws IOException { // Get the InputReader to use InputStreamReader inputStreamReader = getInputStreamReader(in); // Use deprecated method, to avoid duplicating code Object element = JMXSAVER.fromXML(inputStreamReader); inputStreamReader.close(); return element; }
/** * * @param alias the file name or alias * @param recycle whether the file should be re-started on EOF * @param ignoreFirstLine whether the file contains a file header which will be ignored * @param delim the delimiter to use for parsing * @return the parsed line, will be empty if the file is at EOF * @throws IOException when reading of the aliased file fails, or the file was not reserved properly */ public synchronized String[] getParsedLine(String alias, boolean recycle, boolean ignoreFirstLine, char delim) throws IOException { BufferedReader reader = getReader(alias, recycle, ignoreFirstLine); return CSVSaveService.csvReadFile(reader, delim); }
@Override public String serializedClass(@SuppressWarnings("rawtypes") // superclass does not use types Class type) { if (type == null) { return super.serializedClass(null); // was type, but that caused FindBugs warning } String alias = classToAlias(type.getName()); return alias == null ? super.serializedClass(type) : alias ; } };
@Override public Class<?> realClass(String alias) { String fullName = aliasToClass(alias); if (fullName != null) { fullName = NameUpdater.getCurrentName(fullName); } return super.realClass(fullName == null ? alias : fullName); } // Translate to alias and then delegate to wrapped class
/** * Method saves aggregate statistics (with header names) as CSV from a table * model. Same as {@link #saveCSVStats(List, Writer, String[])} except * that there is no need to create a List containing the data. * * @param model * table model containing the data * @param writer * output file * @throws IOException * when writing to <code>writer</code> fails */ public static void saveCSVStats(DefaultTableModel model, FileWriter writer) throws IOException { saveCSVStats(model, writer, true); }
private static OutputStreamWriter getOutputStreamWriter(OutputStream outStream) { // Check if we have a encoding to use from properties Charset charset = getFileEncodingCharset(); return new OutputStreamWriter(outStream, charset); }
public void append(long l) { addDelim(); sb.append(l); }
private static void writeXmlHeader(OutputStreamWriter writer) throws IOException { // Write XML header if we have the charset to use for encoding Charset charset = getFileEncodingCharset(); // We do not use getEncoding method of Writer, since that returns // the historical name String header = XML_HEADER.replaceAll("<ph>", charset.name()); writer.write(header); writer.write('\n'); }
public void append(int i) { addDelim(); sb.append(i); }