Example usage for java.lang Integer valueOf

List of usage examples for java.lang Integer valueOf

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static Integer valueOf(int i) 

Source Link

Document

Returns an Integer instance representing the specified int value.

Usage

From source file:org.eclipse.swt.snippets.Snippet327.java

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Snippet 327");
    shell.setLayout(new FillLayout());

    final Browser browser;
    try {/*from   w ww.j  a v a  2s  .  c om*/
        browser = new Browser(shell, SWT.NONE);
    } catch (SWTError e) {
        System.out.println("Could not instantiate Browser: " + e.getMessage());
        display.dispose();
        return;
    }
    browser.setText(createPage(0));
    browser.addLocationListener(LocationListener.changingAdapter(event -> {
        String location = event.location;
        int index = location.indexOf(PREAMBLE);
        if (index != -1) {
            int pageNumber = Integer.valueOf(location.substring(index + PREAMBLE.length())).intValue();
            browser.setText(createPage(pageNumber));
            event.doit = false;
        }
    }));

    shell.setBounds(10, 10, 200, 200);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    display.dispose();
}

From source file:com.example.bigtable.simpleperf.WritePerfTest.java

public static void main(String[] args) throws IOException, InterruptedException {
    Preconditions.checkArgument(args.length == 6,
            "Usage: [project id] [zone] [cluster id] [table] [row count] [value size]");
    writeTestData(args[0], args[1], args[2], TableName.valueOf(args[3]), Long.valueOf(args[4]),
            Integer.valueOf(args[5]));
}

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

public static void main(String[] args) throws Exception {
    String[] opts = new String[] { "-host", "-port", "-times" };
    String[] defaults = new String[] { "ssusd003.ir.dc", "6666", "500" };
    String[] paras = getOpts(args, opts, defaults);
    String host = paras[0];/*from   w  w w.j a  va  2 s  .c om*/
    int port = Integer.valueOf(paras[1]);
    int timeout = Integer.valueOf(paras[2]);

    //        logger.info("pos="+"/test/".indexOf("/"));
    //        logger.info("/test/".substring(0, "/test/".indexOf("/")));
    //        BuildClusterNodes bc = new BuildClusterNodes("./clusterStore/src/test/resources/config.xml");
    //        logger.info(bc.build().toString());
    //        BuildStoreConfig bs = new BuildStoreConfig("./clusterStore/src/test/resources/config.xml");
    //        logger.info(bs.build().toString());
    long begin = System.currentTimeMillis();
    SocketAddress inet = new InetSocketAddress(host, port);
    try {

        Socket socket = new Socket();
        socket.connect(inet, timeout);
        socket.close();
    } catch (Exception ex) {
        logger.error("ex " + ex.toString());
    }
    logger.info("time in Socket ms " + (System.currentTimeMillis() - begin));
    //        begin = System.currentTimeMillis();
    //        try {
    //            TCPClient client = TCPClient.start(host, port);
    //            client.close();
    //        } catch (Exception ex) {
    //            logger.error( ex.getMessage());
    //        }
    //        logger.info("time in TCPClient ms "+(System.currentTimeMillis() - begin));

}

From source file:com.sm.store.TestPhp.java

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

    String[] opts = new String[] { "-store", "-url", "-times" };
    String[] defaults = new String[] { "keystore", "localhost:7100", "10" };
    String[] paras = getOpts(args, opts, defaults);
    String store = paras[0];// www  . j  a  va2  s  . com
    String url = paras[1];
    int times = Integer.valueOf(paras[2]);
    RemoteClientImpl client = new NTRemoteClientImpl(url, null, store, false);
    //Value<byte[]> value = CacheValue.createValue(Utils.putInt(100000), 0, (short) 0);
    //client.put4Value(Key.createKey("key"), value);
    int startCrmId = client.getSeqNoInt(Key.createKey("key"));
    logger.info("key " + startCrmId);
    //        String filename = args[0];
    //        byte[] data = readFile( filename);
    //        HessianReader hr = new HessianReader(data);
    //        hr.readObject();
    //        System.out.println(new String( hr.getBytes()));
    //        HessianPhp hessianPhp = new HessianPhp(getNameMap());
    //        byte[] d1 = hessianPhp.php2Hessian( data);
    //        System.out.println("size "+d1.length+ " "+ new String(d1));
}

From source file:name.wagners.fssp.Main.java

/**
 * @param args//from  ww w  .  jav  a 2  s .co m
 *            command-line arguments
 */
public static void main(final String[] args) {
    // create the command line parser
    CommandLineParser parser = new PosixParser();

    // create the Options
    Options options = new Options();

    options.addOption(OptionBuilder.hasArg().withArgName("gn").withLongOpt("generations")
            .withDescription("Number of generations [default: 50]").withType(Integer.valueOf(0)).create("g"));

    options.addOption(OptionBuilder.hasArg().withArgName("mp").withLongOpt("mutation")
            .withDescription("Mutation propability [default: 0.5]").withType(Double.valueOf(0)).create("m"));

    options.addOption(OptionBuilder.hasArg().withArgName("ps").withLongOpt("populationsize")
            .withDescription("Size of population [default: 20]").withType(Integer.valueOf(0)).create("p"));

    options.addOption(OptionBuilder.hasArg().withArgName("rp").withLongOpt("recombination")
            .withDescription("Recombination propability [default: 0.8]").withType(Double.valueOf(0))
            .create("r"));

    options.addOption(OptionBuilder.hasArg().withArgName("sp").withLongOpt("selectionpressure")
            .withDescription("Selection pressure [default: 4]").withType(Integer.valueOf(0)).create("s"));

    options.addOption(OptionBuilder.withLongOpt("help").withDescription("print this message").create("h"));

    options.addOption(OptionBuilder.hasArg().withArgName("filename").isRequired().withLongOpt("file")
            .withDescription("Problem file [default: \"\"]").withType(String.valueOf("")).create("f"));

    options.addOptionGroup(new OptionGroup()
            .addOption(OptionBuilder.withLongOpt("verbose").withDescription("be extra verbose").create("v"))
            .addOption(OptionBuilder.withLongOpt("quiet").withDescription("be extra quiet").create("q")));

    options.addOption(OptionBuilder.withLongOpt("version")
            .withDescription("print the version information and exit").create("V"));

    try {
        // parse the command line arguments
        CommandLine line = parser.parse(options, args);

        // validate that block-size has been set
        if (line.hasOption("h")) {
            // automatically generate the help statement
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("fssp", options);
        }

    } catch (MissingOptionException exp) {
        log.info("An option was missing:" + exp.getMessage(), exp);

        // automatically generate the help statement
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("fssp", options);
    } catch (MissingArgumentException exp) {
        log.info("An argument was missing:" + exp.getMessage(), exp);

        // automatically generate the help statement
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("fssp", options);
    } catch (AlreadySelectedException exp) {
        // automatically generate the help statement
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("fssp", options);
    } catch (ParseException exp) {
        log.info("Unexpected exception:" + exp.getMessage(), exp);

        // automatically generate the help statement
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("fssp", options);

        System.exit(1);
    }

    // Ausgabe der eingestellten Optionen

    log.info("Configuration");
    // log.info(" Datafile: {}", fname);
}

From source file:Adder.java

public static void main(String[] args) {
    int numArgs = args.length;

    //this program requires at least two arguments on the command line
    if (numArgs < 2) {
        System.out.println("This program requires two command-line arguments.");
    } else {/*ww  w  .j ava  2  s . c  o m*/
        int sum = 0;

        for (int i = 0; i < numArgs; i++) {
            sum += Integer.valueOf(args[i]).intValue();
        }

        //print the sum
        System.out.println(sum);
    }
}

From source file:org.huahinframework.emanager.Runner.java

/**
 * @param args//from   ww  w . java2 s.  c om
 */
public static void main(String[] args) {
    if (args.length != 4) {
        System.err.println("argument error: [start | stop] [war path] [port] [shutdown port]");
        System.exit(-1);
    }

    String operation = args[0];
    String war = args[1];
    int port = Integer.valueOf(args[2]);
    int shutDownPort = Integer.valueOf(args[3]);

    Runner runner = new Runner();
    if (operation.equals(OPERATION_START)) {
        runner.start(war, port, shutDownPort);
    } else if (operation.equals(OPERATION_STOP)) {
        runner.stop(shutDownPort);
    }

    System.exit(0);
}

From source file:com.navercorp.client.Main.java

public static void main(String[] args) {
    Client clnt = null;/*www  . ja  va  2  s  .com*/
    try {
        CommandLine cmd = new DefaultParser()
                .parse(new Options().addOption("z", true, "zookeeper address (ip:port,ip:port,...)")
                        .addOption("t", true, "zookeeper connection timeout")
                        .addOption("c", true, "command and arguments"), args);

        final String connectionString = cmd.hasOption("z") ? cmd.getOptionValue("z") : "127.0.0.1:2181";
        final int timeout = cmd.hasOption("t") ? Integer.valueOf(cmd.getOptionValue("t")) : 10000;
        clnt = new Client(connectionString, timeout);

        String command;
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        while ((command = in.readLine()) != null) {
            printResult(clnt.execute(command.split(" ")));
        }
        System.exit(Code.OK.n());
    } catch (ParseException e) {
        e.printStackTrace(System.err);
        System.err.println(Client.getUsage());
        System.exit(INVALID_ARGUMENT.n());
    } catch (IOException e) {
        e.printStackTrace(System.err);
        System.exit(ZK_CONNECTION_LOSS.n());
    } catch (InterruptedException e) {
        e.printStackTrace(System.err);
        System.exit(INTERNAL_ERROR.n());
    } finally {
        if (clnt != null) {
            try {
                clnt.close();
            } catch (Exception e) {
                ; // nothing to do
            }
        }
    }
}

From source file:com.sm.replica.DefaultReplicaServer.java

public static void main(String[] args) {
    String[] opts = new String[] { "-store", "-path", "-port", "-mode", "index" };
    String[] defaults = new String[] { "replica", "./data", "7120", "0", "0" };
    String[] paras = getOpts(args, opts, defaults);
    String store = paras[0];/*  w w w  .  j ava  2 s  .co  m*/
    int port = Integer.valueOf(paras[2]);
    String path = paras[1];
    int mode = Integer.valueOf(paras[3]);
    int index = Integer.valueOf(paras[4]);
    CacheStore cacheStore = new CacheStore(path, null, mode);
    LogChannel logChannel = new LogChannel(store, 0, path);
    DefaultReplicaServer defaultReplicaServer = new DefaultReplicaServer(logChannel, index, store, path);
    HashMap<String, CacheStore> storesMap = new HashMap<String, CacheStore>();
    storesMap.put(store, cacheStore);
    UnisonServerHandler unisonServerHandler = new UnisonServerHandler(defaultReplicaServer);
    logger.info("start server at " + port);
    ReplicaServer server = new ReplicaServer(port, storesMap, unisonServerHandler);
    defaultReplicaServer.hookShutdown();
}

From source file:CubaHSQLDBServer.java

public static void main(final String[] args) {
    final boolean validInit = args.length > 2;
    SwingUtilities.invokeLater(new Runnable() {
        @Override//from   w  ww .j av a  2s  .com
        public void run() {
            final CubaHSQLDBServer monitor = new CubaHSQLDBServer();
            monitor.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            monitor.setLocationRelativeTo(null);
            monitor.setVisible(true);

            if (validInit) {
                Integer dbPort = Integer.valueOf(args[0]);
                String dbPath = args[1];
                String dbName = args[2];
                final HSQLServer server = monitor.startServer(dbPort, dbPath, dbName);
                if (server != null) {
                    monitor.addWindowListener(new WindowAdapter() {
                        @Override
                        public void windowClosing(WindowEvent e) {
                            try {
                                server.shutdownCatalogs(2 /* NORMAL CLOSE MODE */);
                            } catch (RuntimeException exception) {
                                // Ignore exceptions from server.
                            }
                        }
                    });
                }
            } else {
                String argStr = StringUtils.join(args, ' ');
                monitor.setStatus(String.format(
                        "Invalid usage (args: '%s')\nExpected arguments: <port> <dbPath> <dbName>", argStr));
            }
        }
    });
}