Class YamlEncoder

java.lang.Object
io.micronaut.serde.LimitingStream
io.micronaut.serde.yaml.YamlEncoder
All Implemented Interfaces:
Encoder, AutoCloseable

public class YamlEncoder extends LimitingStream implements Encoder
YAML implementation of the Encoder interface.

Scalars are emitted with implicit tags, so no type tags appear in the output. A string whose plain form would be read back as another type, such as 123 or true, is written quoted instead of tagged so that it round-trips as a string.

Since:
3.2.0
  • Constructor Details

    • YamlEncoder

      public YamlEncoder(@NonNull OutputStream outputStream, @NonNull LimitingStream.RemainingLimits remainingLimits)
      Creates a YAML encoder with the supplied output stream and stream limits.
      Parameters:
      outputStream - The output stream
      remainingLimits - The remaining stream limits
  • Method Details

    • encodeArray

      public @NonNull Encoder encodeArray(@NonNull io.micronaut.core.type.Argument<?> type) throws IOException
      Description copied from interface: Encoder
      Encodes an array.
      Specified by:
      encodeArray in interface Encoder
      Parameters:
      type - The array type, never null
      Returns:
      The encoder, never null
      Throws:
      IOException - if an error occurs
    • encodeObject

      public @NonNull Encoder encodeObject(@NonNull io.micronaut.core.type.Argument<?> type) throws IOException
      Description copied from interface: Encoder
      Encodes an object.
      Specified by:
      encodeObject in interface Encoder
      Parameters:
      type - The object type, never null
      Returns:
      The encoder, never null
      Throws:
      IOException - if an error occurs
    • finishStructure

      public void finishStructure() throws IOException
      Description copied from interface: Encoder
      Finalize a previously created structure, like an array or object.
      Specified by:
      finishStructure in interface Encoder
      Throws:
      IOException - If an error occurs
    • close

      public void close() throws IOException
      Finishes every structure that is still open, closes the document and flushes the output. The structures that serializers open are closed through their own child encoders, so closing this encoder completes the whole document.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Encoder
      Throws:
      IOException - If the document cannot be written
    • encodeKey

      public void encodeKey(@NonNull String key) throws IOException
      Description copied from interface: Encoder
      Encode a key.
      Specified by:
      encodeKey in interface Encoder
      Parameters:
      key - The key, never null
      Throws:
      IOException - If an error occurs
    • encodeString

      public void encodeString(@NonNull String value) throws IOException
      Description copied from interface: Encoder
      Encode a string.
      Specified by:
      encodeString in interface Encoder
      Parameters:
      value - The string, never null
      Throws:
      IOException - If an error occurs
    • encodeBoolean

      public void encodeBoolean(boolean value) throws IOException
      Description copied from interface: Encoder
      Encode a boolean.
      Specified by:
      encodeBoolean in interface Encoder
      Parameters:
      value - The boolean
      Throws:
      IOException - If an error occurs
    • encodeByte

      public void encodeByte(byte value) throws IOException
      Description copied from interface: Encoder
      Encode a byte.
      Specified by:
      encodeByte in interface Encoder
      Parameters:
      value - The byte
      Throws:
      IOException - If an error occurs
    • encodeShort

      public void encodeShort(short value) throws IOException
      Description copied from interface: Encoder
      Encode a short.
      Specified by:
      encodeShort in interface Encoder
      Parameters:
      value - The short
      Throws:
      IOException - If an error occurs
    • encodeChar

      public void encodeChar(char value) throws IOException
      Description copied from interface: Encoder
      Encode a char.
      Specified by:
      encodeChar in interface Encoder
      Parameters:
      value - The char
      Throws:
      IOException - If an error occurs
    • encodeInt

      public void encodeInt(int value) throws IOException
      Description copied from interface: Encoder
      Encode an int.
      Specified by:
      encodeInt in interface Encoder
      Parameters:
      value - The int
      Throws:
      IOException - If an error occurs
    • encodeLong

      public void encodeLong(long value) throws IOException
      Description copied from interface: Encoder
      Encode a long.
      Specified by:
      encodeLong in interface Encoder
      Parameters:
      value - The long
      Throws:
      IOException - If an error occurs
    • encodeFloat

      public void encodeFloat(float value) throws IOException
      Description copied from interface: Encoder
      Encode a float.
      Specified by:
      encodeFloat in interface Encoder
      Parameters:
      value - The float
      Throws:
      IOException - If an error occurs
    • encodeDouble

      public void encodeDouble(double value) throws IOException
      Description copied from interface: Encoder
      Encode a double.
      Specified by:
      encodeDouble in interface Encoder
      Parameters:
      value - The double
      Throws:
      IOException - If an error occurs
    • encodeBigInteger

      public void encodeBigInteger(@NonNull BigInteger value) throws IOException
      Description copied from interface: Encoder
      Encode a BigInteger.
      Specified by:
      encodeBigInteger in interface Encoder
      Parameters:
      value - The BigInteger, never null
      Throws:
      IOException - If an error occurs
    • encodeBigDecimal

      public void encodeBigDecimal(@NonNull BigDecimal value) throws IOException
      Description copied from interface: Encoder
      Encode a BigDecimal.
      Specified by:
      encodeBigDecimal in interface Encoder
      Parameters:
      value - The BigDecimal, never null
      Throws:
      IOException - If an error occurs
    • encodeNull

      public void encodeNull() throws IOException
      Description copied from interface: Encoder
      Encode null.
      Specified by:
      encodeNull in interface Encoder
      Throws:
      IOException - If an error occurs