Class Json
JSON values are divided into input and output values. Input values are provided by code that wants to bind values to a query. Input values are intended to be consumed by the driver. Input values should not be consumed by application code.
Output values are returned by the driver to be consumed by application code using the following methods:
JSON values should be generally considered for single-consumption only. Output values retain a reference to a potentially pooled memory buffer and must be consumed to avoid memory leaks.
-
Method Summary
Modifier and TypeMethodDescriptionabstract byte[]asArray()Returns the value asbyte[].abstract StringasString()Returns the value asString.abstract <T> TmapBuffer(Function<ByteBuffer, ? extends T> mappingFunction) Returns an object consisting of the result of applying the given mappingFunctionto theByteBufferof this JSON value.abstract <T> TmapByteBuf(Function<io.netty.buffer.ByteBuf, ? extends T> mappingFunction) Returns an object consisting of the result of applying the given mappingFunctionto theByteBufof this JSON value.abstract <T> TmapInputStream(Function<InputStream, ? extends T> mappingFunction) Returns an object consisting of the result of applying the given mappingFunctionto theInputStreamof this JSON value.static Jsonof(byte[] value) Create aJsonobject from abyte[] value.static Jsonof(io.netty.buffer.ByteBuf buffer) Create aJsonobject from aByteBuf.static Jsonof(InputStream inputStream) Create aJsonobject from aInputStream.static Jsonstatic Jsonof(ByteBuffer buffer) Create aJsonobject from aByteBuffer.
-
Method Details
-
of
Create aJsonobject from aByteBuffer.- Parameters:
buffer- the JSON value asByteBuffer- Returns:
Jsonobject from aByteBuffer.- Throws:
IllegalArgumentException- ifbufferisnull
-
of
- Parameters:
buffer- the JSON value asByteBuf- Returns:
Jsonobject from aByteBuf.- Throws:
IllegalArgumentException- ifbufferisnull
-
of
- Parameters:
inputStream- the JSON value asInputStream- Returns:
Jsonobject from aInputStream.- Throws:
IllegalArgumentException- ifinputStreamisnull
-
of
Create aJsonobject from abyte[] value.- Parameters:
value- the JSON value asbyte[]- Returns:
Jsonobject from abyte[] value.- Throws:
IllegalArgumentException- ifvalueisnull
-
of
-
mapBuffer
Returns an object consisting of the result of applying the given mappingFunctionto theByteBufferof this JSON value.Consumption methods should be called exactly once as the underlying JSON value is typically released after consumption.
- Type Parameters:
T- return type.- Parameters:
mappingFunction- mapping function that gets applied to theByteBufferrepresentation of this JSON value.- Returns:
- the mapped value. Can be
null.
-
mapByteBuf
@Nullable public abstract <T> T mapByteBuf(Function<io.netty.buffer.ByteBuf, ? extends T> mappingFunction) Returns an object consisting of the result of applying the given mappingFunctionto theByteBufof this JSON value.Consumption methods should be called exactly once as the underlying JSON value is typically released after consumption.
- Type Parameters:
T- return type.- Parameters:
mappingFunction- mapping function that gets applied to theByteBufrepresentation of this JSON value.- Returns:
- the mapped value. Can be
null.
-
mapInputStream
Returns an object consisting of the result of applying the given mappingFunctionto theInputStreamof this JSON value.Consumption methods should be called exactly once as the underlying JSON value is typically released after consumption.
- Type Parameters:
T- return type.- Parameters:
mappingFunction- mapping function that gets applied to theInputStreamrepresentation of this JSON value.- Returns:
- the mapped value. Can be
null.
-
asArray
public abstract byte[] asArray()Returns the value asbyte[].Consumption methods should be called exactly once as the underlying JSON value is typically released after consumption.
- Returns:
- the contents of the JSON value as
byte[].
-
asString
-