/** * Construct a new instance from a decimal string. * * @param id the ID of the principal, as a string * @throws NumberFormatException if the number is not a valid non-negative long integer */ public NumericPrincipal(final String id) throws NumberFormatException { this(Long.parseUnsignedLong(id)); }
Long l1 = Long.parseUnsignedLong("17916881237904312345");
long l = Long.parseUnsignedLong("FFFFFFFFFFFFFFFF", 16);
static long values = Long.parseUnsignedLong("18446744073709551615"); public static void main(String[] args) { System.out.println(values); // -1 System.out.println(Long.toUnsignedString(values)); // 18446744073709551615 }
/** * Parses this {@code CharSeq} as a unsigned decimal long by calling {@link Long#parseUnsignedLong(String)}. * <p> * We write * * <pre><code> * long value = charSeq.parseUnsignedLong(); * </code></pre> * * instead of * * <pre><code> * long value = Long.parseUnsignedLong(charSeq.mkString()); * </code></pre> * * @return the unsigned long value represented by this {@code CharSeq} in decimal * @throws NumberFormatException If this {@code CharSeq} does not contain a parsable unsigned long. */ @GwtIncompatible public long parseUnsignedLong() { return Long.parseUnsignedLong(back); }
/** * Parses this {@code CharSeq} as a unsigned long in the specified radix * by calling {@link Long#parseUnsignedLong(String, int)}. * <p> * We write * * <pre><code> * long value = charSeq.parseUnsignedLong(radix); * </code></pre> * * instead of * * <pre><code> * long value = Long.parseUnsignedLong(charSeq.mkString(), radix); * </code></pre> * * @param radix the radix to be used in interpreting this {@code CharSeq} * @return the unsigned long value represented by this {@code CharSeq} in the specified radix * @throws NumberFormatException If this {@code CharSeq} does not contain a parsable unsigned long. */ @GwtIncompatible public long parseUnsignedLong(int radix) { return Long.parseUnsignedLong(back, radix); }
result = Long.parseUnsignedLong(txt, radix);
/** * Test error with bad cipher */ @Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = ".*BadCipher.*") public void badCipher() throws IOException, PGPException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream os = GPGFileEncryptor.encryptFile(baos, getClass().getResourceAsStream(PUBLIC_KEY), Long.parseUnsignedLong(KEY_ID, 16), "BadCipher"); } }
/** * Encrypt a test string with an asymmetric key and check that it can be decrypted * @throws IOException * @throws PGPException */ @Test public void encryptAsym() throws IOException, PGPException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OutputStream os = GPGFileEncryptor.encryptFile(baos, getClass().getResourceAsStream(PUBLIC_KEY), Long.parseUnsignedLong(KEY_ID, 16), "CAST5"); os.write(EXPECTED_FILE_CONTENT_BYTES); os.close(); baos.close(); byte[] encryptedBytes = baos.toByteArray(); try (InputStream is = GPGFileDecryptor.decryptFile(new ByteArrayInputStream(encryptedBytes), getClass().getResourceAsStream(PRIVATE_KEY), PASSPHRASE)) { byte[] decryptedBytes = IOUtils.toByteArray(is); Assert.assertNotEquals(EXPECTED_FILE_CONTENT_BYTES, encryptedBytes); Assert.assertEquals(EXPECTED_FILE_CONTENT_BYTES, decryptedBytes); } }
keyName == null ? 0 : Long.parseUnsignedLong(keyName, 16), cipherName); default: log.debug("Do not support encryption type {}", algorithm);
private void initialize() { start = Long.parseUnsignedLong(configuration.get(START_TS_CONF)); end = Long.parseUnsignedLong(configuration.get(END_TS_CONF)); width = Long.parseLong(configuration.get(WIDTH_CONF)); }
/** * Gets unsigned long timestamp from the PCAP filename * * @return timestamp, or null if unable to parse */ public static Long getTimestamp(String pcapFilename) { String[] tokens = stripPrefix(pcapFilename).split("_"); try { return Long.parseUnsignedLong(tokens[tokens.length - 3]); } catch (NumberFormatException e) { return null; } }
String binaryString = Long.toBinaryString(Long.MIN_VALUE); long smallestLongPossibleInJava = Long.parseUnsignedLong(binaryString, 2);
public static long parseSnowflake(String input) { Checks.notEmpty(input, "ID"); try { if (!input.startsWith("-")) // if not negative -> parse unsigned return Long.parseUnsignedLong(input); else // if negative -> parse normal return Long.parseLong(input); } catch (NumberFormatException ex) { throw new NumberFormatException( String.format("The specified ID is not a valid snowflake (%s). Expecting a valid long value!", input)); } }
@Override protected void setup(Context context) throws IOException, InterruptedException { super.setup(context); filter = PcapFilters.valueOf(context.getConfiguration().get(PcapFilterConfigurator.PCAP_FILTER_NAME_CONF)).create(); filter.configure(context.getConfiguration()); start = Long.parseUnsignedLong(context.getConfiguration().get(START_TS_CONF)); end = Long.parseUnsignedLong(context.getConfiguration().get(END_TS_CONF)); }
/** * Removes an object from the cache. * * @param id The ID of the object to remove. * @return The object that was removed. */ default Optional<T> remove(String id) { return remove(Long.parseUnsignedLong(id)); }
private CustomEmojiToken(MessageTokenizer tokenizer, int startIndex, int endIndex) { super(tokenizer, startIndex, endIndex); final String content = getContent(); final long emojiId = Long.parseUnsignedLong(content.substring(content.lastIndexOf(":") + 1, content.lastIndexOf('>'))); emoji = tokenizer.getClient().getGuilds().stream() .map(guild -> guild.getEmojiByID(emojiId)).filter(Objects::nonNull).findFirst() .orElse(null); }
private RoleMentionToken(MessageTokenizer tokenizer, int startIndex, int endIndex) { super(tokenizer, startIndex, endIndex, null); mention = tokenizer.getClient().getRoleByID(Long.parseUnsignedLong(getContent().replace("<@&", "").replace(">", ""))); } }
private void guildRoleDelete(GuildRoleDeleteEventResponse event) { Guild guild = (Guild) client.getGuildByID(Long.parseUnsignedLong(event.guild_id)); if (guild != null) { IRole role = guild.getRoleByID(Long.parseUnsignedLong(event.role_id)); if (role != null) { guild.roles.remove(role); client.dispatcher.dispatch(new RoleDeleteEvent(role)); } } }
private void userUpdate(UserUpdateEventResponse event) { User newUser = (User) client.getUserByID(Long.parseUnsignedLong(event.id)); if (newUser != null) { IUser oldUser = newUser.copy(); newUser = DiscordUtils.getUserFromJSON(shard, event); client.dispatcher.dispatch(new UserUpdateEvent(oldUser, newUser)); } }