Example usage for java.lang Boolean valueOf

List of usage examples for java.lang Boolean valueOf

Introduction

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

Prototype

public static Boolean valueOf(String s) 

Source Link

Document

Returns a Boolean with a value represented by the specified string.

Usage

From source file:com.virtualparadigm.packman.cli.Main.java

public static void main(String[] args) {
    if (args.length > 0) {
        CommandLineParser cliParser = new BasicParser();
        CommandLine cmd = null;//from w  w  w  .  j  a v a2s  .c om
        try {
            cmd = cliParser.parse(Main.buildCommandLineOptions(), args);
        } catch (ParseException pe) {
            throw new RuntimeException(pe);
        }
        if (cmd != null) {
            boolean status = false;
            if (CMD_CREATE.equalsIgnoreCase(args[0])) {
                status = JPackageManager.createPackage(cmd.getOptionValue(CMD_OPTION_LONG_PACKAGE_NAME),
                        cmd.getOptionValue(CMD_OPTION_LONG_PACKAGE_VERSION),
                        new File(cmd.getOptionValue(CMD_OPTION_LONG_PACKAGE_FILE)),
                        new File(cmd.getOptionValue(CMD_OPTION_LONG_OLD_STATE_DIR)),
                        new File(cmd.getOptionValue(CMD_OPTION_LONG_NEW_STATE_DIR)),
                        new File(cmd.getOptionValue(CMD_OPTION_LONG_LICENSE_FILE)),
                        new File(cmd.getOptionValue(CMD_OPTION_LONG_AUTORUN_INSTALL_DIR)),
                        new File(cmd.getOptionValue(CMD_OPTION_LONG_AUTORUN_UNINSTALL_DIR)),
                        (cmd.getOptionValue(CMD_OPTION_LONG_TEMP_DIR) == null) ? null
                                : new File(cmd.getOptionValue(CMD_OPTION_LONG_TEMP_DIR)),
                        (cmd.getOptionValue(CMD_OPTION_LONG_DEV_MODE) != null)
                                ? Boolean.valueOf(cmd.getOptionValue(CMD_OPTION_LONG_DEV_MODE))
                                : false);

                if (status) {
                    System.out.println("Package creation successful");
                } else {
                    System.out.println("Package creation failed");
                }
            } else if (CMD_INSTALL.equalsIgnoreCase(args[0])) {
                status = JPackageManager.installPackage(
                        new File(cmd.getOptionValue(CMD_OPTION_LONG_PACKAGE_FILE)),
                        new File(cmd.getOptionValue(CMD_OPTION_LONG_TARGET_DIR)),
                        new File(cmd.getOptionValue(CMD_OPTION_LONG_DATA_DIR)),
                        new File(cmd.getOptionValue(CMD_OPTION_LONG_LOCAL_CONFIG_FILE)),
                        (cmd.getOptionValue(CMD_OPTION_LONG_DEV_MODE) != null)
                                ? Boolean.valueOf(cmd.getOptionValue(CMD_OPTION_LONG_DEV_MODE))
                                : false);

                if (status) {
                    System.out.println("Package installation successful");
                } else {
                    System.out.println("Package installation failed");
                }

            } else if (CMD_LIST.equalsIgnoreCase(args[0])) {
                System.out.println("Installed Packages");
                System.out.println("");
                Collection<Package> installedPackages = JPackageManager.listPackages();
                if (installedPackages != null) {
                    for (Package installedPackage : installedPackages) {
                        System.out.println("package: " + installedPackage.getName());
                        System.out.println("  version: " + installedPackage.getVersion());
                        System.out.println("  timestamp: " + installedPackage.getInstallTimestamp());
                        System.out.println("  root directory: " + installedPackage.getRootDirectory());
                        System.out.println("");
                    }
                }
            } else {
                System.out.println("unsupported JPatchManager operation");
            }
        } else {
            System.out.println("No command specified. Options are:");
            System.out.println("  " + CMD_CREATE);
            System.out.println("  " + CMD_INSTALL);
            System.out.println("  " + CMD_LIST);
        }
    }
}

From source file:acromusashi.stream.example.topology.HbaseStoreTopology.java

/**
 * ?<br/>/*from   w  w w.j a va2  s. c  o m*/
 * <ul>
 * <li>:arg[0] ??yaml</li>
 * <li>:arg[1] Storm?(true:LocalMode?false:DistributeMode)</li>
 * </ul>
 * @param args 
 * @throws Exception ?
 */
public static void main(String[] args) throws Exception {
    // ???
    if (args.length < 2) {
        System.out.println("Usage: java HbaseStoreTopology ConfigPath isExecuteLocal(true|false)");
        return;
    }

    // ??????Storm?
    Config conf = StormConfigGenerator.loadStormConfig(args[0]);

    // ??(or)
    boolean isLocal = Boolean.valueOf(args[1]);

    // Topology?
    BaseTopology topology = new HbaseStoreTopology("HbaseStoreTopology", conf);
    topology.buildTopology();
    topology.submitTopology(isLocal);
}

From source file:acromusashi.stream.example.topology.Snmp2HbaseStoreTopology.java

/**
 * ?<br/>// w w w .  ja v  a  2s  . c  om
 * <ul>
 * <li>:arg[0] ??yaml</li>
 * <li>:arg[1] Storm?(true:LocalMode?false:DistributeMode)</li>
 * </ul>
 * @param args 
 * @throws Exception ?
 */
public static void main(String[] args) throws Exception {
    // ???
    if (args.length < 2) {
        System.out.println("Usage: java Snmp2HbaseStoreTopology ConfigPath isExecuteLocal(true|false)");
        return;
    }

    // ??????Storm?
    Config conf = StormConfigGenerator.loadStormConfig(args[0]);

    // ??(or)
    boolean isLocal = Boolean.valueOf(args[1]);

    // Topology?
    BaseTopology topology = new Snmp2HbaseStoreTopology("Snmp2HbaseStoreTopology", conf);
    topology.buildTopology();
    topology.submitTopology(isLocal);
}

From source file:org.venice.piazza.servicecontroller.Application.java

public static void main(String[] args) {
    ApplicationContext ctx = SpringApplication.run(Application.class, args); //NOSONAR
    // now check to see if the first parameter is true, if so then test the health of the
    // Spring environment
    if (args.length == 1) {
        // Get the value of the first argument
        // If it is true then do a health check and print it out
        if (Boolean.valueOf(args[0]) == true) {
            inspectSprintEnv(ctx);/*from ww w.ja  v  a2 s  .  com*/
        }
    }
}

From source file:hydrograph.server.execution.tracking.client.main.HydrographMain.java

/**
 * The main method.//from  ww  w  . jav  a2s.  co  m
 *
 * @param args
 *            the arguments
 * @throws Exception
 *             the exception
 */
public static void main(String[] args) throws Exception {

    HydrographMain hydrographMain = new HydrographMain();
    final Timer timer = new Timer();
    final CountDownLatch latch = new CountDownLatch(1);
    try {
        Session session = null;
        boolean isExecutionTracking = false;
        String[] argsList = args;
        List<String> argumentList = new ArrayList<String>(Arrays.asList(args));
        final String jobId = hydrographMain.getJobId(argumentList);

        getLogLevel(argumentList).ifPresent(x -> {
            if (!x.equalsIgnoreCase(String.valueOf(logger.getLevel()))) {
                setLoglevel(x);
            } else {
                Optional.empty();
            }

        });

        logger.info("Argument List: " + argumentList.toString());

        String trackingClientSocketPort = hydrographMain.getTrackingClientSocketPort(argumentList);

        if (argumentList.contains(Constants.IS_TRACKING_ENABLE)) {
            int index = argumentList.indexOf(Constants.IS_TRACKING_ENABLE);
            isExecutionTracking = Boolean.valueOf(argsList[index + 1]);
            argumentList = removeItemFromIndex(index, argumentList);
        }

        if (argumentList.contains(Constants.TRACKING_CLIENT_SOCKET_PORT)) {
            int index = argumentList.indexOf(Constants.TRACKING_CLIENT_SOCKET_PORT);
            argumentList = removeItemFromIndex(index, argumentList);
        }

        argsList = argumentList.toArray(new String[argumentList.size()]);

        logger.debug("Execution tracking enabled - " + isExecutionTracking);
        logger.info("Tracking Client Port: " + trackingClientSocketPort);

        /**
         * Start new thread to run job
         */
        final HydrographService execution = new HydrographService();

        FutureTask task = hydrographMain.executeGraph(latch, jobId, argsList, execution, isExecutionTracking);

        hydrographMain.executorService = Executors.newSingleThreadExecutor();
        hydrographMain.executorService.submit(task);

        if (isExecutionTracking) {
            //If tracking is enabled, start to post execution tracking status.
            final HydrographEngineCommunicatorSocket socket = new HydrographEngineCommunicatorSocket(execution);
            session = hydrographMain.connectToServer(socket, jobId, trackingClientSocketPort);
            hydrographMain.sendExecutionTrackingStatus(latch, session, jobId, timer, execution, socket);
        }

        //waiting for execute graph thread 
        task.get();

    } catch (Exception exp) {
        logger.info("Getting exception from HydrographMain");
        throw new RuntimeException(exp);
    } finally {
        //cleanup threads --> executor thread and timer thread 
        logger.info("HydrographMain releasing resources");
        if (!hydrographMain.executorService.isShutdown() && !hydrographMain.executorService.isTerminated()) {
            hydrographMain.executorService.shutdown();
        }
        timer.cancel();

    }
}

From source file:com.dustindoloff.pngtastic.Main.java

public static void main(final String[] args) throws FileNotFoundException, IOException {
    final CommandLine commandLine = parseArgs(args);

    final String in = commandLine.getOptionValue(ARG_INPUT_PNG);
    final String out = commandLine.getOptionValue(ARG_OUTPUT_PNG);
    final String logLevel = commandLine.getOptionValue(ARG_LOG_LEVEL);
    final Integer iterations = toInteger(commandLine.getOptionValue(ARG_ITERATIONS));
    final String compressor = commandLine.getOptionValue(ARG_COMPRESSOR);
    final Boolean removeGamma = Boolean.valueOf(commandLine.getOptionValue(ARG_REMOVE_GAMMA));
    final Integer compressionLevel = toInteger(commandLine.getOptionValue(ARG_COMPRESSION_LEVEL));

    final PngOptimizer pngOptimizer = new PngOptimizer(logLevel);
    pngOptimizer.setCompressor(compressor, iterations);
    final PngImage pngImage = new PngImage(in, logLevel);
    pngOptimizer.optimize(pngImage, out, removeGamma, compressionLevel);
}

From source file:acromusashi.stream.example.topology.Snmp2HbaseHdfsStoreTopology.java

/**
 * ?<br/>// ww w  .jav  a  2  s  .  co m
 * <ul>
 * <li>:arg[0] ??yaml</li>
 * <li>:arg[1] Storm?(true:LocalMode?false:DistributeMode)</li>
 * </ul>
 * @param args 
 * @throws Exception ?
 */
public static void main(String[] args) throws Exception {
    // ???
    if (args.length < 2) {
        System.out.println("Usage: java Snmp2HbaseHdfsStoreTopology ConfigPath isExecuteLocal(true|false)");
        return;
    }

    // ??????Storm?
    Config conf = StormConfigGenerator.loadStormConfig(args[0]);

    // ??(or)
    boolean isLocal = Boolean.valueOf(args[1]);

    // Topology?
    BaseTopology topology = new Snmp2HbaseHdfsStoreTopology("Snmp2HbaseHdfsStoreTopology", conf);
    topology.buildTopology();
    topology.submitTopology(isLocal);
}

From source file:org.atomserver.utils.jetty.StandAloneAtomServer.java

public static void main(String[] args) throws Exception {

    // the System Property "atomserver.home" defines the home directory for the standalone app
    String atomserverHome = System.getProperty("atomserver.home");
    if (StringUtils.isEmpty(atomserverHome)) {
        log.error("The variable \"atomserver.home\" must be defined");
        System.exit(-1);//www.ja v  a  2  s.co m
    }
    File atomserverHomeDir = new File(atomserverHome);
    if (!atomserverHomeDir.exists() && !atomserverHomeDir.isDirectory()) {
        log.error("The variable \"atomserver.home\" (" + atomserverHome
                + ") must point to a directory that exists");
    }

    // instantiate the Jetty Server
    Server server = new Server();

    // create a new connector on the declared port, and set it onto the server
    log.debug("atomserver.port = " + System.getProperty("atomserver.port"));
    Connector connector = new SelectChannelConnector();
    connector.setPort(Integer.getInteger("atomserver.port", DEFAULT_PORT));
    server.setConnectors(new Connector[] { connector });

    // create a ClassLoader that points at the conf directories
    log.debug("atomserver.conf.dir = " + System.getProperty("atomserver.conf.dir"));
    log.debug("atomserver.ops.conf.dir = " + System.getProperty("atomserver.ops.conf.dir"));
    ClassLoader classLoader = new ConfigurationAwareClassLoader(StandAloneAtomServer.class.getClassLoader());

    // load the version from the version.properties file
    Properties versionProps = new Properties();
    versionProps.load(classLoader.getResourceAsStream(DEFAULT_VERSIONS_FILE));
    String version = versionProps.getProperty("atomserver.version");

    // create a new webapp, rooted at webapps/atomserver-${version}, with the configured
    // context name
    String servletContextName = System.getProperty("atomserver.servlet.context");
    log.debug("atomserver.servlet.context = " + servletContextName);
    WebAppContext webapp = new WebAppContext(atomserverHome + "/webapps/atomserver-" + version,
            "/" + servletContextName);

    // set the webapp's ClassLoader to be the one that loaded THIS class.  the REASON that
    // this needs to be set is so that when we extract the web application context below we can
    // cast it to WebApplicationContext here
    webapp.setClassLoader(StandAloneAtomServer.class.getClassLoader());

    // set the Jetty server's webapp and start it
    server.setHandler(webapp);
    server.start();

    // if the seed system property was set, use the DBSeeder to populate the server
    String seedDB = System.getProperty("seed.database.with.pets");
    log.debug("seed.database.with.pets = " + seedDB);
    if (!StringUtils.isEmpty(seedDB)) {
        if (Boolean.valueOf(seedDB)) {
            Thread.sleep(2000);

            WebApplicationContext webappContext = WebApplicationContextUtils
                    .getWebApplicationContext(webapp.getServletContext());

            DBSeeder.getInstance(webappContext).seedPets();
        }
    }

    server.join();
}

From source file:com.sm.test.TestClusterClient.java

public static void main(String[] args) throws Exception {
    String[] opts = new String[] { "-configPath", "-url", "-store", "-times", "-nio", "-size" };
    String[] defaults = new String[] { "", "localhost:7100", "store", "2", "true", "2000" };
    String[] paras = getOpts(args, opts, defaults);

    String configPath = paras[0];
    if (configPath.length() == 0) {
        //logger.error("missing config path or host");
        //throw new RuntimeException("missing -configPath or -host");
    }/*from w  w w. j ava 2 s . c o  m*/

    String url = paras[1];
    String store = paras[2];
    int times = Integer.valueOf(paras[3]);
    boolean nio = Boolean.valueOf(paras[4]);
    int size = Integer.valueOf(paras[5]);
    ClusterClientFactory ccf = ClusterClientFactory.connect(url, store, new HessianSerializer(),
            TCPClientFactory.ClientType.Netty);
    ClusterClient client = ccf.getDefaultStore(3000);
    TestClusterClient testClient = new TestClusterClient(client);
    client.put(Key.createKey("test-0"), "test-0");
    testClient.testMultiPut(500);
    testClient.testMultiGet(500);
    testClient.testScan(500);
    testClient.testScanCursor(500);
    Value v = client.get(Key.createKey("test-0"));
    System.out.println(v.getData());
    //ccf.reloadClusterClient();
    client.close();
    ccf.close();
}

From source file:squash.tools.FakeBookingCreator.java

public static void main(String[] args) throws IOException {
    int numberOfDays = 21;
    int numberOfCourts = 5;
    int maxCourtSpan = 5;
    int numberOfSlots = 16;
    int maxSlotSpan = 3;
    int minSurnameLength = 2;
    int maxSurnameLength = 20;
    int minBookingsPerDay = 0;
    int maxBookingsPerDay = 8;
    LocalDate startDate = LocalDate.of(2016, 7, 5);

    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
    List<Booking> bookings = new ArrayList<>();
    for (LocalDate date = startDate; date.isBefore(startDate.plusDays(numberOfDays)); date = date.plusDays(1)) {
        int numBookings = ThreadLocalRandom.current().nextInt(minBookingsPerDay, maxBookingsPerDay + 1);
        List<Booking> daysBookings = new ArrayList<>();
        for (int bookingIndex = 0; bookingIndex < numBookings; bookingIndex++) {
            String player1 = RandomStringUtils.randomAlphabetic(1) + "." + RandomStringUtils.randomAlphabetic(
                    ThreadLocalRandom.current().nextInt(minSurnameLength, maxSurnameLength + 1));
            String player2 = RandomStringUtils.randomAlphabetic(1) + "." + RandomStringUtils.randomAlphabetic(
                    ThreadLocalRandom.current().nextInt(minSurnameLength, maxSurnameLength + 1));

            Set<ImmutablePair<Integer, Integer>> bookedCourts = new HashSet<>();
            daysBookings.forEach((booking) -> {
                addBookingToSet(booking, bookedCourts);
            });//from  w w w .j  a v a2  s. c o m

            Booking booking;
            Set<ImmutablePair<Integer, Integer>> courtsToBook = new HashSet<>();
            do {
                // Loop until we create a booking of free courts
                int court = ThreadLocalRandom.current().nextInt(1, numberOfCourts + 1);
                int courtSpan = ThreadLocalRandom.current().nextInt(1,
                        Math.min(maxCourtSpan + 1, numberOfCourts - court + 2));
                int slot = ThreadLocalRandom.current().nextInt(1, numberOfSlots + 1);
                int slotSpan = ThreadLocalRandom.current().nextInt(1,
                        Math.min(maxSlotSpan + 1, numberOfSlots - slot + 2));
                booking = new Booking(court, courtSpan, slot, slotSpan, player1 + "/" + player2);
                booking.setDate(date.format(formatter));
                courtsToBook.clear();
                addBookingToSet(booking, courtsToBook);
            } while (Boolean.valueOf(Sets.intersection(courtsToBook, bookedCourts).size() > 0));

            daysBookings.add(booking);
        }
        bookings.addAll(daysBookings);
    }

    // Encode bookings as JSON
    // Create the node factory that gives us nodes.
    JsonNodeFactory factory = new JsonNodeFactory(false);
    // Create a json factory to write the treenode as json.
    JsonFactory jsonFactory = new JsonFactory();
    ObjectNode rootNode = factory.objectNode();

    ArrayNode bookingsNode = rootNode.putArray("bookings");
    for (int i = 0; i < bookings.size(); i++) {
        Booking booking = bookings.get(i);
        ObjectNode bookingNode = factory.objectNode();
        bookingNode.put("court", booking.getCourt());
        bookingNode.put("courtSpan", booking.getCourtSpan());
        bookingNode.put("slot", booking.getSlot());
        bookingNode.put("slotSpan", booking.getSlotSpan());
        bookingNode.put("name", booking.getName());
        bookingNode.put("date", booking.getDate());
        bookingsNode.add(bookingNode);
    }
    // Add empty booking rules array - just so restore works
    rootNode.putArray("bookingRules");
    rootNode.put("clearBeforeRestore", true);

    try (JsonGenerator generator = jsonFactory.createGenerator(new File("FakeBookings.json"),
            JsonEncoding.UTF8)) {
        ObjectMapper mapper = new ObjectMapper();
        mapper.setSerializationInclusion(Include.NON_EMPTY);
        mapper.setSerializationInclusion(Include.NON_NULL);
        mapper.writeTree(generator, rootNode);
    }
}