com.github.fmjsjx.libnetty.resp.HeapBulkStringMessage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of libnetty-resp Show documentation
Show all versions of libnetty-resp Show documentation
A set of some useful libraries based on netty4.1.x.
package com.github.fmjsjx.libnetty.resp;
import static com.github.fmjsjx.libnetty.resp.RespConstants.EOL_LENGTH;
import static com.github.fmjsjx.libnetty.resp.RespConstants.EOL_SHORT;
import static com.github.fmjsjx.libnetty.resp.RespConstants.TYPE_LENGTH;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Objects;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.Unpooled;
import io.netty.util.AsciiString;
import io.netty.util.CharsetUtil;
/**
* An implementation of {@link RespBulkStringMessage} never holding a
* {@link ByteBuf}.
*
* @since 1.2
*
* @author MJ Fang
*/
public class HeapBulkStringMessage implements RespBulkStringMessage {
private final String value;
/**
* Constructs a new {@link HeapBulkStringMessage} with the specified value.
*
* @param value the value
*/
public HeapBulkStringMessage(String value) {
this.value = Objects.requireNonNull(value, "value must not be null");
}
@Override
public void encode(ByteBufAllocator alloc, List