Package io.micronaut.serde.jackson
Class JacksonEncoder
java.lang.Object
io.micronaut.serde.LimitingStream
io.micronaut.serde.jackson.JacksonEncoder
- All Implemented Interfaces:
Encoder
,AutoCloseable
Implementation of the
Encoder
interface for Jackson.-
Nested Class Summary
Nested classes/interfaces inherited from class io.micronaut.serde.LimitingStream
LimitingStream.RemainingLimits
-
Field Summary
Modifier and TypeFieldDescriptionprotected final com.fasterxml.jackson.core.JsonGenerator
Fields inherited from class io.micronaut.serde.LimitingStream
DEFAULT_LIMITS, DEFAULT_MAXIMUM_DEPTH
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
close()
Finalize the current structure.static @NonNull Encoder
create
(@NonNull com.fasterxml.jackson.core.JsonGenerator generator) static @NonNull Encoder
create
(@NonNull com.fasterxml.jackson.core.JsonGenerator generator, @NonNull LimitingStream.RemainingLimits remainingLimits) Create a new encoder.Return an analysis of the current path.final Encoder
encodeArray
(io.micronaut.core.type.Argument<?> type) Encodes an array.final void
encodeBigDecimal
(@NonNull BigDecimal value) Encode a BigDecimal.final void
encodeBigInteger
(@NonNull BigInteger value) Encode a BigInteger.void
encodeBinary
(byte @NonNull [] data) Encode the given binary data.final void
encodeBoolean
(boolean value) Encode a boolean.final void
encodeByte
(byte value) Encode a byte.final void
encodeChar
(char value) Encode a char.final void
encodeDouble
(double value) Encode a double.final void
encodeFloat
(float value) Encode a float.final void
encodeInt
(int value) Encode an int.final void
Encode a key.final void
encodeLong
(long value) Encode a long.final void
Encodenull
.final Encoder
encodeObject
(io.micronaut.core.type.Argument<?> type) Encodes an object.final void
encodeShort
(short value) Encode a short.final void
encodeString
(@NonNull String value) Encode a string.final void
Finalize a previously created structure, like an array or object.protected abstract void
Methods inherited from class io.micronaut.serde.LimitingStream
childLimits, decreaseDepth, increaseDepth, limitsFromConfiguration, ourLimits
-
Field Details
-
generator
protected final com.fasterxml.jackson.core.JsonGenerator generator
-
-
Method Details
-
create
@NonNull public static @NonNull Encoder create(@NonNull @NonNull com.fasterxml.jackson.core.JsonGenerator generator) -
create
@NonNull @Internal public static @NonNull Encoder create(@NonNull @NonNull com.fasterxml.jackson.core.JsonGenerator generator, @NonNull @NonNull LimitingStream.RemainingLimits remainingLimits) Create a new encoder.- Parameters:
generator
- The jackson-core generator to write toremainingLimits
- The maximum nesting depth- Returns:
- The encoder
-
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:
IOException
- if an error occurs
-
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:
IOException
- if an error occurs
-
finishStructure
Description copied from interface:Encoder
Finalize a previously created structure, like an array or object.- Specified by:
finishStructure
in interfaceEncoder
- Throws:
IOException
- If an error occurs
-
close
Description copied from interface:Encoder
Finalize the current structure. Equivalent to callingEncoder.finishStructure()
.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceEncoder
- Throws:
IOException
- If an unrecoverable error occurs
-
finishStructureToken
- Throws:
IOException
-
currentPath
Description copied from interface:Encoder
Return an analysis of the current path.- Specified by:
currentPath
in interfaceEncoder
- Returns:
- The current path if known
-
encodeKey
Description copied from interface:Encoder
Encode a key.- Specified by:
encodeKey
in interfaceEncoder
- Parameters:
key
- The key, nevernull
- Throws:
IOException
- If an error occurs
-
encodeString
Description copied from interface:Encoder
Encode a string.- Specified by:
encodeString
in interfaceEncoder
- Parameters:
value
- The string, nevernull
- Throws:
IOException
- If an error occurs
-
encodeBoolean
Description copied from interface:Encoder
Encode a boolean.- Specified by:
encodeBoolean
in interfaceEncoder
- Parameters:
value
- The boolean- Throws:
IOException
- If an error occurs
-
encodeByte
Description copied from interface:Encoder
Encode a byte.- Specified by:
encodeByte
in interfaceEncoder
- Parameters:
value
- The byte- Throws:
IOException
- If an error occurs
-
encodeShort
Description copied from interface:Encoder
Encode a short.- Specified by:
encodeShort
in interfaceEncoder
- Parameters:
value
- The short- Throws:
IOException
- If an error occurs
-
encodeChar
Description copied from interface:Encoder
Encode a char.- Specified by:
encodeChar
in interfaceEncoder
- Parameters:
value
- The char- Throws:
IOException
- If an error occurs
-
encodeInt
Description copied from interface:Encoder
Encode an int.- Specified by:
encodeInt
in interfaceEncoder
- Parameters:
value
- The int- Throws:
IOException
- If an error occurs
-
encodeLong
Description copied from interface:Encoder
Encode a long.- Specified by:
encodeLong
in interfaceEncoder
- Parameters:
value
- The long- Throws:
IOException
- If an error occurs
-
encodeFloat
Description copied from interface:Encoder
Encode a float.- Specified by:
encodeFloat
in interfaceEncoder
- Parameters:
value
- The float- Throws:
IOException
- If an error occurs
-
encodeDouble
Description copied from interface:Encoder
Encode a double.- Specified by:
encodeDouble
in interfaceEncoder
- Parameters:
value
- The double- Throws:
IOException
- If an error occurs
-
encodeBigInteger
Description copied from interface:Encoder
Encode a BigInteger.- Specified by:
encodeBigInteger
in interfaceEncoder
- Parameters:
value
- The BigInteger, nevernull
- Throws:
IOException
- If an error occurs
-
encodeBigDecimal
Description copied from interface:Encoder
Encode a BigDecimal.- Specified by:
encodeBigDecimal
in interfaceEncoder
- Parameters:
value
- The BigDecimal, nevernull
- Throws:
IOException
- If an error occurs
-
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
Description copied from interface:Encoder
Encodenull
.- Specified by:
encodeNull
in interfaceEncoder
- Throws:
IOException
- If an error occurs
-