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:converters.StringToVoteConverter.java

@Override
public Vote convert(String key) {
    Assert.hasText(key);//from   w w w  . ja  v a  2 s  .c o m

    Vote result;
    int id;

    id = Integer.valueOf(key);
    result = voteRepository.findOne(id);
    Assert.notNull(result);

    return result;
}

From source file:com.taobao.datax.engine.tools.JobConfGenDriver.java

private static int showChoice(String header, List<String> plugins) {
    System.out.println(header);/*from  www  .  j av a  2s .c  o m*/

    int idx = 0;
    for (String plugin : plugins) {
        System.out.println(String.format("%d\t%s", idx++,
                plugin.toLowerCase().replace("reader", "").replace("writer", "")));
    }

    System.out.print(String.format("Please choose [%d-%d]: ", 0, plugins.size() - 1));

    try {
        idx = Integer.valueOf(new Scanner(System.in).nextLine());
    } catch (Exception e) {
        // TODO: handle exception
        idx = -1;
    }

    return idx;
}

From source file:com.marc.lastweek.extractionengine.adapters.EbayAdAdapter.java

public final static NewExternalClassifiedAdTO adapt(EbayAd ebayAd) {
    long categoryId = EBAY_PISOS_CATEGORIES_TO_LASTWEEK_CATEGORIES[ArrayUtils.indexOf(EBAY_PISOS_CATEGORIES,
            ebayAd.getCategory().trim())];
    Double price = null;/*w  w  w.j  a v  a  2  s  .  c o  m*/
    try {
        price = Double.valueOf(ebayAd.getPrice().replaceFirst("EUR", ""));
    } catch (Exception e) {
        price = Double.valueOf(0);
    }

    Long provinceId = Long.valueOf(1);

    return new NewExternalClassifiedAdTO(Long.valueOf(categoryId), null, price, ebayAd.getTitle(),
            ebayAd.getDescription(), null, null, provinceId, Integer.valueOf(ClassifiedAd.SOURCE_EBAY),
            ebayAd.getUrl(), Integer.valueOf(0), Integer.valueOf(ClassifiedAd.STATE_ACTIVE));
}

From source file:io.proscript.jlight.Runtime.java

public static void run(CommandLine line) throws IOException {

    Environment environment = new Environment();

    if (1 == line.getArgList().size()) {
        File cwdCandidate = new File(line.getArgList().get(0));
        if (cwdCandidate.isDirectory()) {
            environment.setCwd(cwdCandidate);
        } else {// w w  w  .  jav  a 2 s .c o m
            throw new IOException("Last argument must be valid source root directory");
        }
    } else {
        environment.setCwd(new File(System.getProperty("user.dir")));
    }

    if (line.hasOption("port")) {
        environment.setPort(Integer.valueOf(line.getOptionValue("port")));
    }

    if (line.hasOption("host")) {
        environment.setHost(line.getOptionValue("host"));
    }

    environment.setCacheDirectory(new File(environment.getCwd().toString() + "/.jlcache"));
    environment.setMainClassName(line.getOptionValue("class"));

    CacheManager cacheManager = new CacheManager(environment);

    try {
        cacheManager.initialize();
    } catch (IOException e) {
        log.log(Level.SEVERE, "Failed to initialize class file cache: %s", e.getMessage());
        return;
    }

    Collection<File> javaFiles = SourcesLocator.locateRecursive(environment.getCwd());

    ApplicationCompiler compiler = new ApplicationCompiler(environment.getCacheDirectory());

    boolean result = false;

    try {
        result = compiler.compile(javaFiles);
    } catch (IOException e) {
        log.log(Level.SEVERE, "Compilation failed: %s", e.getMessage());
        return;
    }

    if (!result) {
        for (Diagnostic diagnostic : compiler.getLastDiagnosticCollector().getDiagnostics()) {
            System.out.println(diagnostic.getMessage(Locale.getDefault()));
            LogRecord record = new LogRecord(Level.SEVERE, diagnostic.getMessage(Locale.getDefault()));
            log.log(record);
        }
    } else {

        Application application = buildApplication(environment);
        ThreadedHTTPServer server = new ThreadedHTTPServer(environment);
        server.run(application);
    }

    try {
        cacheManager.destroy();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static int getArg(final NodeList args, final String strName, final int iDefaultValue) {
    final String strValue = getArg(args, strName, null);

    if (strValue == null) {
        return iDefaultValue;
    }//from   w  ww  .j  a v a  2  s . c o m

    return Integer.valueOf(strValue);
}

From source file:converters.StringToVotationConverter.java

@Override
public Votation convert(String key) {
    Assert.hasText(key);/*from   w  w w .j av a2s  .c  om*/

    Votation result;
    int id;

    id = Integer.valueOf(key);
    result = votationRepository.findOne(id);
    Assert.notNull(result);

    return result;
}

From source file:ch.rasc.s4ws.snake.SnakeTimer.java

protected static synchronized void removeSnake(Snake snake) {
    snakes.remove(Integer.valueOf(snake.getId()));
    if (snakes.size() == 0) {
        stopTimer();// w  w w . j  a  v  a 2 s.  c om
    }
}

From source file:com.smi.travel.monitor.BookingFlightComparator.java

@Override
public int compare(BookingFlight f1, BookingFlight f2) {
    int compareDate = f1.getDepartureDate().compareTo(f2.getDepartureDate());
    if (compareDate != 0) {
        return compareDate;
    } else {/*from   w  ww .j ava 2  s  .com*/
        int departTime1;
        int departTime2;
        if (StringUtils.isEmpty(f1.getDepartTime())) {
            departTime1 = 0;
        } else {
            departTime1 = Integer.valueOf(f1.getDepartTime().trim());
        }
        if (StringUtils.isEmpty(f2.getDepartTime())) {
            departTime2 = 0;
        } else {
            departTime2 = Integer.valueOf(f2.getDepartTime().trim());
        }

        return Integer.compare(departTime1, departTime2);
    }
}

From source file:com.gmind7.bakery.websocket.SnakeTimer.java

public static synchronized void removeSnake(Snake snake) {
    snakes.remove(Integer.valueOf(snake.getId()));
    if (snakes.size() == 0) {
        stopTimer();//from  ww w.  j a v a2s .c  om
    }
}

From source file:ai.grakn.migration.json.Main.java

public static void runJson(MigrationCLI cli) {
    String jsonDataFileName = cli.getRequiredOption("input", "Data file missing (-i)");
    String jsonTemplateName = cli.getRequiredOption("template", "Template file missing (-t)");
    int batchSize = cli.hasOption("b") ? Integer.valueOf(cli.getOption("b")) : JsonMigrator.BATCH_SIZE;

    // get files/*from ww w  .j a v  a2  s .  c  o  m*/
    File jsonDataFile = new File(jsonDataFileName);
    File jsonTemplateFile = new File(jsonTemplateName);

    if (!jsonDataFile.exists()) {
        cli.die("Cannot find file: " + jsonDataFileName);
    }

    if (!jsonTemplateFile.exists() || jsonTemplateFile.isDirectory()) {
        cli.die("Cannot find file: " + jsonTemplateName);
    }

    cli.printInitMessage(jsonDataFile.getPath());

    String template = cli.fileAsString(jsonTemplateFile);
    try (JsonMigrator jsonMigrator = new JsonMigrator(template, jsonDataFile)) {

        if (cli.hasOption("n")) {
            cli.writeToSout(jsonMigrator.migrate());
        } else {
            MigrationLoader.load(cli.getLoader(), batchSize, jsonMigrator);
            cli.printWholeCompletionMessage();
        }
    } catch (Throwable throwable) {
        cli.die(throwable);
    }

    cli.initiateShutdown();
}