Interface Encoder

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
BsonWriterEncoder, JacksonEncoder, JsonNodeEncoder, OracleJdbcJsonGeneratorEncoder

public interface Encoder extends AutoCloseable
Core interface for encoding a serialization format such as JSON.
Since:
1.0.0
  • 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, never null
      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, never null
      Returns:
      The encoder, never null
      Throws:
      IOException - if an error occurs
    • finishStructure

      void finishStructure() throws IOException
      Finalize a previously created structure, like an array or object.
      Throws:
      IOException - If an error occurs
    • close

      default void close() throws IOException
      Finalize the current structure. Equivalent to calling finishStructure().
      Specified by:
      close in interface AutoCloseable
      Throws:
      IOException - If an unrecoverable error occurs
    • encodeKey

      void encodeKey(@NonNull @NonNull String key) throws IOException
      Encode a key.
      Parameters:
      key - The key, never null
      Throws:
      IOException - If an error occurs
    • encodeString

      void encodeString(@NonNull @NonNull String value) throws IOException
      Encode a string.
      Parameters:
      value - The string, never null
      Throws:
      IOException - If an error occurs
    • encodeBoolean

      void encodeBoolean(boolean value) throws IOException
      Encode a boolean.
      Parameters:
      value - The boolean
      Throws:
      IOException - If an error occurs
    • encodeByte

      void encodeByte(byte value) throws IOException
      Encode a byte.
      Parameters:
      value - The byte
      Throws:
      IOException - If an error occurs
    • encodeShort

      void encodeShort(short value) throws IOException
      Encode a short.
      Parameters:
      value - The short
      Throws:
      IOException - If an error occurs
    • encodeChar

      void encodeChar(char value) throws IOException
      Encode a char.
      Parameters:
      value - The char
      Throws:
      IOException - If an error occurs
    • encodeInt

      void encodeInt(int value) throws IOException
      Encode an int.
      Parameters:
      value - The int
      Throws:
      IOException - If an error occurs
    • encodeLong

      void encodeLong(long value) throws IOException
      Encode a long.
      Parameters:
      value - The long
      Throws:
      IOException - If an error occurs
    • encodeFloat

      void encodeFloat(float value) throws IOException
      Encode a float.
      Parameters:
      value - The float
      Throws:
      IOException - If an error occurs
    • encodeDouble

      void encodeDouble(double value) throws IOException
      Encode a double.
      Parameters:
      value - The double
      Throws:
      IOException - If an error occurs
    • encodeBigInteger

      void encodeBigInteger(@NonNull @NonNull BigInteger value) throws IOException
      Encode a BigInteger.
      Parameters:
      value - The BigInteger, never null
      Throws:
      IOException - If an error occurs
    • encodeBigDecimal

      void encodeBigDecimal(@NonNull @NonNull BigDecimal value) throws IOException
      Encode a BigDecimal.
      Parameters:
      value - The BigDecimal, never null
      Throws:
      IOException - If an error occurs
    • encodeBinary

      default void encodeBinary(byte @NonNull [] data) throws IOException
      Encode the given binary data. The shape of the data in the output is unspecified, the only requirement is that the equivalent Decoder.decodeBinary() must be able to parse to the same data.
      Parameters:
      data - The input data
      Throws:
      IOException
      Since:
      2.1
    • encodeNull

      void encodeNull() throws IOException
      Encode null.
      Throws:
      IOException - If an error occurs
    • currentPath

      @NonNull default @NonNull String currentPath()
      Return an analysis of the current path.
      Returns:
      The current path if known