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 Encoder encodeArray(@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 Encoder encodeObject(@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 String key) throws IOException
      Encode a key.
      Parameters:
      key - The key, never null
      Throws:
      IOException - If an error occurs
    • encodeString

      void encodeString(@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 BigInteger value) throws IOException
      Encode a BigInteger.
      Parameters:
      value - The BigInteger, never null
      Throws:
      IOException - If an error occurs
    • encodeBigDecimal

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

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

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