@Test public void parseUnsignedLong() { assertThat(XCloudTraceContextExtractor.parseUnsignedLong("9223372036854775807")) .isEqualTo(Long.parseUnsignedLong("9223372036854775807")); assertThat(XCloudTraceContextExtractor.parseUnsignedLong("9223372036854775808")) .isEqualTo(Long.parseUnsignedLong("9223372036854775808")); assertThat(XCloudTraceContextExtractor.parseUnsignedLong("18446744073709551615")) .isEqualTo(Long.parseUnsignedLong("18446744073709551615")); try { XCloudTraceContextExtractor.parseUnsignedLong("18446744073709551616"); failBecauseExceptionWasNotThrown(NumberFormatException.class); } catch (NumberFormatException e) { } }
static long parseUnsignedLong(String input) throws NumberFormatException { if (input == null) throw new NumberFormatException("input == null"); int len = input.length(); if (len == 0) throw new NumberFormatException("empty input"); if (len > 20) throw new NumberFormatException("too long for uint64: " + input); if (len <= 18) return Long.parseLong(input); long left = Long.parseLong(input.substring(0, 18)); int digit19 = digitAt(input, 18); int rightDigits = 20 - len; if (rightDigits == 1) { return left * 10 + digit19; } int digit20 = digitAt(input, 19); int right = digit19 * 10 + digit20; if (left > 184467440737095516L || (left == 184467440737095516L && right > 15)) { throw new NumberFormatException("out of range for uint64: " + input); } return left * 100 + right; }
XCloudTraceContextExtractor implements Extractor<R> { static long parseUnsignedLong(String input) throws NumberFormatException { if (input == null) throw new NumberFormatException("input == null"); int len = input.length(); if (len == 0) throw new NumberFormatException("empty input"); if (len > 20) throw new NumberFormatException("too long for uint64: " + input); if (len <= 18) return Long.parseLong(input); long left = Long.parseLong(input.substring(0, 18)); int digit19 = digitAt(input, 18); int rightDigits = 20 - len; if (rightDigits == 1) { return left * 10 + digit19; } int digit20 = digitAt(input, 19); int right = digit19 * 10 + digit20; if (left > 184467440737095516L || (left == 184467440737095516L && right > 15)) { throw new NumberFormatException("out of range for uint64: " + input); } return left * 100 + right; } }
XCloudTraceContextExtractor implements Extractor<R> { static long parseUnsignedLong(String input) throws NumberFormatException { if (input == null) throw new NumberFormatException("input == null"); int len = input.length(); if (len == 0) throw new NumberFormatException("empty input"); if (len > 20) throw new NumberFormatException("too long for uint64: " + input); if (len <= 18) return Long.parseLong(input); long left = Long.parseLong(input.substring(0, 18)); int digit19 = digitAt(input, 18); int rightDigits = 20 - len; if (rightDigits == 1) { return left * 10 + digit19; } int digit20 = digitAt(input, 19); int right = digit19 * 10 + digit20; if (left > 184467440737095516L || (left == 184467440737095516L && right > 15)) { throw new NumberFormatException("out of range for uint64: " + input); } return left * 100 + right; } XCloudTraceContextExtractor(Propagation<String> primary, Getter<R, String> getter); }
XCloudTraceContextExtractor implements Extractor<R> { static long parseUnsignedLong(String input) throws NumberFormatException { if (input == null) throw new NumberFormatException("input == null"); int len = input.length(); if (len == 0) throw new NumberFormatException("empty input"); if (len > 20) throw new NumberFormatException("too long for uint64: " + input); if (len <= 18) return Long.parseLong(input); long left = Long.parseLong(input.substring(0, 18)); int digit19 = digitAt(input, 18); int rightDigits = 20 - len; if (rightDigits == 1) { return left * 10 + digit19; } int digit20 = digitAt(input, 19); int right = digit19 * 10 + digit20; if (left > 184467440737095516L || (left == 184467440737095516L && right > 15)) { throw new NumberFormatException("out of range for uint64: " + input); } return left * 100 + right; } XCloudTraceContextExtractor(Propagation<String> primary, Getter<R, String> getter); @Override TraceContextOrSamplingFlags extract(R request); }
XCloudTraceContextExtractor implements Extractor<R> { static long parseUnsignedLong(String input) throws NumberFormatException { if (input == null) throw new NumberFormatException("input == null"); int len = input.length(); if (len == 0) throw new NumberFormatException("empty input"); if (len > 20) throw new NumberFormatException("too long for uint64: " + input); if (len <= 18) return Long.parseLong(input); long left = Long.parseLong(input.substring(0, 18)); int digit19 = digitAt(input, 18); int rightDigits = 20 - len; if (rightDigits == 1) { return left * 10 + digit19; } int digit20 = digitAt(input, 19); int right = digit19 * 10 + digit20; if (left > 184467440737095516L || (left == 184467440737095516L && right > 15)) { throw new NumberFormatException("out of range for uint64: " + input); } return left * 100 + right; } XCloudTraceContextExtractor(Propagation<String> primary, Getter<R, String> getter); @Override TraceContextOrSamplingFlags extract(R request);  }