Package io.micronaut.serde
Interface Encoder
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
BsonWriterEncoder,JacksonEncoder,JsonNodeEncoder,OracleJdbcJsonGeneratorEncoder
Core interface for encoding a serialization format such as JSON.
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidclose()Finalize the current structure.default @NonNull StringReturn an analysis of the current path.@NonNull EncoderencodeArray(@NonNull io.micronaut.core.type.Argument<?> type) Encodes an array.voidencodeBigDecimal(@NonNull BigDecimal value) Encode a BigDecimal.voidencodeBigInteger(@NonNull BigInteger value) Encode a BigInteger.default voidencodeBinary(byte @NonNull [] data) Encode the given binary data.voidencodeBoolean(boolean value) Encode a boolean.voidencodeByte(byte value) Encode a byte.voidencodeChar(char value) Encode a char.voidencodeDouble(double value) Encode a double.voidencodeFloat(float value) Encode a float.voidencodeInt(int value) Encode an int.voidEncode a key.voidencodeLong(long value) Encode a long.voidEncodenull.@NonNull EncoderencodeObject(@NonNull io.micronaut.core.type.Argument<?> type) Encodes an object.voidencodeShort(short value) Encode a short.voidencodeString(@NonNull String value) Encode a string.voidFinalize a previously created structure, like an array or object.
-
Method Details
-
encodeArray
@NonNull @NonNull Encoder encodeArray(@NonNull @NonNull io.micronaut.core.type.Argument<?> type) throws IOException Encodes an array.- Parameters:
type- The array type, nevernull- Returns:
- The encoder, never
null - Throws:
IOException- if an error occurs
-
encodeObject
@NonNull @NonNull Encoder encodeObject(@NonNull @NonNull io.micronaut.core.type.Argument<?> type) throws IOException Encodes an object.- Parameters:
type- The object type, nevernull- Returns:
- The encoder, never
null - Throws:
IOException- if an error occurs
-
finishStructure
Finalize a previously created structure, like an array or object.- Throws:
IOException- If an error occurs
-
close
Finalize the current structure. Equivalent to callingfinishStructure().- Specified by:
closein interfaceAutoCloseable- Throws:
IOException- If an unrecoverable error occurs
-
encodeKey
Encode a key.- Parameters:
key- The key, nevernull- Throws:
IOException- If an error occurs
-
encodeString
Encode a string.- Parameters:
value- The string, nevernull- Throws:
IOException- If an error occurs
-
encodeBoolean
Encode a boolean.- Parameters:
value- The boolean- Throws:
IOException- If an error occurs
-
encodeByte
Encode a byte.- Parameters:
value- The byte- Throws:
IOException- If an error occurs
-
encodeShort
Encode a short.- Parameters:
value- The short- Throws:
IOException- If an error occurs
-
encodeChar
Encode a char.- Parameters:
value- The char- Throws:
IOException- If an error occurs
-
encodeInt
Encode an int.- Parameters:
value- The int- Throws:
IOException- If an error occurs
-
encodeLong
Encode a long.- Parameters:
value- The long- Throws:
IOException- If an error occurs
-
encodeFloat
Encode a float.- Parameters:
value- The float- Throws:
IOException- If an error occurs
-
encodeDouble
Encode a double.- Parameters:
value- The double- Throws:
IOException- If an error occurs
-
encodeBigInteger
Encode a BigInteger.- Parameters:
value- The BigInteger, nevernull- Throws:
IOException- If an error occurs
-
encodeBigDecimal
Encode a BigDecimal.- Parameters:
value- The BigDecimal, nevernull- Throws:
IOException- If an error occurs
-
encodeBinary
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.- Parameters:
data- The input data- Throws:
IOException- Since:
- 2.1
-
encodeNull
Encodenull.- Throws:
IOException- If an error occurs
-
currentPath
Return an analysis of the current path.- Returns:
- The current path if known
-