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:api.util.JsonUtil.java

public static Boolean asBoolean(Object val) {
    if (val == JSONObject.NULL)
        return null;
    if (val instanceof Boolean)
        return (Boolean) val;
    if (val instanceof String)
        return Boolean.parseBoolean((String) val);
    if (val instanceof Number)
        return ((Number) val).intValue() != 0;
    throw new IllegalArgumentException("Not a boolean: " + val);
}

From source file:com.clustercontrol.winsyslog.WinSyslogConfig.java

public static boolean getBooleanProperty(String key) {
    log.debug(key + " = " + properties.getProperty(key));
    return Boolean.parseBoolean(properties.getProperty(key));
}

From source file:org.dspace.app.webui.cris.controller.admin.OUAdminController.java

@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {

    ModelAndView mav = super.handleRequest(request, response);
    String errore = request.getParameter("error");
    OrganizationUnitDTO grantDTO = new OrganizationUnitDTO();
    if (errore != null && Boolean.parseBoolean(errore) == true) {
        // errore
        mav.getModel().put("error", "jsp.dspace-admin.hku.error.add-ou");
    }/*  w w w  . jav a2s.c  o m*/
    mav.getModel().put("dto", grantDTO);
    return mav;
}

From source file:com.plugtree.solrmeter.model.SolrServerRegistry.java

public static synchronized SolrServer getSolrServer(String url) {
    SolrServer server = servers.get(url);
    if (server == null) {
        logger.info("Connecting to Solr: " + url);
        HttpSolrServer httpServer = new HttpSolrServer(url);
        httpServer.setSoTimeout(Integer
                .parseInt(SolrMeterConfiguration.getProperty("solr.server.configuration.soTimeout", "60000"))); // socket read timeout
        httpServer.setConnectionTimeout(Integer.parseInt(
                SolrMeterConfiguration.getProperty("solr.server.configuration.connectionTimeout", "60000")));
        httpServer.setDefaultMaxConnectionsPerHost(Integer.parseInt(SolrMeterConfiguration
                .getProperty("solr.server.configuration.defaultMaxConnectionsPerHost", "100000")));
        httpServer.setMaxTotalConnections(Integer.parseInt(SolrMeterConfiguration
                .getProperty("solr.server.configuration.maxTotalConnections", "1000000")));
        httpServer.setFollowRedirects(Boolean.parseBoolean(
                SolrMeterConfiguration.getProperty("solr.server.configuration.followRedirect", "false"))); // defaults to false
        httpServer.setAllowCompression(Boolean.parseBoolean(
                SolrMeterConfiguration.getProperty("solr.server.configuration.allowCompression", "true")));
        httpServer.setMaxRetries(Integer
                .parseInt(SolrMeterConfiguration.getProperty("solr.server.configuration.maxRetries", "1"))); // defaults to 0. > 1 not recommended.
        setAuthentication(httpServer);/*w  ww .j  a  va  2 s  . com*/
        servers.put(url, httpServer);
        return httpServer;

    }
    return server;
}

From source file:com.acc.populator.AbstractHttpRequestDataPopulator.java

protected boolean updateBooleanValueFromRequest(final HttpServletRequest request, final String paramName,
        final boolean defaultValue) {
    final String booleanString = updateStringValueFromRequest(request, paramName, null);
    if (booleanString == null) {
        return defaultValue;
    }// w  w  w  .j ava2s  . co  m
    return Boolean.parseBoolean(booleanString);
}

From source file:com.bt.aloha.batchtest.WeekendBatchTest.java

protected static void configure(BatchTest batchTest) throws Exception {
    Properties properties = new Properties();
    InputStream is = new FileInputStream(CONFIG_FILE);
    properties.load(is);/*from   ww w  . ja  v a 2 s . c  o  m*/
    is.close();
    sleepTime = Integer.parseInt(properties.getProperty("sleepTime", Integer.toString(defaultSleepTime)));
    batchTest.setAudioFileUri(properties.getProperty("audioFileUri", "/provisioned/behave.wav"));
    stop = Boolean.parseBoolean(properties.getProperty("stop", "false"));
    batchTest.setNumberOfRuns(Integer.parseInt(properties.getProperty("numberOfRuns", "1000")));
    int concurrentStarts = Integer.parseInt(properties.getProperty("numberOfConcurrentStarts", "4"));
    batchTest.setNumberOfConcurrentStarts(concurrentStarts);
    if (executorService == null)
        executorService = Executors.newFixedThreadPool(concurrentStarts);
    batchTest.setExecutorService(executorService);
    batchTest.setMaximumScenarioCompletionWaitTimeSeconds(
            Integer.parseInt(properties.getProperty("maximumScenarioCompletionWaitTimeSeconds", "60")));
    addBatchScenarios(batchTest);
}

From source file:org.nabucco.alfresco.enhScriptEnv.common.webscripts.RemoteJavascriptDebuggerPost.java

/**
 *
 * {@inheritDoc}// w w w  .  j a v  a  2  s. c o  m
 */
@Override
protected Map<String, Object> executeImpl(final WebScriptRequest req, final Status status) {
    final String visibleStr = req.getParameter("visible");
    final boolean visible = Boolean.parseBoolean(visibleStr);

    if (visible) {
        this.debugger.activate();
    } else {
        this.debugger.shutdown();
    }

    final Map<String, Object> model = new HashMap<String, Object>(7, 1.0f);
    model.put("visible", Boolean.valueOf(this.debugger.isActive()));
    return model;
}

From source file:photosharing.api.ExecutorUtil.java

/**
 * helper method that returns an HTTPClient executor with credentials
 * available.//from ww w .j a  v  a 2 s .c  o m
 * 
 * Also enables the test case to connect to ANY SSL Certificate
 * valid/invalid
 * 
 * @return {Executor} or Null if there is an issue
 */
public static Executor getExecutor() {
    Executor executor = null;

    /*
     * if using one of the environments without a trusted CA chain or
     * you are using Fiddler, you want to set TRUST=TRUE in appconfig.properties
     */
    Configuration config = Configuration.getInstance(null);
    String sTrust = config.getValue(Configuration.TRUST);
    boolean trusted = Boolean.parseBoolean(sTrust);
    if (trusted) {
        try {
            HttpClientBuilder builder = HttpClients.custom();

            // Setup the SSL Context to Trust Any SSL Certificate
            SSLContextBuilder sslBuilder = new SSLContextBuilder();
            sslBuilder.loadTrustMaterial(null, new TrustStrategy() {
                /**
                 * override for fiddler proxy
                 */
                public boolean isTrusted(X509Certificate[] certs, String host) throws CertificateException {
                    return true;
                }
            });
            SSLContext sslContext = sslBuilder.build();
            builder.setHostnameVerifier(new AllowAllHostnameVerifier());
            builder.setSslcontext(sslContext);

            CloseableHttpClient httpClient = builder.build();
            executor = Executor.newInstance(httpClient);
        } catch (NoSuchAlgorithmException e) {
            logger.log(Level.SEVERE, "Issue with No Algorithm " + e.toString());
        } catch (KeyStoreException e) {
            logger.log(Level.SEVERE, "Issue with KeyStore " + e.toString());
        } catch (KeyManagementException e) {
            logger.log(Level.SEVERE, "Issue with KeyManagement  " + e.toString());
        }
    }

    return executor;
}

From source file:io.cloudslang.content.httpclient.build.CookieStoreBuilder.java

public CookieStore buildCookieStore() {
    if (Boolean.parseBoolean(useCookies) && cookieStoreSessionObject != null) {
        BasicCookieStore cookieStore;//from   w  w w.ja  v  a2  s .c om
        if (cookieStoreSessionObject.getValue() == null) {
            cookieStore = new BasicCookieStore();
        } else {
            try {
                cookieStore = (BasicCookieStore) deserialize((byte[]) cookieStoreSessionObject.getValue());
            } catch (IOException | ClassNotFoundException e) {
                throw new RuntimeException(e.getMessage(), e);
            }
        }
        return cookieStore;
    }
    return null;
}

From source file:org.dspace.app.webui.cris.controller.admin.ProjectAdminController.java

@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {

    ModelAndView mav = super.handleRequest(request, response);
    String errore = request.getParameter("error");
    ProjectDTO grantDTO = new ProjectDTO();
    if (errore != null && Boolean.parseBoolean(errore) == true) {
        // errore
        mav.getModel().put("error", "jsp.dspace-admin.hku.error.add-grant");
    }// w  w w . j  av  a  2s. c o m
    mav.getModel().put("dto", grantDTO);
    return mav;
}