@NotNull private static Optional<Integer> releaseToMajor(@NotNull Release release) { Optional<Integer> major; try { major = Optional.of(Integer.parseUnsignedInt(release.major)); } catch (NumberFormatException numberFormatException) { major = Optional.empty(); } return major; }
@Override public Object getKeyMapping(String value) { int index = Integer.parseUnsignedInt(value.substring(0, this.padding), HEX_RADIX); KeyFormat<Object> keyFormat = this.keyFormats.get(index); return keyFormat.parse(value.substring(this.padding)); } }
@NotNull private static Optional<Integer> releaseToMinor(@NotNull Release release) { Optional<Integer> minor; @Nullable String releaseMinor = release.minor; if (releaseMinor != null) { try { minor = Optional.of(Integer.parseUnsignedInt(release.minor)); } catch (NumberFormatException numberFormatException) { minor = Optional.empty(); } } else { minor = Optional.empty(); } return minor; } }
private static String validateHostName(String serviceName, String[] serviceInfos, String hostname) { String[] parts = hostname.split(":"); if (parts.length >= 3) { throw new IllegalArgumentException("Invalid hostname : " + hostname); } else if (parts.length == 2) { try { Integer.parseUnsignedInt(parts[1]); } catch (NumberFormatException nfe) { throw new IllegalArgumentException("Invalid hostname : " + hostname); } return hostname; } else if (parts.length == 1) { return hostname + ":" + getServicePort(serviceName, serviceInfos); } else { return hostname; } }
/** * Parses this {@code CharSeq} as a unsigned decimal int by calling {@link Integer#parseUnsignedInt(String)}. * <p> * We write * * <pre><code> * int value = charSeq.parseUnsignedInt(); * </code></pre> * * instead of * * <pre><code> * int value = Integer.parseUnsignedInt(charSeq.mkString()); * </code></pre> * * @return the unsigned int value represented by this {@code CharSeq} in decimal * @throws NumberFormatException If this {@code CharSeq} does not contain a parsable unsigned int. */ @GwtIncompatible public int parseUnsignedInt() { return Integer.parseUnsignedInt(back); }
/** * Parses this {@code CharSeq} as a unsigned int in the specified radix * by calling {@link Integer#parseUnsignedInt(String, int)}. * <p> * We write * * <pre><code> * int value = charSeq.parseUnsignedInt(radix); * </code></pre> * * instead of * * <pre><code> * int value = Integer.parseUnsignedInt(charSeq.mkString(), radix); * </code></pre> * * @param radix the radix to be used in interpreting this {@code CharSeq} * @return the unsigned int value represented by this {@code CharSeq} in the specified radix * @throws NumberFormatException If this {@code CharSeq} does not contain a parsable unsigned int. */ @GwtIncompatible public int parseUnsignedInt(int radix) { return Integer.parseUnsignedInt(back, radix); }
result = Integer.parseUnsignedInt(txt, radix);
lineno = Integer.parseUnsignedInt(lnum); } catch (NumberFormatException e) { lineno = 0;
final int targetNumShardsPerGranularity = Integer.parseUnsignedInt( tableProperties.getProperty(Constants.DRUID_TARGET_SHARDS_PER_GRANULARITY, "0")); final int maxPartitionSize = targetNumShardsPerGranularity > 0 ? -1 : HiveConf
/** * Converts a positive value into an {@code int}. * * @param value * to convert * @return the value, or -1 if it wasn't a positive integral value */ public static int positive(String value) { if (value != null) { try { return Integer.parseUnsignedInt(value); } catch (NumberFormatException e) { // Ignore } } return -1; }
int uint = Integer.parseUnsignedInt("4294967295"); System.out.println(Integer.toUnsignedString(uint));
/** * Retrieves the JDA instance represented by the provided shard ID * or {@code null} if none of the connected shards match the provided id. * * @param id * The ID of the shard * * @throws java.lang.NumberFormatException * If the provided String is {@code null} or * cannot be resolved to an unsigned int id * * @return Possibly-null entity for the specified shard ID */ default JDA getElementById(String id) { return getElementById(Integer.parseUnsignedInt(id)); } }
long l = Integer.toUnsignedLong(uint); System.out.println(l); // will print 4294967295 int x = Integer.parseUnsignedInt("4294967295"); int y = 5; int cmp1 = Integer.compareUnsigned(x,y); // interprets x as 4294967295 (x>y) int cmp2 = Integer.compare(x,y); // interprets x as -1 (x<y)
@Override public Integer get() { String rawValue = SystemReader.getInstance() .getProperty(MAX_REDIRECT_SYSTEM_PROPERTY); Integer value = Integer.valueOf(DEFAULT_MAX_REDIRECTS); if (rawValue != null) { try { value = Integer.valueOf(Integer.parseUnsignedInt(rawValue)); } catch (NumberFormatException e) { LOG.warn(MessageFormat.format( JGitText.get().invalidSystemProperty, MAX_REDIRECT_SYSTEM_PROPERTY, rawValue, value)); } } return value; } }).get().intValue();
@Override public AppenderSkeleton apply(MonitorLocation loc) { int defaultPort = Integer.parseUnsignedInt(Property.MONITOR_LOG4J_PORT.getDefaultValue()); HostAndPort remote = HostAndPort.fromString(loc.getLocation()); SocketAppender socketAppender = new SocketAppender(); socketAppender.setApplication(System.getProperty("accumulo.application", "unknown")); socketAppender.setRemoteHost(remote.getHost()); socketAppender.setPort(remote.getPortOrDefault(defaultPort)); return socketAppender; } }
try { String guessText = JOptionPane.showInputDialog("Enter your next guess"); int guess = Integer.parseUnsignedInt(guessText); } catch (NumberFormatException ex) { ... }
private static int getPoolSize(String systemProperty, int defaultSize) { String value = System.getProperty(systemProperty); if (value != null) { try { return Integer.parseUnsignedInt(value); } catch (NumberFormatException e) { // will return the default } } return defaultSize; } }
public static void main(String[] args) { SubnetTree tree = new SubnetTree(); tree.add(Integer.parseUnsignedInt("01100110000000000000000000000000", 2), 8); System.out.println("true: " + tree.isInRange(Integer.parseUnsignedInt("01100110000000000000100010000101", 2))); System.out.println("false: " + tree.isInRange(Integer.parseUnsignedInt("01101110000000000000100010000101", 2))); tree.add(Integer.parseUnsignedInt("01001110000000000000000000000000", 2), 6); System.out.println("true: " + tree.isInRange(Integer.parseUnsignedInt("01100110000000000000100010000101", 2))); System.out.println("false: " + tree.isInRange(Integer.parseUnsignedInt("01101110000000000000100010000101", 2))); System.out.println("true: " + tree.isInRange(Integer.parseUnsignedInt("01001110100000000000000000000000", 2))); System.out.println("true: " + tree.isInRange(Integer.parseUnsignedInt("01001100100000000000000000111111", 2))); }
private static Id tryParseScheduleId(String s) { try { return Id.of(Integer.toString(Integer.parseUnsignedInt(s))); } catch (NumberFormatException ignore) { return null; } }
private static Function<String, Integer> parseInt( Repetition repetition ) { return in -> { int result = parseUnsignedInt( in ); return (result < repetition.minTimes() || (repetition.limited() && result > repetition.maxTimes())) ? null : result; }; }