List of usage examples for java.lang Integer valueOf
@HotSpotIntrinsicCandidate public static Integer valueOf(int i)
From source file:de.citec.csra.allocation.vis.MovingChart.java
/** * Starting point for the dynamic graph application. * * @param args ignored./*w w w . ja v a 2s . c om*/ */ public static void main(final String[] args) throws InterruptedException, RSBException { int past = DEFAULT_PAST; int future = DEFAULT_FUTURE; if (args.length > 0) { if (args.length == 2) { try { past = Integer.valueOf(args[0]); future = Integer.valueOf(args[1]); } catch (IllegalArgumentException ex) { System.err.println( "Could not read integer values for PAST or FUTURE.\nusage: csra-allocation-viewer [PAST FUTURE]"); System.exit(1); } } else { System.err.println("usage: csra-allocation-viewer [PAST FUTURE]"); System.exit(1); } } final MovingChart demo = new MovingChart("Resource Allocation Chart", past, future); Listener l = Factory.getInstance().createListener(AllocationServer.getScope()); l.addHandler(demo, true); demo.pack(); RefineryUtilities.centerFrameOnScreen(demo); l.activate(); demo.setVisible(true); }
From source file:Main.java
public static float getY(MotionEvent event, int index) { float value;/*from w w w . j a va 2 s . c o m*/ try { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ECLAIR) { if (index == 0) { value = event.getX(); } else { value = 0; } } else { value = ((Float) (event.getClass().getMethod("getY", new Class[] { int.class }).invoke(event, new Object[] { Integer.valueOf(index) }))).floatValue(); } } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (SecurityException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } return value; }
From source file:act.installer.HMDBParser.java
public static void main(String[] args) throws Exception { // Parse the command line options Options opts = new Options(); for (Option.Builder b : OPTION_BUILDERS) { opts.addOption(b.build());// w ww . j a v a 2 s .c o m } CommandLine cl = null; try { CommandLineParser parser = new DefaultParser(); cl = parser.parse(opts, args); } catch (ParseException e) { System.err.format("Argument parsing failed: %s\n", e.getMessage()); HELP_FORMATTER.printHelp(PubchemParser.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); System.exit(1); } if (cl.hasOption("help")) { HELP_FORMATTER.printHelp(PubchemParser.class.getCanonicalName(), HELP_MESSAGE, opts, null, true); return; } File inputDir = new File(cl.getOptionValue(OPTION_INPUT_DIRECTORY)); if (!inputDir.isDirectory()) { System.err.format("Input directory at %s is not a directory\n", inputDir.getAbsolutePath()); System.exit(1); } String dbName = cl.getOptionValue(OPTION_DB_NAME, DEFAULT_DB_NAME); String dbHost = cl.getOptionValue(OPTION_DB_HOST, DEFAULT_DB_HOST); Integer dbPort = Integer.valueOf(cl.getOptionValue(OPTION_DB_PORT, DEFAULT_DB_PORT)); LOGGER.info("Connecting to %s:%d/%s", dbHost, dbPort, dbName); MongoDB db = new MongoDB(dbHost, dbPort, dbName); HMDBParser parser = Factory.makeParser(db); LOGGER.info("Starting parser"); parser.run(inputDir); LOGGER.info("Done"); }
From source file:Main.java
public static Object getObject(String type, String value) throws Exception { type = type.toLowerCase();//from w w w .jav a 2 s . c o m if ("boolean".equals(type)) return Boolean.valueOf(value); if ("byte".equals(type)) return Byte.valueOf(value); if ("short".equals(type)) return Short.valueOf(value); if ("char".equals(type)) if (value.length() != 1) throw new NumberFormatException("Argument is not a character!"); else return Character.valueOf(value.toCharArray()[0]); if ("int".equals(type)) return Integer.valueOf(value); if ("long".equals(type)) return Long.valueOf(value); if ("float".equals(type)) return Float.valueOf(value); if ("double".equals(type)) return Double.valueOf(value); if ("string".equals(type)) return value; else { Object objs[] = new String[] { value }; return Class.forName(type).getConstructor(new Class[] { java.lang.String.class }).newInstance(objs); } }
From source file:Main.java
private static int xpathIndex(String expr) { try {/*w ww .j av a 2s .c om*/ return Integer.valueOf(expr); } catch (Exception ignored) { } return -1; }
From source file:Main.java
public static Pair<Integer, Integer> getScreenDimensions(Context paramContext) { WindowManager localWindowManager = (WindowManager) paramContext.getSystemService("window"); DisplayMetrics localDisplayMetrics = new DisplayMetrics(); localWindowManager.getDefaultDisplay().getMetrics(localDisplayMetrics); int i = Math.min(localDisplayMetrics.widthPixels, localDisplayMetrics.heightPixels); int j = Math.max(localDisplayMetrics.widthPixels, localDisplayMetrics.heightPixels); return new Pair(Integer.valueOf(i), Integer.valueOf(j)); }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T> T getJsonObjectValue(JSONObject jsonObject, String key, Class<T> clazz) { T t = null;//from www . j av a2 s.c o m try { if (clazz == Integer.class) { t = (T) Integer.valueOf(jsonObject.getInt(key)); } else if (clazz == Boolean.class) { t = (T) Boolean.valueOf(jsonObject.getBoolean(key)); } else if (clazz == String.class) { t = (T) String.valueOf(jsonObject.getString(key)); } else if (clazz == Double.class) { t = (T) Double.valueOf(jsonObject.getDouble(key)); } else if (clazz == JSONObject.class) { t = (T) jsonObject.getJSONObject(key); } else if (clazz == JSONArray.class) { t = (T) jsonObject.getJSONArray(key); } else if (clazz == Long.class) { t = (T) Long.valueOf(jsonObject.getLong(key)); } } catch (JSONException e) { e.printStackTrace(); } return t; }
From source file:com.rapleaf.hank.hadoop.HadoopDomainCompactor.java
public static void main(String[] args) throws IOException, InvalidConfigurationException { CommandLineChecker.check(args, new String[] { "domain name", "version to compact number", "mapred.task.timeout", "config path", "jobjar" }, HadoopDomainCompactor.class); String domainName = args[0];//from ww w .j a v a 2 s . co m Integer versionToCompactNumber = Integer.valueOf(args[1]); Integer mapredTaskTimeout = Integer.valueOf(args[2]); CoordinatorConfigurator configurator = new YamlClientConfigurator(args[3]); String jobJar = args[4]; DomainCompactorProperties properties = new DomainCompactorProperties(domainName, versionToCompactNumber, configurator); JobConf conf = new JobConf(); conf.setJar(jobJar); conf.set("mapred.task.timeout", mapredTaskTimeout.toString()); conf.setJobName(HadoopDomainCompactor.class.getSimpleName() + " Domain " + domainName + ", Version " + versionToCompactNumber); HadoopDomainCompactor compactor = new HadoopDomainCompactor(conf); LOG.info("Compacting Hank domain " + domainName + " version " + versionToCompactNumber + " with coordinator configuration " + configurator); compactor.buildHankDomain(properties, new IncrementalDomainVersionProperties.Base("Version " + versionToCompactNumber + " compacted")); }
From source file:Main.java
/** * box the int to Integer */ public static Integer boxed(int v) { return Integer.valueOf(v); }
From source file:Main.java
public static Integer stringToInteger(String str) { if (str == null) { return null; } else {// w ww. ja v a 2 s.co m try { return Integer.parseInt(str); } catch (NumberFormatException e) { try { Double d = Double.valueOf(str); if (d.doubleValue() > mMaxInt.doubleValue() + 1.0) { Log.w(TAG, "Value " + d + " too large for integer"); return null; } return Integer.valueOf(d.intValue()); } catch (NumberFormatException nfe2) { Log.w(TAG, "Unable to interpret value " + str + " in field being " + "converted to int, caught NumberFormatException <" + e.getMessage() + "> field discarded"); return null; } } } }