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 void
close()
Finalize the current structure.default @NonNull String
Return an analysis of the current path.@NonNull Encoder
encodeArray
(@NonNull io.micronaut.core.type.Argument<?> type) Encodes an array.void
encodeBigDecimal
(@NonNull BigDecimal value) Encode a BigDecimal.void
encodeBigInteger
(@NonNull BigInteger value) Encode a BigInteger.default 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
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
.@NonNull Encoder
encodeObject
(@NonNull io.micronaut.core.type.Argument<?> type) Encodes an object.void
encodeShort
(short value) Encode a short.void
encodeString
(@NonNull String value) Encode a string.void
Finalize 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:
close
in 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
-