All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.server.resp.serialization.BigNumberSerializer Maven / Gradle / Ivy

There is a newer version: 15.1.4.Final
Show newest version
package org.infinispan.server.resp.serialization;

import java.math.BigInteger;
import java.nio.charset.StandardCharsets;

import org.infinispan.server.resp.ByteBufPool;

/**
 * Represent signed integer values outside the 64-bit interval.
 *
 * 

* Similar to {@link PrimitiveSerializer.IntegerSerializer}, but the prefix is the left parenthesis. *

* * @since 15.0 * @author José Bolina */ final class BigNumberSerializer implements ResponseSerializer { static final BigNumberSerializer INSTANCE = new BigNumberSerializer(); @Override public void accept(BigInteger bigInteger, ByteBufPool alloc) { // FIXME: Find a way to write without string allocation. String value = bigInteger.toString(10); int size = 1 + value.length() + RespConstants.CRLF.length; // RESP: ([+|-]\r\n alloc.acquire(size).writeByte(RespConstants.BIG_NUMBER) .writeBytes(value.getBytes(StandardCharsets.US_ASCII)) .writeBytes(RespConstants.CRLF); } @Override public boolean test(Object object) { // Handle only non-fractional large values. return object instanceof BigInteger; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy