Package io.micronaut.serde.bson
Class BsonWriterEncoder
java.lang.Object
io.micronaut.serde.LimitingStream
io.micronaut.serde.bson.BsonWriterEncoder
- All Implemented Interfaces:
Encoder
,AutoCloseable
Bson implementation of
Encoder
.- Author:
- Denis Stepanov
-
Nested Class Summary
Nested classes/interfaces inherited from class io.micronaut.serde.LimitingStream
LimitingStream.RemainingLimits
-
Field Summary
Fields inherited from class io.micronaut.serde.LimitingStream
DEFAULT_LIMITS, DEFAULT_MAXIMUM_DEPTH
-
Constructor Summary
ConstructorDescriptionBsonWriterEncoder
(org.bson.BsonWriter bsonWriter, LimitingStream.RemainingLimits remainingLimits) -
Method Summary
Modifier and TypeMethodDescription@NonNull String
Return an analysis of the current path.encodeArray
(io.micronaut.core.type.Argument<?> type) Encodes an array.void
encodeBigDecimal
(BigDecimal value) Encode a BigDecimal.void
encodeBigInteger
(BigInteger value) Encode a BigInteger.void
encodeBinary
(byte @NonNull [] data) Encode the given binary data.void
encodeBoolean
(boolean value) Encode a boolean.void
encodeByte
(byte value) Encode a byte.void
encodeChar
(char value) Encode a char.void
encodeDecimal128
(org.bson.types.Decimal128 value) void
encodeDouble
(double value) Encode a double.void
encodeFloat
(float value) Encode a float.void
encodeInt
(int value) Encode an int.void
Encode a key.void
encodeLong
(long value) Encode a long.void
Encodenull
.encodeObject
(io.micronaut.core.type.Argument<?> type) Encodes an object.void
encodeObjectId
(org.bson.types.ObjectId value) void
encodeShort
(short value) Encode a short.void
encodeString
(String value) Encode a string.void
Finalize a previously created structure, like an array or object.org.bson.BsonWriter
Methods inherited from class io.micronaut.serde.LimitingStream
childLimits, decreaseDepth, increaseDepth, limitsFromConfiguration, ourLimits
-
Constructor Details
-
BsonWriterEncoder
public BsonWriterEncoder(org.bson.BsonWriter bsonWriter, LimitingStream.RemainingLimits remainingLimits)
-
-
Method Details
-
encodeArray
Description copied from interface:Encoder
Encodes an array.- Specified by:
encodeArray
in interfaceEncoder
- Parameters:
type
- The array type, nevernull
- Returns:
- The encoder, never
null
- Throws:
SerdeException
-
encodeObject
Description copied from interface:Encoder
Encodes an object.- Specified by:
encodeObject
in interfaceEncoder
- Parameters:
type
- The object type, nevernull
- Returns:
- The encoder, never
null
- Throws:
SerdeException
-
finishStructure
public void finishStructure()Description copied from interface:Encoder
Finalize a previously created structure, like an array or object.- Specified by:
finishStructure
in interfaceEncoder
-
encodeKey
Description copied from interface:Encoder
Encode a key. -
encodeString
Description copied from interface:Encoder
Encode a string.- Specified by:
encodeString
in interfaceEncoder
- Parameters:
value
- The string, nevernull
-
encodeBoolean
public void encodeBoolean(boolean value) Description copied from interface:Encoder
Encode a boolean.- Specified by:
encodeBoolean
in interfaceEncoder
- Parameters:
value
- The boolean
-
encodeByte
public void encodeByte(byte value) Description copied from interface:Encoder
Encode a byte.- Specified by:
encodeByte
in interfaceEncoder
- Parameters:
value
- The byte
-
encodeShort
public void encodeShort(short value) Description copied from interface:Encoder
Encode a short.- Specified by:
encodeShort
in interfaceEncoder
- Parameters:
value
- The short
-
encodeChar
public void encodeChar(char value) Description copied from interface:Encoder
Encode a char.- Specified by:
encodeChar
in interfaceEncoder
- Parameters:
value
- The char
-
encodeInt
public void encodeInt(int value) Description copied from interface:Encoder
Encode an int. -
encodeLong
public void encodeLong(long value) Description copied from interface:Encoder
Encode a long.- Specified by:
encodeLong
in interfaceEncoder
- Parameters:
value
- The long
-
encodeFloat
public void encodeFloat(float value) Description copied from interface:Encoder
Encode a float.- Specified by:
encodeFloat
in interfaceEncoder
- Parameters:
value
- The float
-
encodeDouble
public void encodeDouble(double value) Description copied from interface:Encoder
Encode a double.- Specified by:
encodeDouble
in interfaceEncoder
- Parameters:
value
- The double
-
encodeBigInteger
Description copied from interface:Encoder
Encode a BigInteger.- Specified by:
encodeBigInteger
in interfaceEncoder
- Parameters:
value
- The BigInteger, nevernull
-
encodeBigDecimal
Description copied from interface:Encoder
Encode a BigDecimal.- Specified by:
encodeBigDecimal
in interfaceEncoder
- Parameters:
value
- The BigDecimal, nevernull
-
encodeBinary
Description copied from interface:Encoder
Encode the given binary data. The shape of the data in the output is unspecified, the only requirement is that the equivalentDecoder.decodeBinary()
must be able to parse to the same data.- Specified by:
encodeBinary
in interfaceEncoder
- Parameters:
data
- The input data- Throws:
IOException
-
encodeNull
public void encodeNull()Description copied from interface:Encoder
Encodenull
.- Specified by:
encodeNull
in interfaceEncoder
-
currentPath
Description copied from interface:Encoder
Return an analysis of the current path.- Specified by:
currentPath
in interfaceEncoder
- Returns:
- The current path if known
-
encodeDecimal128
public void encodeDecimal128(org.bson.types.Decimal128 value) -
encodeObjectId
public void encodeObjectId(org.bson.types.ObjectId value) -
getBsonWriter
public org.bson.BsonWriter getBsonWriter()
-