Example usage for java.util List toString

List of usage examples for java.util List toString

Introduction

In this page you can find the example usage for java.util List toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:dollar.DollarOperatorsRegressionTest.java

public void regression(@NotNull String symbol, @NotNull String operation, @NotNull String variant,
        @NotNull List<List<Value>> result) throws IOException {
    String filename = operation + "." + variant + ".json";
    final JsonArray previous = new JsonArray(
            new String(ByteStreams.toByteArray(getClass().getResourceAsStream("/" + filename))));
    //Use small to stop massive string creation
    final File file = new File("target", filename);
    final Value current = DollarStatic.$(result);
    Files.write(current.jsonArray().encodePrettily(), file, Charset.forName("utf-8"));
    System.out.println(file.getAbsolutePath());
    SortedSet<String> typeComparison = new TreeSet<>();
    SortedSet<String> humanReadable = new TreeSet<>();
    for (List<Value> res : result) {
        if (res.size() != 3) {
            throw new IllegalStateException(res.toString());
        }/* w  ww.  j  a  v a2  s .  c  om*/

        typeComparison.add(
                res.get(0).$type() + " " + operation + " " + res.get(1).$type() + " = " + res.get(2).$type());
        humanReadable.add(res.get(0).toDollarScript() + " " + symbol + " " + res.get(1).toDollarScript()
                + " <=> " + res.get(2).toDollarScript());
    }
    final String typesFile = operation + "." + variant + ".types.txt";
    final String humanFile = operation + "." + variant + ".ds";
    Files.asCharSink(new File("target", typesFile), Charset.forName("utf-8")).writeLines(typeComparison);
    Files.asCharSink(new File("target", humanFile), Charset.forName("utf-8")).writeLines(humanReadable);
    final TreeSet previousTypeComparison = new TreeSet<>(Resources
            .asCharSource(getClass().getResource("/" + typesFile), Charset.forName("utf-8")).readLines());
    diff("type", previousTypeComparison.toString(), typeComparison.toString());
    diff("result", previous, current.jsonArray());
}

From source file:org.hdiv.web.servlet.view.DummyMacroRequestContext.java

/**
 * @see org.springframework.web.servlet.support.RequestContext#getMessage(String, List, String)
 *//*from  ww w  .j a va 2s .com*/
public String getMessage(String code, List args, String defaultMsg) {
    String msg = (String) this.messageMap.get(code);
    return (msg != null ? msg + args.toString() : defaultMsg);
}

From source file:org.hdiv.web.servlet.view.DummyMacroRequestContext.java

/**
 * @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String, List, String)
 *///from  ww w  .  j  av  a2s  . c om
public String getThemeMessage(String code, List args, String defaultMsg) {
    String msg = (String) this.themeMessageMap.get(code);
    return (msg != null ? msg + args.toString() : defaultMsg);
}

From source file:io.cortical.retina.core.TextsTest.java

/**
 * {@link Texts#getKeywordsForText(String)} test method.
 * //w w w.  ja v  a  2s .c  om
 * @throws ApiException : should never be thrown
 */
@Test
public void testGetKeywordsForText() throws ApiException {
    when(textApi.getKeywordsForText(eq(TEXT), eq(NOT_NULL_RETINA))).thenReturn(asList(KEYWORDS));
    List<String> keywords = texts.getKeywordsForText(TEXT);
    assertEquals("[KEY1, KEY2, KEY3]", keywords.toString());
    verify(textApi, times(1)).getKeywordsForText(eq(TEXT), eq(NOT_NULL_RETINA));
}

From source file:curly.commons.config.cache.RedisCacheConfig.java

private Map<String, Long> toMap(final List<String> cacheNames, final List<Long> cacheExpirations) {
    Map<String, Long> map = new HashMap<>();
    logger.debug("Converting cache resources to map, {}, {}", cacheNames.toString(),
            cacheExpirations.toString());
    for (String cacheName : cacheNames) {
        logger.debug("Converting {} from list to map", cacheName);
        for (Long cacheExpiration : cacheExpirations) {
            logger.debug("Putting on map, key {}, value {}", cacheName, cacheExpiration);
            map.put(cacheName, cacheExpiration);
        }//from   w ww  . j a v a  2  s. c o m
    }
    return map;
}

From source file:com.javacodegags.waterflooding.controller.AdminController.java

@RequestMapping(value = "/admin/allTherms", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
public @ResponseBody String getAllTherms(@RequestBody String postBody) throws JSONException {
    JSONObject jsono = new JSONObject();
    List<Therm> therms = thermInterface.getList();
    LOG.info(therms.toString());
    jsono.put("thermlist", new CustomJSONParser().thermsToJsonArray(therms));
    return jsono.toString();
}

From source file:ch.unibas.fittingwizard.infrastructure.RealBabelScript.java

@Override
public BabelOutput execute(BabelInput input) {

    String moleculeName = getMoleculeName(input.getGaussianLogFile());

    File specificMoleculeDir = new File(moleculesDir, moleculeName);

    setWorkingDir(specificMoleculeDir);//from w ww. j av a  2 s .  com

    File sdfFile = new File(specificMoleculeDir, moleculeName + sdfExtension);

    List<String> args = Arrays.asList("-ig03", input.getGaussianLogFile().getName(), "-osdf",
            sdfFile.getName());

    logger.info("Running babel: " + args.toString());

    try {
        int retval = runner.exec(args);
        if (retval != 0) {
            logger.error("Babel exited with non-zero return value: " + retval);
            throw new ScriptExecutionException("Babel exited with non-zero return value: " + retval);
        }
    } catch (Exception e) {
        logger.error("Babel file conversion failed.");
        throw new ScriptExecutionException("Babel file conversion failed.", e);
    }

    if (!sdfFile.exists()) {
        logger.error("Babel file conversion did not create SDF output file.");
        throw new ScriptExecutionException("Babel file conversion did not create SDF output file.");
    }

    return new BabelOutput(sdfFile);
}

From source file:ispyb.server.common.test.services.CrimsTest.java

public void getData() {
    List<Map<String, Object>> result = this.external3Service.getDataCollectionByProposal("mx", "415");
    System.out.println(result.toString());
}

From source file:com.turn.sorcerer.util.email.Emailer.java

private void sendEmail() throws EmailException, UnknownHostException {

    List<String> addresses = Lists
            .newArrayList(Splitter.on(',').omitEmptyStrings().trimResults().split(ADMIN_EMAIL.getAdmins()));
    logger.info("Sending email to {}", addresses.toString());

    Email email = new HtmlEmail();
    email.setHostName(ADMIN_EMAIL.getHost());
    email.setSocketTimeout(30000); // 30 seconds
    email.setSocketConnectionTimeout(30000); // 30 seconds
    for (String address : addresses) {
        email.addTo(address);/*from  ww  w . ja v  a2s.  com*/
    }
    email.setFrom(
            SorcererInjector.get().getModule().getName() + "@" + InetAddress.getLocalHost().getHostName());
    email.setSubject(title);
    email.setMsg(body);
    email.send();

}

From source file:org.yardstickframework.report.jfreechart.JFreeChartGraphPlotter.java

/**
 * @param file File.//from ww w. j  a v  a  2  s .c o  m
 * @return Collection of plot data.
 * @throws Exception If failed.
 */
private static List<PlotData> readData(File file) throws Exception {
    List<PlotData> data = new ArrayList<>();

    try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)))) {
        long initTime = 0;

        String drvNames = null;
        String[] metaInfo = null;

        for (String line; (line = br.readLine()) != null;) {
            if (line.startsWith("--"))
                continue;

            if (line.startsWith(DRV_NAMES_PREFIX)) {
                drvNames = line.substring(DRV_NAMES_PREFIX.length());

                List<String> drvNamesList = Arrays.asList(drvNames.split(","));

                Collections.sort(drvNamesList);

                drvNames = drvNamesList.toString().replaceAll("\\[", "").replaceAll("]", "");

                continue;
            }

            if (line.startsWith(META_INFO_PREFIX)) {
                metaInfo = line.substring(META_INFO_PREFIX.length()).split("\"" + META_INFO_SEPARATOR + "\"");

                continue;
            }

            String[] split = line.split(",");

            if (data.isEmpty()) {
                initTime = Long.parseLong(split[0]);

                int plotNum = split.length - 1;

                if (plotNum < 1)
                    throwException("Invalid data file: " + file.getAbsolutePath());

                String xAxisLabel = metaInfo == null || metaInfo.length == 0 ? ""
                        : metaInfo[0].replace("\"", "");

                for (int i = 0; i < plotNum; i++) {
                    PlotSeries single = new PlotSeries(drvNames);

                    single.addConfiguration(file.getParentFile().getName());

                    String yAxisLabel = metaInfo == null || i + 1 >= metaInfo.length ? ""
                            : metaInfo[i + 1].replace("\"", "");

                    String plotName = file.getName().replace(INPUT_FILE_EXTENSION, "");

                    String cnt = Integer.toString(i + 1);

                    cnt = cnt.length() == 1 ? "0" + cnt : cnt;

                    data.add(new PlotData("Plot_" + plotName + "_" + cnt, single, xAxisLabel, yAxisLabel));
                }
            }

            double[] tup = new double[split.length];

            for (int i = 0; i < tup.length; i++) {
                double d = i == 0 ? (Long.parseLong(split[0]) - initTime) : Double.parseDouble(split[i]);

                tup[i] = d;
            }

            for (int i = 0; i < split.length - 1; i++)
                data.get(i).series().rawData().add(new double[] { tup[0], tup[i + 1] });
        }

        for (PlotData plotData : data)
            plotData.series().finish();

        return data;
    } catch (Exception e) {
        errorHelp("Exception is raised while processing file (will skip): " + file.getAbsolutePath(), e);

        return Collections.emptyList();
    }
}