java.lang.Integer.parseUnsignedInt()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(623)

本文整理了Java中java.lang.Integer.parseUnsignedInt()方法的一些代码示例,展示了Integer.parseUnsignedInt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Integer.parseUnsignedInt()方法的具体详情如下:
包路径:java.lang.Integer
类名称:Integer
方法名:parseUnsignedInt

Integer.parseUnsignedInt介绍

暂无

代码示例

代码示例来源:origin: KronicDeth/intellij-elixir

  1. @NotNull
  2. private static Optional<Integer> releaseToMajor(@NotNull Release release) {
  3. Optional<Integer> major;
  4. try {
  5. major = Optional.of(Integer.parseUnsignedInt(release.major));
  6. } catch (NumberFormatException numberFormatException) {
  7. major = Optional.empty();
  8. }
  9. return major;
  10. }

代码示例来源:origin: wildfly/wildfly

  1. @Override
  2. public Object getKeyMapping(String value) {
  3. int index = Integer.parseUnsignedInt(value.substring(0, this.padding), HEX_RADIX);
  4. KeyFormat<Object> keyFormat = this.keyFormats.get(index);
  5. return keyFormat.parse(value.substring(this.padding));
  6. }
  7. }

代码示例来源:origin: KronicDeth/intellij-elixir

  1. @NotNull
  2. private static Optional<Integer> releaseToMinor(@NotNull Release release) {
  3. Optional<Integer> minor;
  4. @Nullable String releaseMinor = release.minor;
  5. if (releaseMinor != null) {
  6. try {
  7. minor = Optional.of(Integer.parseUnsignedInt(release.minor));
  8. } catch (NumberFormatException numberFormatException) {
  9. minor = Optional.empty();
  10. }
  11. } else {
  12. minor = Optional.empty();
  13. }
  14. return minor;
  15. }
  16. }

代码示例来源:origin: apache/pulsar

  1. private static String validateHostName(String serviceName,
  2. String[] serviceInfos,
  3. String hostname) {
  4. String[] parts = hostname.split(":");
  5. if (parts.length >= 3) {
  6. throw new IllegalArgumentException("Invalid hostname : " + hostname);
  7. } else if (parts.length == 2) {
  8. try {
  9. Integer.parseUnsignedInt(parts[1]);
  10. } catch (NumberFormatException nfe) {
  11. throw new IllegalArgumentException("Invalid hostname : " + hostname);
  12. }
  13. return hostname;
  14. } else if (parts.length == 1) {
  15. return hostname + ":" + getServicePort(serviceName, serviceInfos);
  16. } else {
  17. return hostname;
  18. }
  19. }

代码示例来源:origin: vavr-io/vavr

  1. /**
  2. * Parses this {@code CharSeq} as a unsigned decimal int by calling {@link Integer#parseUnsignedInt(String)}.
  3. * <p>
  4. * We write
  5. *
  6. * <pre><code>
  7. * int value = charSeq.parseUnsignedInt();
  8. * </code></pre>
  9. *
  10. * instead of
  11. *
  12. * <pre><code>
  13. * int value = Integer.parseUnsignedInt(charSeq.mkString());
  14. * </code></pre>
  15. *
  16. * @return the unsigned int value represented by this {@code CharSeq} in decimal
  17. * @throws NumberFormatException If this {@code CharSeq} does not contain a parsable unsigned int.
  18. */
  19. @GwtIncompatible
  20. public int parseUnsignedInt() {
  21. return Integer.parseUnsignedInt(back);
  22. }

代码示例来源:origin: vavr-io/vavr

  1. /**
  2. * Parses this {@code CharSeq} as a unsigned int in the specified radix
  3. * by calling {@link Integer#parseUnsignedInt(String, int)}.
  4. * <p>
  5. * We write
  6. *
  7. * <pre><code>
  8. * int value = charSeq.parseUnsignedInt(radix);
  9. * </code></pre>
  10. *
  11. * instead of
  12. *
  13. * <pre><code>
  14. * int value = Integer.parseUnsignedInt(charSeq.mkString(), radix);
  15. * </code></pre>
  16. *
  17. * @param radix the radix to be used in interpreting this {@code CharSeq}
  18. * @return the unsigned int value represented by this {@code CharSeq} in the specified radix
  19. * @throws NumberFormatException If this {@code CharSeq} does not contain a parsable unsigned int.
  20. */
  21. @GwtIncompatible
  22. public int parseUnsignedInt(int radix) {
  23. return Integer.parseUnsignedInt(back, radix);
  24. }

代码示例来源:origin: checkstyle/checkstyle

  1. result = Integer.parseUnsignedInt(txt, radix);

代码示例来源:origin: oracle/opengrok

  1. lineno = Integer.parseUnsignedInt(lnum);
  2. } catch (NumberFormatException e) {
  3. lineno = 0;

代码示例来源:origin: apache/hive

  1. final int targetNumShardsPerGranularity = Integer.parseUnsignedInt(
  2. tableProperties.getProperty(Constants.DRUID_TARGET_SHARDS_PER_GRANULARITY, "0"));
  3. final int maxPartitionSize = targetNumShardsPerGranularity > 0 ? -1 : HiveConf

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

  1. /**
  2. * Converts a positive value into an {@code int}.
  3. *
  4. * @param value
  5. * to convert
  6. * @return the value, or -1 if it wasn't a positive integral value
  7. */
  8. public static int positive(String value) {
  9. if (value != null) {
  10. try {
  11. return Integer.parseUnsignedInt(value);
  12. } catch (NumberFormatException e) {
  13. // Ignore
  14. }
  15. }
  16. return -1;
  17. }

代码示例来源:origin: stackoverflow.com

  1. int uint = Integer.parseUnsignedInt("4294967295");
  2. System.out.println(Integer.toUnsignedString(uint));

代码示例来源:origin: DV8FromTheWorld/JDA

  1. /**
  2. * Retrieves the JDA instance represented by the provided shard ID
  3. * or {@code null} if none of the connected shards match the provided id.
  4. *
  5. * @param id
  6. * The ID of the shard
  7. *
  8. * @throws java.lang.NumberFormatException
  9. * If the provided String is {@code null} or
  10. * cannot be resolved to an unsigned int id
  11. *
  12. * @return Possibly-null entity for the specified shard ID
  13. */
  14. default JDA getElementById(String id)
  15. {
  16. return getElementById(Integer.parseUnsignedInt(id));
  17. }
  18. }

代码示例来源:origin: stackoverflow.com

  1. long l = Integer.toUnsignedLong(uint);
  2. System.out.println(l); // will print 4294967295
  3. int x = Integer.parseUnsignedInt("4294967295");
  4. int y = 5;
  5. int cmp1 = Integer.compareUnsigned(x,y); // interprets x as 4294967295 (x>y)
  6. int cmp2 = Integer.compare(x,y); // interprets x as -1 (x<y)

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

  1. @Override
  2. public Integer get() {
  3. String rawValue = SystemReader.getInstance()
  4. .getProperty(MAX_REDIRECT_SYSTEM_PROPERTY);
  5. Integer value = Integer.valueOf(DEFAULT_MAX_REDIRECTS);
  6. if (rawValue != null) {
  7. try {
  8. value = Integer.valueOf(Integer.parseUnsignedInt(rawValue));
  9. } catch (NumberFormatException e) {
  10. LOG.warn(MessageFormat.format(
  11. JGitText.get().invalidSystemProperty,
  12. MAX_REDIRECT_SYSTEM_PROPERTY, rawValue, value));
  13. }
  14. }
  15. return value;
  16. }
  17. }).get().intValue();

代码示例来源:origin: apache/accumulo

  1. @Override
  2. public AppenderSkeleton apply(MonitorLocation loc) {
  3. int defaultPort = Integer.parseUnsignedInt(Property.MONITOR_LOG4J_PORT.getDefaultValue());
  4. HostAndPort remote = HostAndPort.fromString(loc.getLocation());
  5. SocketAppender socketAppender = new SocketAppender();
  6. socketAppender.setApplication(System.getProperty("accumulo.application", "unknown"));
  7. socketAppender.setRemoteHost(remote.getHost());
  8. socketAppender.setPort(remote.getPortOrDefault(defaultPort));
  9. return socketAppender;
  10. }
  11. }

代码示例来源:origin: stackoverflow.com

  1. try {
  2. String guessText = JOptionPane.showInputDialog("Enter your next guess");
  3. int guess = Integer.parseUnsignedInt(guessText);
  4. } catch (NumberFormatException ex) {
  5. ...
  6. }

代码示例来源:origin: Netflix/iceberg

  1. private static int getPoolSize(String systemProperty, int defaultSize) {
  2. String value = System.getProperty(systemProperty);
  3. if (value != null) {
  4. try {
  5. return Integer.parseUnsignedInt(value);
  6. } catch (NumberFormatException e) {
  7. // will return the default
  8. }
  9. }
  10. return defaultSize;
  11. }
  12. }

代码示例来源:origin: stackoverflow.com

  1. public static void main(String[] args) {
  2. SubnetTree tree = new SubnetTree();
  3. tree.add(Integer.parseUnsignedInt("01100110000000000000000000000000", 2), 8);
  4. System.out.println("true: " + tree.isInRange(Integer.parseUnsignedInt("01100110000000000000100010000101", 2)));
  5. System.out.println("false: " + tree.isInRange(Integer.parseUnsignedInt("01101110000000000000100010000101", 2)));
  6. tree.add(Integer.parseUnsignedInt("01001110000000000000000000000000", 2), 6);
  7. System.out.println("true: " + tree.isInRange(Integer.parseUnsignedInt("01100110000000000000100010000101", 2)));
  8. System.out.println("false: " + tree.isInRange(Integer.parseUnsignedInt("01101110000000000000100010000101", 2)));
  9. System.out.println("true: " + tree.isInRange(Integer.parseUnsignedInt("01001110100000000000000000000000", 2)));
  10. System.out.println("true: " + tree.isInRange(Integer.parseUnsignedInt("01001100100000000000000000111111", 2)));
  11. }

代码示例来源:origin: io.digdag/digdag-cli

  1. private static Id tryParseScheduleId(String s)
  2. {
  3. try {
  4. return Id.of(Integer.toString(Integer.parseUnsignedInt(s)));
  5. }
  6. catch (NumberFormatException ignore) {
  7. return null;
  8. }
  9. }

代码示例来源:origin: org.opencypher/grammar

  1. private static Function<String, Integer> parseInt( Repetition repetition )
  2. {
  3. return in -> {
  4. int result = parseUnsignedInt( in );
  5. return (result < repetition.minTimes() || (repetition.limited() && result > repetition.maxTimes()))
  6. ? null : result;
  7. };
  8. }

相关文章