Example usage for java.lang Boolean parseBoolean

List of usage examples for java.lang Boolean parseBoolean

Introduction

In this page you can find the example usage for java.lang Boolean parseBoolean.

Prototype

public static boolean parseBoolean(String s) 

Source Link

Document

Parses the string argument as a boolean.

Usage

From source file:org.xwiki.chart.internal.VisibilityChartCustomizer.java

@Override
public void customize(JFreeChart jfchart, Map<String, String> parameters) {
    if (parameters.get(PLOT_BORDER_VISIBLE) != null) {
        jfchart.getPlot().setOutlineVisible(Boolean.parseBoolean(parameters.get(PLOT_BORDER_VISIBLE)));
    }// w  w  w . j a  v a  2 s  . c om

    if (parameters.get(LEGEND_VISIBLE) != null && !Boolean.parseBoolean(parameters.get(LEGEND_VISIBLE))) {
        jfchart.removeLegend();
    }
}

From source file:com.seer.datacruncher.streams.ExcelStreamTest.java

@Test
public void testExcelStream() {
    String fileName = properties.getProperty("excel_test_stream_file_name");
    InputStream in = this.getClass().getClassLoader().getResourceAsStream(stream_file_path + fileName);
    byte[] arr = null;
    try {//from  w ww  .ja  v a2  s  .  c o m
        arr = IOUtils.toByteArray(in);
    } catch (IOException e) {
        assertTrue("IOException while excel test file reading", false);
    }
    DatastreamsInput datastreamsInput = new DatastreamsInput();
    datastreamsInput.setUploadedFileName(fileName);
    String res = datastreamsInput.datastreamsInput(null, (Long) schemaEntity.getIdSchema(), arr, true);
    assertTrue("Excel file validation failed", Boolean.parseBoolean(res));
}

From source file:org.zlogic.vogon.web.controller.ConfigurationController.java

/**
 * Sets configuration properties//from   www .j  a v a 2 s  . c om
 *
 * @param values the values to set
 */
@RequestMapping(method = RequestMethod.POST, produces = "application/json")
@Secured({ VogonSecurityUser.AUTHORITY_ADMIN })
public @ResponseBody void setProperties(@RequestBody Collection<ConfigurationElement> values) {
    for (ConfigurationElement element : values)
        if (element.getName().equals(ConfigurationKeys.ALLOW_REGISTRATION))
            element.setValue(Boolean.parseBoolean((String) element.getValue()));
    configurationRepository.save(values);
    configurationRepository.flush();
}

From source file:com.seer.datacruncher.streams.DelimiterStreamTest.java

@Test
public void testDelimitedStream() {
    InputStream in = this.getClass().getClassLoader()
            .getResourceAsStream(stream_file_path + flat_file_delimited_file_name);
    StringWriter writer = new StringWriter();
    try {/*ww w .  j a va2s  . c o  m*/
        IOUtils.copy(in, writer, "UTF-8");
    } catch (IOException e) {
        assertTrue("IOException while delimited file reading", false);
    }
    String stream = writer.toString();
    DatastreamsInput datastreamsInput = new DatastreamsInput();
    String res = datastreamsInput.datastreamsInput(stream, (Long) schemaEntity.getIdSchema(), null, true);
    assertTrue("Delimited file validation failed", Boolean.parseBoolean(res));
}

From source file:uk.ac.ebi.ep.base.config.EnzymesConfig.java

@Bean
public LiteratureConfig literatureConfig() {
    LiteratureConfig lc = new LiteratureConfig();
    lc.setMaxThreads(Integer.parseInt(env.getProperty("literature.threads.max")));
    lc.setUseCitexploreWs(Boolean.parseBoolean(env.getProperty("literature.citexplore.ws")));
    lc.setMaxCitations(Integer.parseInt(env.getProperty("literature.results.max")));
    lc.setCitexploreClientPoolSize(Integer.parseInt(env.getProperty("literature.citexplore.client.pool.size")));
    lc.setCitexploreConnectTimeout(/*from   w ww.j  ava2 s .c o  m*/
            Integer.parseInt(env.getProperty("literature.citexplore.ws.timeout.connect")));
    lc.setCitexploreReadTimeout(Integer.parseInt(env.getProperty("literature.citexplore.ws.timeout.read")));
    return lc;
}

From source file:com.netflix.spinnaker.orca.pipelinetemplate.v1schema.render.JsonRenderedValueConverter.java

@Override
public Object convertRenderedValue(String rendered) {
    if (NumberUtils.isNumber(rendered)) {
        if (rendered.contains(".")) {
            return NumberUtils.createDouble(rendered);
        }/*  ww w  .  j ava 2s. c  o m*/
        try {
            return NumberUtils.createInteger(rendered);
        } catch (NumberFormatException ignored) {
            return NumberUtils.createLong(rendered);
        }
    } else if (rendered.equals("true") || rendered.equals("false")) {
        return Boolean.parseBoolean(rendered);
    } else if (rendered.startsWith("{{") || (!rendered.startsWith("{") && !rendered.startsWith("["))) {
        return rendered;
    }

    JsonNode node;
    try {
        node = pipelineTemplateObjectMapper.readTree(rendered);
    } catch (IOException e) {
        throw new TemplateRenderException("template produced invalid json", e);
    }

    try {
        if (node.isArray()) {
            return pipelineTemplateObjectMapper.readValue(rendered, Collection.class);
        }
        if (node.isObject()) {
            return pipelineTemplateObjectMapper.readValue(rendered, HashMap.class);
        }
        if (node.isBoolean()) {
            return Boolean.parseBoolean(node.asText());
        }
        if (node.isDouble()) {
            return node.doubleValue();
        }
        if (node.canConvertToInt()) {
            return node.intValue();
        }
        if (node.canConvertToLong()) {
            return node.longValue();
        }
        if (node.isTextual()) {
            return node.textValue();
        }
        if (node.isNull()) {
            return null;
        }
    } catch (IOException e) {
        throw new TemplateRenderException("template produced invalid json", e);
    }

    throw new TemplateRenderException("unknown rendered object type");
}

From source file:com.seer.datacruncher.streams.FixedPosStreamTest.java

@Test
public void testFixedPosStream() {
    InputStream in = this.getClass().getClassLoader()
            .getResourceAsStream(stream_file_path + flat_file_fixedposition_file_name);
    StringWriter writer = new StringWriter();
    try {//from w  w w.ja v a  2  s.c  om
        IOUtils.copy(in, writer, "UTF-8");
    } catch (IOException e) {
        assertTrue("IOException while fixedPosition file reading", false);
    }
    String stream = writer.toString();
    DatastreamsInput datastreamsInput = new DatastreamsInput();
    String res = datastreamsInput.datastreamsInput(stream, (Long) schemaEntity.getIdSchema(), null, true);
    assertTrue("FixedPosition file validation failed", Boolean.parseBoolean(res));
}

From source file:gov.nih.nci.cabig.ccts.tags.CheckRoleTag.java

private void evaluateRoles() {
    String rolesString = new String(roleName);

    log.debug(">>> EVALUATING: " + roleName);

    String[] roles = BooleanDelimiter.parseBoolean(roleName);
    if (roles.length == 0) {
        hasTheRoles = false;// w w  w .  j  a v  a 2  s.  c  om
        return;
    }

    log.debug(">>> FOUND ROLES: " + Arrays.toString(roles));

    for (String role : roles) {
        boolean hasTheRole = evaluateOneRole(role);
        rolesString = rolesString.replace(role, String.valueOf(hasTheRole));
        log.debug(String.format(">>> %s: %b, NEW STRING: %s ", role, hasTheRole, rolesString));
    }

    log.debug(">>> FINAL STRING: " + rolesString);
    hasTheRoles = Boolean.parseBoolean(new EL().evaluate("${" + rolesString + "}"));
    log.debug(">>> HAS THE ROLES: " + hasTheRoles);
}

From source file:eu.planets_project.pp.plato.xml.plato.TriggerFactory.java

@Override
public Object createObject(Attributes arg0) throws Exception {
    Trigger trigger = new Trigger();

    // legacy import for old trigger definition pre plato-2.0:
    String id = arg0.getValue("id");
    String value = arg0.getValue("value");

    if (id != null) { // this means we have an old xml
        trigger.setActive(true);/* www . j  a  v  a 2  s . c  o m*/
        if ("1".equals(id)) {
            trigger.setType(TriggerType.NEW_COLLECTION);
        } else if ("2".equals(id)) {
            trigger.setType(TriggerType.PERIODIC_REVIEW);
        } else if ("3".equals(id)) {
            trigger.setType(TriggerType.CHANGED_ENVIRONMENT);
        } else if ("4".equals(id)) {
            trigger.setType(TriggerType.CHANGED_OBJECTIVE);
        } else if ("5".equals(id)) {
            trigger.setType(TriggerType.CHANGED_COLLECTION_PROFILE);
        }
        trigger.setDescription(value);
    } else { // new xml >= plato 2.0
        trigger.setActive(Boolean.parseBoolean(arg0.getValue("active")));
        trigger.setDescription(arg0.getValue("description"));
        trigger.setType(TriggerType.valueOf(arg0.getValue("type")));
    }

    return trigger;
}

From source file:com.siemens.sw360.portal.users.UserCSV.java

public UserCSV(CSVRecord record) {
    givenname = record.get(0);//from   w ww  . ja  v a2s .  c  o m
    lastname = record.get(1);
    email = record.get(2);
    department = record.get(3);
    group = record.get(4);
    gid = record.get(5);
    isMale = Boolean.parseBoolean(record.get(6));
    hash = record.get(7);
    if (record.size() > 8) {
        wantsMailNotification = Boolean.parseBoolean((record.get(8)));
    }
}