Example usage for java.lang String toString

List of usage examples for java.lang String toString

Introduction

In this page you can find the example usage for java.lang String toString.

Prototype

public String toString() 

Source Link

Document

This object (which is already a string!) is itself returned.

Usage

From source file:eu.optimis.ics.core.io.BaseImageCopier.java

/**
 * Checks that <code>destination</code> has enough space to create a copy of
 * <code>baseImage</code>./*from w  ww .j  a  v  a  2  s .co m*/
 * 
 * @param destination
 *            the destination which will be checked for free space
 * 
 * @param file
 *            the file to copy
 * 
 * @return <code>True</code> if there is enough space available to create a
 *         copy of <code>baseImage</code> on <code>destination</code>,
 *         <code>false</code> otherwise
 */
private boolean checkDiskspace(String destination, File file) {
    // Determine free space in KB
    long freeSpaceKb;
    try {
        freeSpaceKb = FileSystemUtils.freeSpaceKb(destination.toString());
    } catch (IOException ioException) {
        LOG.error("ics.core.io.BaseImageCopier.checkDiskspace(): Cannot determine free space in image folder '"
                + destination.toString() + "'", ioException);
        return false;
    }
    LOG.debug("ics.core.io.BaseImageCopier.checkDiskspace(): Free disk space: " + freeSpaceKb + "KB");

    // Determine required size in KB
    long requiredSizeKb = (file.length() / 1024);
    LOG.debug("ics.core.io.BaseImageCopier.checkDiskspace(): Required disk space: " + requiredSizeKb + "KB");

    // Check if enough space is available
    if (requiredSizeKb > freeSpaceKb) {
        LOG.error("ics.core.io.BaseImageCopier.checkDiskspace(): Not enough disk space for cloning image");
        return false;
    } else {
        LOG.debug("ics.core.io.BaseImageCopier.checkDiskspace(): Image can be cloned, enough disk space");
        return true;
    }
}

From source file:io.github.mbarre.schemacrawler.tool.linter.BaseLintTest.java

protected List<LintWrapper> executeToJsonAndConvertToLintList(SchemaCrawlerOptions options,
        Connection connection) throws Exception {

    final Executable executable = new SchemaCrawlerExecutable("lint");

    final Path linterConfigsFile = FileSystems.getDefault().getPath("",
            this.getClass().getClassLoader().getResource("schemacrawler-linter-configs-test.xml").getPath());
    final LintOptionsBuilder optionsBuilder = new LintOptionsBuilder();
    optionsBuilder.withLinterConfigs(linterConfigsFile.toString());
    executable.setAdditionalConfiguration(optionsBuilder.toConfig());

    Path out = Paths.get("target/test_" + this.getClass().getSimpleName() + ".json");
    OutputOptions outputOptions = new OutputOptions(TextOutputFormat.json, out);
    outputOptions.setOutputFile(Paths.get("target/test_" + this.getClass().getSimpleName() + ".json"));

    executable.setOutputOptions(outputOptions);
    executable.setSchemaCrawlerOptions(options);
    executable.execute(connection);//from  w  ww . j  a va  2  s  . c o  m

    File output = new File(out.toString());
    String data = IOUtils.toString(new FileInputStream(output));
    Assert.assertNotNull(data);
    JSONObject json = new JSONObject(data.toString().substring(1, data.toString().length() - 2));

    List<LintWrapper> lints = new ArrayList<>();

    if (json.get("table_lints") instanceof JSONObject) {

        Assert.assertNotNull(json.getJSONObject("table_lints"));
        JSONArray jsonLints = json.getJSONObject("table_lints").getJSONArray("lints");
        Assert.assertNotNull(jsonLints);

        if (options.getTableNamePattern() != null && !options.getTableNamePattern().isEmpty())
            Assert.assertEquals(options.getTableNamePattern(),
                    json.getJSONObject("table_lints").getString("name"));

        for (int i = 0; i < jsonLints.length(); i++) {
            if (!"databasechangelog".equals(json.getJSONObject("table_lints").getString("name"))
                    && !"databasechangeloglock".equals(json.getJSONObject("table_lints").getString("name")))
                lints.add(createLintWrapper(json.getJSONObject("table_lints").getString("name"),
                        jsonLints.getJSONObject(i)));
        }
    } else {
        Assert.assertNotNull(json.getJSONArray("table_lints"));
        JSONArray jsonTableLints = json.getJSONArray("table_lints");

        for (int i = 0; i < jsonTableLints.length(); i++) {
            JSONArray jsonLints = jsonTableLints.getJSONObject(i).getJSONArray("lints");
            Assert.assertNotNull(jsonLints);

            if (options.getTableNamePattern() != null && !options.getTableNamePattern().isEmpty())
                Assert.assertEquals(options.getTableNamePattern(),
                        json.getJSONObject("table_lints").getString("name"));

            for (int j = 0; j < jsonLints.length(); j++) {
                if (!"databasechangelog".equals(jsonTableLints.getJSONObject(i).getString("name"))
                        && !"databasechangeloglock".equals(jsonTableLints.getJSONObject(i).getString("name")))
                    lints.add(createLintWrapper(jsonTableLints.getJSONObject(i).getString("name"),
                            jsonLints.getJSONObject(j)));
            }
        }
    }
    return lints;
}

From source file:gov.va.vinci.leo.listener.SimpleCsvListenerTest.java

@Test
public void testSimple2() throws IOException {
    File f = File.createTempFile("testSimple", "txt");
    SimpleCsvListener listener = new SimpleCsvListener(f, false, '|', true, Token.class.getCanonicalName(),
            WordToken.class.getCanonicalName());
    listener.entityProcessComplete(cas, null);
    String b = FileUtils.readFileToString(f).trim();
    assertEquals("|\"1\"|\"5\"|\"gov.va.vinci.leo.whitespace.types.Token\"|\"1234\"|\"[ TokenType = 1]\"",
            b.toString());
}

From source file:com.aw.core.db.support.WhereBuilder2.java

public void filter(Object valor, String sqlFiltro, Object[] filters) {
    if (valor == null || (valor instanceof String && StringUtils.isEmpty((String) valor))) {
        return;/*  www  .jav  a2  s.c  o  m*/
    }
    boolean filterStartWithAND = sqlFiltro.toString().toLowerCase().trim().startsWith("and");
    if (!filterStartWithAND) {
        boolean containsWhere = sql.toString().toLowerCase().indexOf(" where ") != -1;
        sql.append(containsWhere ? " and " : " where ");
    }

    sql.append(" ").append(sqlFiltro).append(" ");
    if (filters != null)
        for (Object filter : filters) {
            if (filter instanceof Date)
                filter = new java.sql.Date(((Date) filter).getTime());
            params.add(filter);
        }
}

From source file:de.uzk.hki.da.service.CSVQueryHandler.java

private String formatDate(Date date) {
    String sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(date);
    return sdf.toString();
}

From source file:edu.pdx.konstan2.PortlandLive.responseParserFactory.java

public void parseStopsJSON(String response, HashMap<LatLng, Stop> sMap) {
    try {//from   ww w .  j  a  v a  2 s  . c o  m
        JSONParser parser = new JSONParser();
        JSONObject jobj = (JSONObject) parser.parse(response.toString());
        JSONObject v = (JSONObject) jobj.get("resultSet");
        JSONArray arr = (JSONArray) v.get("location");
        Iterator<JSONObject> iter = arr.iterator();
        while (iter.hasNext()) {
            Stop t = new Stop(iter.next());
            sMap.put(new LatLng(t.latitude, t.longitude), t);
        }
    } catch (Exception e) {
    }
}

From source file:gov.nih.nci.cabig.caaers.dao.InvestigatorDao.java

/**
 * Search for investigators using query.
 * //from  w w w. j  a v a2 s.c  om
 * @param query
 *                The query used to search for investigators
 * @return The list of investigators.
 */
@SuppressWarnings({ "unchecked" })
public List<Investigator> searchInvestigator(final InvestigatorQuery query) {
    String queryString = query.getQueryString();
    log.debug("::: " + queryString.toString());
    return (List<Investigator>) super.search(query);
}

From source file:gov.nih.nci.cabig.caaers.dao.InvestigatorDao.java

@SuppressWarnings("unchecked")
public List<Investigator> getLocalInvestigator(final InvestigatorQuery query) {
    String queryString = query.getQueryString();
    log.debug("::: " + queryString.toString());
    List<Investigator> investigators = (List<Investigator>) super.search(query);
    return investigators;
}

From source file:mercury.core.AngularDeferred.java

public void callDeferredWithJSON(final String method, String parameter) {
    runLater(() -> {//from  w  ww  .  j a  v a 2  s. c  o m
        timer.start();

        deferred.call(method, toJSON(parameter));
        timer.elapsed("deferred." + method + "(" + parameter.toString() + ")");
    });
}

From source file:com.github.wnameless.tagwall.aop.TagwallAspectConfig.java

@SuppressWarnings("unchecked")
private void removeTags(String thingType, Iterable<Serializable> thingIds) {
    for (Serializable thingId : thingIds) {
        Thing thing = thingRepo.findByThingTypeAndThingId(thingType.toString(), thingId);
        if (thing != null) {
            for (String tagName : ((Set<String>) thing.getTagNames())) {
                Tag tag = tagRepo.findByTagNameAndThingType(tagName, thingType);
                if (tag != null) {
                    tag.getThingIds().remove(thingId);
                    if (tag.getThingIds().isEmpty()) {
                        tagRepo.delete(tag);
                    } else {
                        tagRepo.save(tag);
                    }/*from   w  w  w.  j  av  a  2s  .c o m*/
                }
            }
            thingRepo.delete(thing);
        }
    }
}