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:com.collective.celos.ci.config.CiCommandLineParser.java

public CiCommandLine parse(final String[] commandLineArguments) throws Exception {

    final CommandLineParser cmdLineGnuParser = new GnuParser();
    final Options gnuOptions = constructOptionsForParsing();
    CommandLine commandLine = cmdLineGnuParser.parse(gnuOptions, commandLineArguments);

    if (!commandLine.hasOption(CLI_TARGET) || !commandLine.hasOption(CLI_MODE)
            || !commandLine.hasOption(CLI_WORKFLOW_NAME)) {
        printHelp(80, 5, 3, true, System.out);
        throw new RuntimeException("Wrong CelosCi configuration provided");
    }/*w ww. jav a2 s .c o  m*/

    String deployDir = commandLine.getOptionValue(CLI_DEPLOY_DIR);
    String mode = commandLine.getOptionValue(CLI_MODE);
    String workflowName = commandLine.getOptionValue(CLI_WORKFLOW_NAME);
    String targetUri = commandLine.getOptionValue(CLI_TARGET);
    String testCasesDir = commandLine.getOptionValue(CLI_TEST_CASES_DIR, DEFAULT_TEST_CASES_DIR);
    String hdfsRoot = commandLine.getOptionValue(CLI_HDFS_ROOT, Constants.DEFAULT_HDFS_ROOT);
    String celosServerUri = commandLine.getOptionValue(CLI_CELOS_SERVER);

    boolean keepTempData = Boolean.parseBoolean(System.getenv(KEEP_TEMP_DATA));
    String userName = System.getenv(USERNAME_ENV_VAR);
    if (userName == null) {
        userName = System.getProperty("user.name");
    }
    return new CiCommandLine(targetUri, mode, deployDir, workflowName, testCasesDir, userName, keepTempData,
            celosServerUri, hdfsRoot);
}

From source file:com.haulmont.cuba.gui.xml.layout.loaders.ActionsHolderLoader.java

protected void loadStandardActionProperties(Action instance, Element element) {
    String enable = element.attributeValue("enable");
    if (StringUtils.isNotEmpty(enable)) {
        instance.setEnabled(Boolean.parseBoolean(enable));
    }// w w w.  j  av a 2  s.co m

    String visible = element.attributeValue("visible");
    if (StringUtils.isNotEmpty(visible)) {
        instance.setVisible(Boolean.parseBoolean(visible));
    }

    String caption = element.attributeValue("caption");
    if (StringUtils.isNotEmpty(caption)) {
        instance.setCaption(loadResourceString(caption));
    }

    String description = element.attributeValue("description");
    if (StringUtils.isNotEmpty(description)) {
        instance.setDescription(loadResourceString(description));
    }

    String icon = element.attributeValue("icon");
    if (StringUtils.isNotEmpty(icon)) {
        instance.setIcon(getIconPath(icon));
    }
}

From source file:rest.GroupREST.java

private Group getFormattedDataSingle(Response response) {
    String responseJson = response.readEntity(String.class);
    System.out.println(responseJson);
    ObjectMapper mapper = new ObjectMapper();
    TypeReference<HashMap<String, Object>> typeReference = new TypeReference<HashMap<String, Object>>() {
    };/*from ww w  .  j  a v  a2 s .  c om*/
    StringBuilder sb = new StringBuilder();
    try {
        HashMap<String, Object> map = mapper.readValue(responseJson, typeReference);
        if (Boolean.parseBoolean(map.get("found").toString())) {
            return Group.parseGroup(map);
            //               
        } else {
            return null;
        }
    } catch (Exception e) {
        return null;
    }
}

From source file:dk.alexandra.fresco.suite.tinytables.prepro.TinyTablesPreproConfiguration.java

public static ProtocolSuiteConfiguration fromCmdLine(SCEConfiguration sceConf, CommandLine cmd)
        throws ParseException, IllegalArgumentException {

    Options options = new Options();

    TinyTablesPreproConfiguration configuration = new TinyTablesPreproConfiguration();

    /*//from w w  w  . j  a  v  a  2  s .c o  m
     * Parse TinyTables specific options
     */

    String otExtensionOption = "tinytables.otExtension";
    String otExtensionPortOption = "tinytables.otExtensionPort";
    String tinytablesFileOption = "tinytables.file";

    options.addOption(Option.builder("D").desc(
            "Specify whether we should try to use SCAPIs OT-Extension lib. This requires the SCAPI library to be installed.")
            .longOpt(otExtensionOption).required(false).hasArgs().build());

    options.addOption(Option.builder("D")
            .desc("The port number for the OT-Extension lib. Both players should specify the same here.")
            .longOpt(otExtensionPortOption).required(false).hasArgs().build());

    options.addOption(Option.builder("D").desc("The file where the generated TinyTables should be stored.")
            .longOpt(tinytablesFileOption).required(false).hasArgs().build());

    Properties p = cmd.getOptionProperties("D");

    boolean useOtExtension = Boolean.parseBoolean(p.getProperty(otExtensionOption, "false"));
    configuration.setUseOtExtension(useOtExtension);

    int otExtensionPort = Integer.parseInt(p.getProperty(otExtensionPortOption, "9005"));
    Party sender = sceConf.getParties().get(1);
    configuration.setSenderAddress(InetSocketAddress.createUnresolved(sender.getHostname(), otExtensionPort));
    ;

    String tinyTablesFilePath = p.getProperty(tinytablesFileOption, "tinytables");
    File tinyTablesFile = new File(tinyTablesFilePath);
    configuration.setTinyTablesFile(tinyTablesFile);

    // We are not testing when running from command line
    configuration.setTesting(false);

    return configuration;
}

From source file:com.c77.androidstreamingclient.lib.rtp.RtpMediaBufferWithJitterAvoidance.java

public RtpMediaBufferWithJitterAvoidance(RtpMediaExtractor rtpMediaExtractor, Properties properties) {

    this.rtpMediaExtractor = rtpMediaExtractor;
    streamingState = State.IDLE;//from   w  ww. j a v a  2 s  .c  o m
    dataPacketSenderThread = new DataPacketSenderThread();

    properties = (properties != null) ? properties : new Properties();
    DEBUGGING = Boolean.parseBoolean(properties.getProperty(DEBUGGING_PROPERTY, "false"));
    FRAMES = Integer.parseInt(properties.getProperty(FRAMES_WINDOW_PROPERTY, "50"));
    log.info("Using RtpMediaBufferWithJitterAvoidance with FRAMES = [" + FRAMES + "]");
}

From source file:com.mockey.ui.TwistInfoToggleServlet.java

/**
 * Handles the following activities for <code>TwistInfo</code>
 * /*from   w  w  w.  j av a2  s.c o m*/
 */
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    String responseType = req.getParameter("response-type");
    // If type is JSON, then respond with JSON
    // Otherwise, direct to JSP

    Long twistInfoId = null;
    TwistInfo twistInfo = null;
    String coachingMessage = null;
    JSONObject jsonObject = new JSONObject();

    try {
        twistInfoId = new Long(req.getParameter(PARAMETER_KEY_TWIST_ID));
        boolean enable = Boolean.parseBoolean(req.getParameter(PARAMETER_KEY_TWIST_ENABLE));
        twistInfo = store.getTwistInfoById(twistInfoId);
        if (enable) {
            store.setUniversalTwistInfoId(twistInfo.getId());
            if (twistInfo != null) {
                jsonObject.put(PARAMETER_KEY_TWIST_ID, "" + twistInfo.getId());
                jsonObject.put(PARAMETER_KEY_TWIST_NAME, "" + twistInfo.getName());
                coachingMessage = "Twist configuration on";
            }

        } else if (store.getUniversalTwistInfoId() != null
                && store.getUniversalTwistInfoId().equals(twistInfoId)) {
            // Disable
            // The only way to DISABLE _all_ twist configurations, both ENABLE (false) and TWIST-ID value (equal 
            // to the current universal twist-id have to be passed in. 
            // Why? To prevent random 'ENABLE=false' arguments past to this service from users 
            // clicking OFF/disable when things are already disabled. 
            // 
            store.setUniversalTwistInfoId(null);
            coachingMessage = "Twist configuration off";
        }

    } catch (Exception e) {
        logger.error("Unable to properly set Twist configuration.", e);
    }

    if (PARAMETER_KEY_RESPONSE_TYPE_VALUE_JSON.equalsIgnoreCase(responseType)) {
        // ***********************
        // BEGIN - JSON response
        // ***********************
        resp.setContentType("application/json");
        PrintWriter out = resp.getWriter();
        try {
            JSONObject jsonResponseObject = new JSONObject();
            if (twistInfo != null) {
                jsonObject.put("success", coachingMessage);

            } else {
                jsonObject.put("fail", "Unable to set twist configuration.");

            }
            jsonResponseObject.put("result", jsonObject);
            out.println(jsonResponseObject.toString());

        } catch (JSONException jsonException) {
            throw new ServletException(jsonException);
        }

        out.flush();
        out.close();
        return;
        // ***********************
        // END - JSON response
        // ***********************

    } else {
        List<TwistInfo> twistInfoList = store.getTwistInfoList();
        Util.saveSuccessMessage("Twist configuration updated", req);
        req.setAttribute("twistInfoList", twistInfoList);
        req.setAttribute("twistInfoIdEnabled", store.getUniversalTwistInfoId());
        RequestDispatcher dispatch = req.getRequestDispatcher("/twistinfo_setup.jsp");
        dispatch.forward(req, resp);
        return;
    }

}

From source file:eu.prestoprime.plugin.dracma.DRACMATasks.java

@WfService(name = "dracma_indexing", version = "2.0.0")
public void index(Map<String, String> sParams, Map<String, String> dParamsString, Map<String, File> dParamsFile)
        throws TaskExecutionFailedException {

    if (Boolean.parseBoolean(dParamsString.get("isD10"))) {
        // retrieve dynamic parameters
        String sipID = dParamsString.get("sipID");

        // retrieve static parameters
        String DRACMAIndexServer = sParams.get("dracma.indexing.url");
        String[] MQFormats = sParams.get("MQformats").split(",");

        SIP sip = null;//from   w w w  . j a  va2 s .  c o  m
        try {
            sip = P4DataManager.getInstance().getSIPByID(sipID);

            for (String format : MQFormats) {
                List<String> MQFilePathList = sip.getAVMaterial(format, "FILE");
                if (MQFilePathList.size() > 0) {

                    URI indexServer = new URI(DRACMAIndexServer);
                    File mxfFile = new File(MQFilePathList.get(0));

                    String UMID = new DRACMAClient(indexServer).index(mxfFile);

                    MessageDigestExtractor mde = new MessageDigestExtractor();
                    ToolOutput<MessageDigestExtractor.AttributeType> output = mde
                            .extract(mxfFile.getAbsolutePath());

                    sip.addFile(format, "DRACMA", UMID,
                            output.getAttribute(MessageDigestExtractor.AttributeType.MD5), mxfFile.length());

                    break;
                }
            }

        } catch (DataException e) {
            e.printStackTrace();
            throw new TaskExecutionFailedException("Unable to retrieve the SIP...");
        } catch (IPException e) {
            e.printStackTrace();
            throw new TaskExecutionFailedException("Unable to retrieve the MQ file...");
        } catch (DRACMAException e) {
            e.printStackTrace();
            throw new TaskExecutionFailedException("Unable to execute DRACMA indexing...");
        } catch (ToolException e) {
            e.printStackTrace();
            throw new TaskExecutionFailedException("Unable to compute the MD5...");
        } catch (URISyntaxException e) {
            e.printStackTrace();
            throw new TaskExecutionFailedException("Bad DRACMA indexing URL in wfDescriptor...");
        } finally {
            P4DataManager.getInstance().releaseIP(sip);
        }
    }
}

From source file:com.mozilla.fhr.consumer.FHRConsumer.java

public static void main(String[] args) {
    Options options = FHRConsumer.getOptions();
    CommandLineParser parser = new GnuParser();
    ShutdownHook sh = ShutdownHook.getInstance();
    try {//from   w  w  w  . j a v  a  2s  .  com
        // Parse command line options
        CommandLine cmd = parser.parse(options, args);

        final FHRConsumer consumer = (FHRConsumer) FHRConsumer.fromOptions(cmd);
        sh.addFirst(consumer);

        // Set the sink for consumer storage
        SinkConfiguration sinkConfig = new SinkConfiguration();
        if (cmd.hasOption("numthreads")) {
            sinkConfig.setInt("hbasesink.hbase.numthreads", Integer.parseInt(cmd.getOptionValue("numthreads")));
        }
        if (cmd.hasOption("batchsize")) {
            sinkConfig.setInt("hbasesink.hbase.batchsize", Integer.parseInt(cmd.getOptionValue("batchsize")));
        }

        sinkConfig.setString("hbasesink.hbase.tablename", cmd.getOptionValue("table"));
        sinkConfig.setString("hbasesink.hbase.column.family", cmd.getOptionValue("family", "data"));
        sinkConfig.setString("hbasesink.hbase.column.qualifier", cmd.getOptionValue("qualifier", "json"));
        sinkConfig.setBoolean("hbasesink.hbase.rowkey.prefixdate",
                Boolean.parseBoolean(cmd.getOptionValue("prefixdate", "false")));
        KeyValueSinkFactory sinkFactory = KeyValueSinkFactory.getInstance(HBaseSink.class, sinkConfig);
        sh.addLast(sinkFactory);
        consumer.setSinkFactory(sinkFactory);

        // Initialize metrics collection, reporting, etc.
        final MetricsManager manager = MetricsManager.getDefaultMetricsManager();

        // Begin polling
        consumer.poll();
    } catch (ParseException e) {
        LOG.error("Error parsing command line options", e);
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(FHRConsumer.class.getName(), options);
    }
}

From source file:com.google.mr4c.hadoop.MR4CMRJob.java

private boolean isRemote(MR4CConfig bbConf) {
    String strVal = getProperty(bbConf, Category.HADOOP, HadoopConfig.PROP_REMOTE);
    return StringUtils.isEmpty(strVal) ? false : Boolean.parseBoolean(strVal);
}