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
FieldsModifier and TypeFieldDescriptionprotected final com.fasterxml.jackson.core.JsonGeneratorFields inherited from class io.micronaut.serde.LimitingStream
DEFAULT_LIMITS, DEFAULT_MAXIMUM_DEPTH -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()Finalize the current structure.static @NonNull Encodercreate(@NonNull com.fasterxml.jackson.core.JsonGenerator generator) static @NonNull Encodercreate(@NonNull com.fasterxml.jackson.core.JsonGenerator generator, @NonNull LimitingStream.RemainingLimits remainingLimits) Create a new encoder.Return an analysis of the current path.final EncoderencodeArray(io.micronaut.core.type.Argument<?> type) Encodes an array.final voidencodeBigDecimal(@NonNull BigDecimal value) Encode a BigDecimal.final voidencodeBigInteger(@NonNull BigInteger value) Encode a BigInteger.voidencodeBinary(byte @NonNull [] data) Encode the given binary data.final voidencodeBoolean(boolean value) Encode a boolean.final voidencodeByte(byte value) Encode a byte.final voidencodeChar(char value) Encode a char.final voidencodeDouble(double value) Encode a double.final voidencodeFloat(float value) Encode a float.final voidencodeInt(int value) Encode an int.final voidEncode a key.final voidencodeLong(long value) Encode a long.final voidEncodenull.final EncoderencodeObject(io.micronaut.core.type.Argument<?> type) Encodes an object.final voidencodeShort(short value) Encode a short.final voidencodeString(@NonNull String value) Encode a string.final voidFinalize a previously created structure, like an array or object.protected abstract voidMethods 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:EncoderEncodes an array.- Specified by:
encodeArrayin interfaceEncoder- Parameters:
type- The array type, nevernull- Returns:
- The encoder, never
null - Throws:
IOException- if an error occurs
-
encodeObject
Description copied from interface:EncoderEncodes an object.- Specified by:
encodeObjectin interfaceEncoder- Parameters:
type- The object type, nevernull- Returns:
- The encoder, never
null - Throws:
IOException- if an error occurs
-
finishStructure
Description copied from interface:EncoderFinalize a previously created structure, like an array or object.- Specified by:
finishStructurein interfaceEncoder- Throws:
IOException- If an error occurs
-
close
Description copied from interface:EncoderFinalize the current structure. Equivalent to callingEncoder.finishStructure().- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceEncoder- Throws:
IOException- If an unrecoverable error occurs
-
finishStructureToken
- Throws:
IOException
-
currentPath
Description copied from interface:EncoderReturn an analysis of the current path.- Specified by:
currentPathin interfaceEncoder- Returns:
- The current path if known
-
encodeKey
Description copied from interface:EncoderEncode a key.- Specified by:
encodeKeyin interfaceEncoder- Parameters:
key- The key, nevernull- Throws:
IOException- If an error occurs
-
encodeString
Description copied from interface:EncoderEncode a string.- Specified by:
encodeStringin interfaceEncoder- Parameters:
value- The string, nevernull- Throws:
IOException- If an error occurs
-
encodeBoolean
Description copied from interface:EncoderEncode a boolean.- Specified by:
encodeBooleanin interfaceEncoder- Parameters:
value- The boolean- Throws:
IOException- If an error occurs
-
encodeByte
Description copied from interface:EncoderEncode a byte.- Specified by:
encodeBytein interfaceEncoder- Parameters:
value- The byte- Throws:
IOException- If an error occurs
-
encodeShort
Description copied from interface:EncoderEncode a short.- Specified by:
encodeShortin interfaceEncoder- Parameters:
value- The short- Throws:
IOException- If an error occurs
-
encodeChar
Description copied from interface:EncoderEncode a char.- Specified by:
encodeCharin interfaceEncoder- Parameters:
value- The char- Throws:
IOException- If an error occurs
-
encodeInt
Description copied from interface:EncoderEncode an int.- Specified by:
encodeIntin interfaceEncoder- Parameters:
value- The int- Throws:
IOException- If an error occurs
-
encodeLong
Description copied from interface:EncoderEncode a long.- Specified by:
encodeLongin interfaceEncoder- Parameters:
value- The long- Throws:
IOException- If an error occurs
-
encodeFloat
Description copied from interface:EncoderEncode a float.- Specified by:
encodeFloatin interfaceEncoder- Parameters:
value- The float- Throws:
IOException- If an error occurs
-
encodeDouble
Description copied from interface:EncoderEncode a double.- Specified by:
encodeDoublein interfaceEncoder- Parameters:
value- The double- Throws:
IOException- If an error occurs
-
encodeBigInteger
Description copied from interface:EncoderEncode a BigInteger.- Specified by:
encodeBigIntegerin interfaceEncoder- Parameters:
value- The BigInteger, nevernull- Throws:
IOException- If an error occurs
-
encodeBigDecimal
Description copied from interface:EncoderEncode a BigDecimal.- Specified by:
encodeBigDecimalin interfaceEncoder- Parameters:
value- The BigDecimal, nevernull- Throws:
IOException- If an error occurs
-
encodeBinary
Description copied from interface:EncoderEncode 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:
encodeBinaryin interfaceEncoder- Parameters:
data- The input data- Throws:
IOException
-
encodeNull
Description copied from interface:EncoderEncodenull.- Specified by:
encodeNullin interfaceEncoder- Throws:
IOException- If an error occurs
-