@Override protected String doBackward(Long value) { return value.toString(); }
@Override public void onPostCall(Long result) { // Handle the result of computation LOGGER.info(result.toString()); }
/** * Set the (new) value of the {@code Access-Control-Max-Age} response header. */ public void setAccessControlMaxAge(long maxAge) { set(ACCESS_CONTROL_MAX_AGE, Long.toString(maxAge)); }
/** * Set the length of the body in bytes, as specified by the * {@code Content-Length} header. */ public void setContentLength(long contentLength) { set(CONTENT_LENGTH, Long.toString(contentLength)); }
/** * Returns the String representation of the {@link #sum}. * * @return the String representation of the {@link #sum} */ public String toString() { return Long.toString(sum()); }
/** * Returns the String representation of the {@link #sum}. * * @return the String representation of the {@link #sum} */ public String toString() { return Long.toString(sum()); }
public void arrayj(long... vargs) { s = ""; if (vargs != null) { s = ""; for (long v: vargs) { this.s += Long.toString(v); } } }
/** * Set the content-length header. * Applies to the SEND, MESSAGE, and ERROR frames. */ public void setContentLength(long contentLength) { set(CONTENT_LENGTH, Long.toString(contentLength)); }
@Override public String nextStringValue() throws DataAccessException { String s = Long.toString(getNextKey()); int len = s.length(); if (len < this.paddingLength) { StringBuilder sb = new StringBuilder(this.paddingLength); for (int i = 0; i < this.paddingLength - len; i++) { sb.append('0'); } sb.append(s); s = sb.toString(); } return s; }
/** * Now that we've buffered the entire request body, update the request headers and the body * itself. This happens late to enable HttpURLConnection users to complete the socket connection * before sending request body bytes. */ @Override public Request prepareToSendRequest(Request request) throws IOException { if (request.header("Content-Length") != null) return request; outputStream().close(); contentLength = buffer.size(); return request.newBuilder() .removeHeader("Transfer-Encoding") .header("Content-Length", Long.toString(buffer.size())) .build(); }
public void testParseInt() { for (long a : UNSIGNED_INTS) { assertEquals((int) a, UnsignedInts.parseUnsignedInt(Long.toString(a))); } }
public void testParseIntWithRadix() { for (long a : UNSIGNED_INTS) { for (int radix = Character.MIN_RADIX; radix <= Character.MAX_RADIX; radix++) { assertEquals((int) a, UnsignedInts.parseUnsignedInt(Long.toString(a, radix), radix)); } } }
public void testParseIntFail() { try { UnsignedInts.parseUnsignedInt(Long.toString(1L << 32)); fail("Expected NumberFormatException"); } catch (NumberFormatException expected) { } }
public void testToString() { int[] bases = {2, 5, 7, 8, 10, 16}; for (long a : UNSIGNED_INTS) { for (int base : bases) { assertEquals(UnsignedInts.toString((int) a, base), Long.toString(a, base)); } } }
@Test public void defaultModules() throws JsonProcessingException, UnsupportedEncodingException { this.factory.afterPropertiesSet(); ObjectMapper objectMapper = this.factory.getObject(); Long timestamp = 1322903730000L; DateTime dateTime = new DateTime(timestamp, DateTimeZone.UTC); assertEquals(timestamp.toString(), new String(objectMapper.writeValueAsBytes(dateTime), "UTF-8")); }
@Test public void wellKnownModules() throws JsonProcessingException, UnsupportedEncodingException { ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build(); Long timestamp = 1322903730000L; DateTime dateTime = new DateTime(timestamp, DateTimeZone.UTC); assertEquals(timestamp.toString(), new String(objectMapper.writeValueAsBytes(dateTime), "UTF-8")); Path file = Paths.get("foo"); assertTrue(new String(objectMapper.writeValueAsBytes(file), "UTF-8").endsWith("foo\"")); Optional<String> optional = Optional.of("test"); assertEquals("\"test\"", new String(objectMapper.writeValueAsBytes(optional), "UTF-8")); // Kotlin module IntRange range = new IntRange(1, 3); assertEquals("{\"start\":1,\"end\":3}", new String(objectMapper.writeValueAsBytes(range), "UTF-8")); }
@GetMapping("/event") Flux<ServerSentEvent<Person>> sse() { return INTERVAL.take(2).map(l -> ServerSentEvent.builder(new Person("foo " + l)) .id(Long.toString(l)) .comment("bar " + l) .build()); }
@GwtIncompatible // too slow public void testEquals() { EqualsTester equalsTester = new EqualsTester(); for (int a : TEST_INTS) { long value = a & 0xffffffffL; equalsTester.addEqualityGroup( UnsignedInteger.fromIntBits(a), UnsignedInteger.valueOf(value), UnsignedInteger.valueOf(Long.toString(value)), UnsignedInteger.valueOf(Long.toString(value, 16), 16)); } equalsTester.testEquals(); }
public void testTryParse_radix() { for (int radix = Character.MIN_RADIX; radix <= Character.MAX_RADIX; radix++) { radixEncodeParseAndAssertEquals(0, radix); radixEncodeParseAndAssertEquals(8000, radix); radixEncodeParseAndAssertEquals(-8000, radix); radixEncodeParseAndAssertEquals(GREATEST, radix); radixEncodeParseAndAssertEquals(LEAST, radix); assertNull("Radix: " + radix, Ints.tryParse("9999999999999999", radix)); assertNull( "Radix: " + radix, Ints.tryParse(Long.toString((long) GREATEST + 1, radix), radix)); assertNull("Radix: " + radix, Ints.tryParse(Long.toString((long) LEAST - 1, radix), radix)); } assertNull("Hex string and dec parm", Ints.tryParse("FFFF", 10)); assertEquals("Mixed hex case", 65535, (int) Ints.tryParse("ffFF", 16)); }