List of usage examples for java.lang Integer valueOf
@HotSpotIntrinsicCandidate public static Integer valueOf(int i)
From source file:Main.java
static Integer integerElement(Element row, String name) { final String s = stringElement(row, name); if (s == null || s.equals("")) { return null; } else {/*from w ww . jav a 2 s . com*/ return Integer.valueOf(s); } }
From source file:com.alibaba.jstorm.utils.SystemOperation.java
public static boolean isRoot() throws IOException { String result = SystemOperation.exec("echo $EUID").substring(0, 1); return Integer.valueOf(result.substring(0, result.length())).intValue() == 0 ? true : false; }
From source file:Main.java
/** * Retrieves PID from filename with format [PREFIX][PID].[EXTENSION] * @param filename - the file name to parse * @param prefix - the prefix of the filename up to the PID * @return - the PID portion of the filename as an Integer * @throws IOException If PID can not be parsed. *///from www . jav a 2 s.co m public static Integer parsePID(String filename, String prefix) throws IOException { String pidstr = filename.substring(prefix.length(), filename.lastIndexOf(DOT)); if (isNumber(pidstr)) { return Integer.valueOf(pidstr); } else { throw new IOException("Cannot parse PID from output file"); //$NON-NLS-1$ } }
From source file:SortByHouseNo.java
@Override public int compare(HouseNo o1, HouseNo o2) { Integer first = Integer.valueOf(o1.getHouseno()); Integer second = Integer.valueOf(o2.getHouseno()); Integer f1 = Integer.valueOf(o1.getBlockno()); Integer f2 = Integer.valueOf(o2.getBlockno()); if (first.compareTo(second) == 0) { return f1.compareTo(f2); }/* www .j a va 2 s .co m*/ return first.compareTo(second); }
From source file:Main.java
public static boolean isLowestLevel(int level) { if (mLevelSet == null) mLevelSet = mContext.getSharedPreferences(PREFER, Context.MODE_WORLD_READABLE).getStringSet(LEVELSET, null);/*from w w w.ja v a2s . co m*/ if (mLevelSet != null) { if (mLevelSet.size() < 5) // data is too few to judge lowest return false; ArrayList<String> array = Collections.list(Collections.enumeration(mLevelSet)); Collections.sort(array, mComparator); // TODO: may need check statistics to ensure the level is true lowest and not false alarm. if (level <= Integer.valueOf(array.get(0))) return true; } return false; }
From source file:com.twitter.heron.metricscachemgr.MetricsCacheManager.java
public static void main(String[] args) throws Exception { Options options = constructOptions(); Options helpOptions = constructHelpOptions(); CommandLineParser parser = new DefaultParser(); // parse the help options first. CommandLine cmd = parser.parse(helpOptions, args, true); if (cmd.hasOption("h")) { usage(options);/*from ww w.j av a 2 s . co m*/ return; } try { // Now parse the required options cmd = parser.parse(options, args); } catch (ParseException e) { usage(options); throw new RuntimeException("Error parsing command line options: ", e); } Level logLevel = Level.INFO; if (cmd.hasOption("v")) { logLevel = Level.ALL; } String cluster = cmd.getOptionValue("cluster"); String role = cmd.getOptionValue("role"); String environ = cmd.getOptionValue("environment"); int masterPort = Integer.valueOf(cmd.getOptionValue("master_port")); int statsPort = Integer.valueOf(cmd.getOptionValue("stats_port")); String systemConfigFilename = cmd.getOptionValue("system_config_file"); String overrideConfigFilename = cmd.getOptionValue("override_config_file"); String metricsSinksConfigFilename = cmd.getOptionValue("sink_config_file"); String topologyName = cmd.getOptionValue("topology_name"); String topologyId = cmd.getOptionValue("topology_id"); String metricsCacheMgrId = cmd.getOptionValue("metricscache_id"); // read heron internal config file SystemConfig systemConfig = SystemConfig.newBuilder(true).putAll(systemConfigFilename, true) .putAll(overrideConfigFilename, true).build(); // Log to file and sink(exception) LoggingHelper.loggerInit(logLevel, true); LoggingHelper.addLoggingHandler( LoggingHelper.getFileHandler(metricsCacheMgrId, systemConfig.getHeronLoggingDirectory(), true, systemConfig.getHeronLoggingMaximumSize(), systemConfig.getHeronLoggingMaximumFiles())); LoggingHelper.addLoggingHandler(new ErrorReportLoggingHandler()); LOG.info(String.format( "Starting MetricsCache for topology %s with topologyId %s with " + "MetricsCache Id %s, master port: %d.", topologyName, topologyId, metricsCacheMgrId, masterPort)); LOG.info("System Config: " + systemConfig); // read sink config file MetricsSinksConfig sinksConfig = new MetricsSinksConfig(metricsSinksConfigFilename); LOG.info("Sinks Config: " + sinksConfig.toString()); // build config from cli Config config = Config.toClusterMode(Config.newBuilder().putAll(ConfigLoader.loadClusterConfig()) .putAll(Config.newBuilder().put(Key.CLUSTER, cluster).put(Key.ROLE, role).put(Key.ENVIRON, environ) .build()) .putAll(Config.newBuilder().put(Key.TOPOLOGY_NAME, topologyName).put(Key.TOPOLOGY_ID, topologyId) .build()) .build()); LOG.info("Cli Config: " + config.toString()); // build metricsCache location TopologyMaster.MetricsCacheLocation metricsCacheLocation = TopologyMaster.MetricsCacheLocation.newBuilder() .setTopologyName(topologyName).setTopologyId(topologyId) .setHost(InetAddress.getLocalHost().getHostName()).setControllerPort(-1) // not used for metricscache .setMasterPort(masterPort).setStatsPort(statsPort).build(); MetricsCacheManager metricsCacheManager = new MetricsCacheManager(topologyName, METRICS_CACHE_HOST, masterPort, statsPort, systemConfig, sinksConfig, config, metricsCacheLocation); metricsCacheManager.start(); LOG.info("Loops terminated. MetricsCache Manager exits."); }
From source file:Main.java
@SuppressWarnings("checkstyle:magicnumber") private static Integer encodeColor(int red, int green, int blue, int alpha) { int col = (alpha & 0xFF) << 24; col |= (red & 0xFF) << 16; col |= (green & 0xFF) << 8; col |= blue & 0xFF;/*w w w .ja v a 2 s . co m*/ return Integer.valueOf(col); }
From source file:Main.java
public static int[] decodeMultiIntegerField(String field) throws NumberFormatException { StringTokenizer fieldTokens = new StringTokenizer(field, ";"); int[] result = new int[fieldTokens.countTokens()]; int counter = 0; while (fieldTokens.hasMoreTokens()) { String fieldToken = fieldTokens.nextToken(); result[counter++] = Integer.valueOf(fieldToken); }/*w ww .j a v a 2 s.co m*/ return result; }
From source file:com.hp.autonomy.hod.client.HodServiceConfigFactory.java
public static HodServiceConfig<EntityType.Application, TokenType.Simple> getHodServiceConfig( final TokenProxyService<EntityType.Application, TokenType.Simple> tokenProxyService, final Endpoint endpoint) { final HttpClientBuilder builder = HttpClientBuilder.create(); builder.disableCookieManagement();/*ww w. j a v a2 s . c om*/ builder.setDefaultSocketConfig(SocketConfig.custom().setSoTimeout(60000).build()); final String proxyHost = System.getProperty("hp.hod.https.proxyHost"); if (proxyHost != null) { final Integer proxyPort = Integer.valueOf(System.getProperty("hp.hod.https.proxyPort", "8080")); builder.setProxy(new HttpHost(proxyHost, proxyPort)); } final HodServiceConfig.Builder<EntityType.Application, TokenType.Simple> configBuilder = new HodServiceConfig.Builder<EntityType.Application, TokenType.Simple>( endpoint.getUrl()).setHttpClient(builder.build()); if (tokenProxyService != null) { configBuilder.setTokenProxyService(tokenProxyService); } return configBuilder.build(); }
From source file:Main.java
public static int getX(final Component component) { return component != null ? runInEDT(() -> Integer.valueOf(component.getX())).intValue() : 0; }