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.jolokia.jvmagent.spring.config.AgentBeanDefinitionParser.java

@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    Element config = DomUtils.getChildElementByTagName(element, "config");
    if (config != null) {
        builder.addPropertyValue("config",
                parserContext.getDelegate().parseCustomElement(config, builder.getRawBeanDefinition()));
    }// w  w  w.  j a  v a  2s .com
    String lookupConfig = element.getAttribute("lookupConfig");
    if (StringUtils.hasLength(lookupConfig)) {
        builder.addPropertyValue("lookupConfig", Boolean.parseBoolean(lookupConfig));
    } else {
        builder.addPropertyValue("lookupConfig", false);
    }
    String systemPropertiesMode = element.getAttribute("systemPropertiesMode");
    if (StringUtils.hasLength(systemPropertiesMode)) {
        builder.addPropertyValue("systemPropertiesMode", systemPropertiesMode);
    }
}

From source file:code.google.nfs.rpc.netty4.client.Netty4ClientFactory.java

protected Client createClient(String targetIP, int targetPort, int connectTimeout, String key)
        throws Exception {
    final Netty4ClientHandler handler = new Netty4ClientHandler(this, key);

    EventLoopGroup group = new NioEventLoopGroup(1);
    Bootstrap b = new Bootstrap();
    b.group(group).channel(NioSocketChannel.class)
            .option(ChannelOption.TCP_NODELAY,
                    Boolean.parseBoolean(System.getProperty("nfs.rpc.tcp.nodelay", "true")))
            .option(ChannelOption.SO_REUSEADDR,
                    Boolean.parseBoolean(System.getProperty("nfs.rpc.tcp.reuseaddress", "true")))
            .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout < 1000 ? 1000 : connectTimeout)
            .handler(new ChannelInitializer<SocketChannel>() {
                @Override//www. j a  v  a  2  s. c  o  m
                public void initChannel(SocketChannel ch) throws Exception {
                    ch.pipeline().addLast("decoder", new Netty4ProtocolDecoder());
                    ch.pipeline().addLast("encoder", new Netty4ProtocolEncoder());
                    ch.pipeline().addLast("handler", handler);
                }
            });

    ChannelFuture future = b.connect(targetIP, targetPort);

    future.awaitUninterruptibly(connectTimeout);
    if (!future.isDone()) {
        LOGGER.error("Create connection to " + targetIP + ":" + targetPort + " timeout!");
        throw new Exception("Create connection to " + targetIP + ":" + targetPort + " timeout!");
    }
    if (future.isCancelled()) {
        LOGGER.error("Create connection to " + targetIP + ":" + targetPort + " cancelled by user!");
        throw new Exception("Create connection to " + targetIP + ":" + targetPort + " cancelled by user!");
    }
    if (!future.isSuccess()) {
        LOGGER.error("Create connection to " + targetIP + ":" + targetPort + " error", future.cause());
        throw new Exception("Create connection to " + targetIP + ":" + targetPort + " error", future.cause());
    }
    Netty4Client client = new Netty4Client(future, key, connectTimeout);
    handler.setClient(client);
    return client;
}

From source file:com.mgmtp.jfunk.web.FormInputHandlerProvider.java

@Override
public FormInputHandler get() {
    FormInputHandler fih = FormInputHandler.create().webDriver(webDriverProvider.get());

    Configuration config = configProvider.get();
    String value = trimToNull(config.get(WebConstants.FIH_ENABLED));
    if (value != null) {
        fih = fih.enabled(Boolean.parseBoolean(value));
    }//w w  w.ja  v  a2  s . c om
    value = trimToNull(config.get(WebConstants.FIH_DISPLAYED));
    if (value != null) {
        fih = fih.displayed(Boolean.parseBoolean(value));
    }
    long timeout = config.getLong(WebConstants.FIH_TIMEOUT_SECONDS, 0L);
    if (timeout > 0L) {
        long sleepMillis = config.getLong(WebConstants.FIH_SLEEP_MILLIS, 0L);
        fih = sleepMillis > 0L ? fih.timeout(timeout, sleepMillis) : fih.timeout(timeout);
    }

    return fih;
}

From source file:com.mgmtp.jfunk.web.WebElementFinderProvider.java

@Override
public WebElementFinder get() {
    WebElementFinder wef = WebElementFinder.create().webDriver(webDriverProvider.get());

    Configuration config = configProvider.get();
    String value = trimToNull(config.get(WebConstants.WEF_ENABLED));
    if (value != null) {
        wef = wef.enabled(Boolean.parseBoolean(value));
    }//w  ww .j  a v a  2s.  c om
    value = trimToNull(config.get(WebConstants.WEF_DISPLAYED));
    if (value != null) {
        wef = wef.displayed(Boolean.parseBoolean(value));
    }
    long timeout = config.getLong(WebConstants.WEF_TIMEOUT_SECONDS, 0L);
    if (timeout > 0L) {
        long sleepMillis = config.getLong(WebConstants.WEF_SLEEP_MILLIS, 0L);
        wef = sleepMillis > 0L ? wef.timeout(timeout, sleepMillis) : wef.timeout(timeout);
    }

    return wef;
}

From source file:com.yahoo.pulsar.admin.cli.PulsarAdminTool.java

PulsarAdminTool(Properties properties) throws Exception {
    // fallback to previous-version serviceUrl property to maintain backward-compatibility
    String serviceUrl = StringUtils.isNotBlank(properties.getProperty("webServiceUrl"))
            ? properties.getProperty("webServiceUrl")
            : properties.getProperty("serviceUrl");
    String authPluginClassName = properties.getProperty("authPlugin");
    String authParams = properties.getProperty("authParams");
    boolean useTls = Boolean.parseBoolean(properties.getProperty("useTls"));
    boolean tlsAllowInsecureConnection = Boolean
            .parseBoolean(properties.getProperty("tlsAllowInsecureConnection"));
    String tlsTrustCertsFilePath = properties.getProperty("tlsTrustCertsFilePath");

    URL url = null;/*  w  ww  .j ava 2s . co m*/
    try {
        url = new URL(serviceUrl);
    } catch (MalformedURLException e) {
        System.err.println("Invalid serviceUrl: '" + serviceUrl + "'");
        System.exit(1);
    }

    ClientConfiguration config = new ClientConfiguration();
    config.setAuthentication(authPluginClassName, authParams);
    config.setUseTls(useTls);
    config.setTlsAllowInsecureConnection(tlsAllowInsecureConnection);
    config.setTlsTrustCertsFilePath(tlsTrustCertsFilePath);

    admin = new PulsarAdmin(url, config);
    jcommander = new JCommander();
    jcommander.setProgramName("pulsar-admin");
    jcommander.addObject(this);
    jcommander.addCommand("clusters", new CmdClusters(admin));
    jcommander.addCommand("ns-isolation-policy", new CmdNamespaceIsolationPolicy(admin));
    jcommander.addCommand("brokers", new CmdBrokers(admin));
    jcommander.addCommand("broker-stats", new CmdBrokerStats(admin));
    jcommander.addCommand("properties", new CmdProperties(admin));
    jcommander.addCommand("namespaces", new CmdNamespaces(admin));
    jcommander.addCommand("persistent", new CmdPersistentTopics(admin));
    jcommander.addCommand("resource-quotas", new CmdResourceQuotas(admin));
}

From source file:AIR.Common.Utilities.JavaPrimitiveUtils.java

public static boolean boolTryParse(String value, _Ref<Boolean> ref) {
    try {//from   w w  w .j  av  a2s.  c o  m
        ref.set(Boolean.parseBoolean(value));
        return true;
    } catch (NumberFormatException exp) {
        return false;
    }
}

From source file:de.hybris.platform.dfcheckoutfacade.cart.impl.DfDefaultCartFacade.java

@Override
public void updateEntiresSelectedStatus(final String code, final String status) {
    //first, update status
    final CartModel cart = getCartService().getSessionCart();
    final List<AbstractOrderEntryModel> entries = cart.getEntries();
    for (final AbstractOrderEntryModel entry : entries) {
        if (entry.getProduct().getCode().equals(code)) {
            entry.setChecked(Boolean.parseBoolean(status));
            cart.setEntries(entries);/*  w  w  w  .  j  ava2  s .c o  m*/
            getModelService().save(entry);
            getModelService().refresh(cart);
        }
    }
    //second, update checkout price
    try {
        getCalculationService().recalculate(cart);
    } catch (final CalculationException e) {
        e.printStackTrace();
    }
}

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

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

From source file:ivory.core.tokenize.Tokenizer.java

@SuppressWarnings("static-access")
public static void main(String[] args) {
    Options options = new Options();
    options.addOption(OptionBuilder.withArgName("full path to model file or directory").hasArg()
            .withDescription("model file").create("model"));
    options.addOption(OptionBuilder.withArgName("full path to input file").hasArg()
            .withDescription("input file").isRequired().create("input"));
    options.addOption(OptionBuilder.withArgName("full path to output file").hasArg()
            .withDescription("output file").isRequired().create("output"));
    options.addOption(OptionBuilder.withArgName("en | zh | de | fr | ar | tr | es").hasArg()
            .withDescription("2-character language code").isRequired().create("lang"));
    options.addOption(OptionBuilder.withArgName("path to stopwords list").hasArg()
            .withDescription("one stopword per line").create("stopword"));
    options.addOption(OptionBuilder.withArgName("path to stemmed stopwords list").hasArg()
            .withDescription("one stemmed stopword per line").create("stemmed_stopword"));
    options.addOption(OptionBuilder.withArgName("true|false").hasArg().withDescription("turn on/off stemming")
            .create("stem"));
    options.addOption(OptionBuilder.withDescription("Hadoop option to load external jars")
            .withArgName("jar packages").hasArg().create("libjars"));

    CommandLine cmdline;//ww  w  . j a  v a  2 s  . c o  m
    CommandLineParser parser = new GnuParser();
    try {
        String stopwordList = null, stemmedStopwordList = null, modelFile = null;
        boolean isStem = true;
        cmdline = parser.parse(options, args);
        if (cmdline.hasOption("stopword")) {
            stopwordList = cmdline.getOptionValue("stopword");
        }
        if (cmdline.hasOption("stemmed_stopword")) {
            stemmedStopwordList = cmdline.getOptionValue("stemmed_stopword");
        }
        if (cmdline.hasOption("stem")) {
            isStem = Boolean.parseBoolean(cmdline.getOptionValue("stem"));
        }
        if (cmdline.hasOption("model")) {
            modelFile = cmdline.getOptionValue("model");
        }

        ivory.core.tokenize.Tokenizer tokenizer = TokenizerFactory.createTokenizer(
                cmdline.getOptionValue("lang"), modelFile, isStem, stopwordList, stemmedStopwordList, null);
        BufferedWriter out = new BufferedWriter(
                new OutputStreamWriter(new FileOutputStream(cmdline.getOptionValue("output")), "UTF8"));
        BufferedReader in = new BufferedReader(
                new InputStreamReader(new FileInputStream(cmdline.getOptionValue("input")), "UTF8"));

        String line = null;
        while ((line = in.readLine()) != null) {
            String[] tokens = tokenizer.processContent(line);
            String s = "";
            for (String token : tokens) {
                s += token + " ";
            }
            out.write(s.trim() + "\n");
        }
        in.close();
        out.close();

    } catch (Exception exp) {
        System.out.println(exp);
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("Tokenizer", options);
        System.exit(-1);
    }
}

From source file:com.dianping.lion.service.impl.SystemSettingServiceImpl.java

@Override
public boolean getBool(String key, boolean defaultIfNull) {
    String settingVal = getSetting(key);
    return settingVal != null ? Boolean.parseBoolean(settingVal) : defaultIfNull;
}