Class YamlEncoder
java.lang.Object
io.micronaut.serde.LimitingStream
io.micronaut.serde.yaml.YamlEncoder
- All Implemented Interfaces:
Encoder, AutoCloseable
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
-
Nested Class Summary
Nested classes/interfaces inherited from class LimitingStream
LimitingStream.RemainingLimits -
Field Summary
Fields inherited from class LimitingStream
DEFAULT_LIMITS, DEFAULT_MAXIMUM_DEPTH -
Constructor Summary
ConstructorsConstructorDescriptionYamlEncoder(@NonNull OutputStream outputStream, @NonNull LimitingStream.RemainingLimits remainingLimits) Creates a YAML encoder with the supplied output stream and stream limits. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Finalize the current structure.@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.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.Methods inherited from class LimitingStream
childLimits, decreaseDepth, increaseDepth, limitsFromConfiguration, ourLimitsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Encoder
currentPath, encodeBinary
-
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 streamremainingLimits- The remaining stream limits
-
-
Method Details
-
encodeArray
public @NonNull Encoder encodeArray(@NonNull io.micronaut.core.type.Argument<?> type) throws IOException Description copied from interface:EncoderEncodes an array.- Specified by:
encodeArrayin interfaceEncoder- Parameters:
type- The array type, nevernull- 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:EncoderEncodes an object.- Specified by:
encodeObjectin interfaceEncoder- Parameters:
type- The object type, nevernull- Returns:
- The encoder, never
null - Throws:
IOException- if an error occurs
-
finishStructure
Description copied from interface:EncoderFinalize a previously created structure, like an array or object.- Specified by:
finishStructurein interfaceEncoder- Throws:
IOException- If an error occurs
-
close
Description copied from interface:EncoderFinalize the current structure. Equivalent to callingEncoder.finishStructure().- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceEncoder- Throws:
IOException- If an unrecoverable error occurs
-
encodeKey
Description copied from interface:EncoderEncode a key.- Specified by:
encodeKeyin interfaceEncoder- Parameters:
key- The key, nevernull- Throws:
IOException- If an error occurs
-
encodeString
Description copied from interface:EncoderEncode a string.- Specified by:
encodeStringin interfaceEncoder- Parameters:
value- The string, nevernull- Throws:
IOException- If an error occurs
-
encodeBoolean
Description copied from interface:EncoderEncode a boolean.- Specified by:
encodeBooleanin interfaceEncoder- Parameters:
value- The boolean- Throws:
IOException- If an error occurs
-
encodeByte
Description copied from interface:EncoderEncode a byte.- Specified by:
encodeBytein interfaceEncoder- Parameters:
value- The byte- Throws:
IOException- If an error occurs
-
encodeShort
Description copied from interface:EncoderEncode a short.- Specified by:
encodeShortin interfaceEncoder- Parameters:
value- The short- Throws:
IOException- If an error occurs
-
encodeChar
Description copied from interface:EncoderEncode a char.- Specified by:
encodeCharin interfaceEncoder- Parameters:
value- The char- Throws:
IOException- If an error occurs
-
encodeInt
Description copied from interface:EncoderEncode an int.- Specified by:
encodeIntin interfaceEncoder- Parameters:
value- The int- Throws:
IOException- If an error occurs
-
encodeLong
Description copied from interface:EncoderEncode a long.- Specified by:
encodeLongin interfaceEncoder- Parameters:
value- The long- Throws:
IOException- If an error occurs
-
encodeFloat
Description copied from interface:EncoderEncode a float.- Specified by:
encodeFloatin interfaceEncoder- Parameters:
value- The float- Throws:
IOException- If an error occurs
-
encodeDouble
Description copied from interface:EncoderEncode a double.- Specified by:
encodeDoublein interfaceEncoder- Parameters:
value- The double- Throws:
IOException- If an error occurs
-
encodeBigInteger
Description copied from interface:EncoderEncode a BigInteger.- Specified by:
encodeBigIntegerin interfaceEncoder- Parameters:
value- The BigInteger, nevernull- Throws:
IOException- If an error occurs
-
encodeBigDecimal
Description copied from interface:EncoderEncode a BigDecimal.- Specified by:
encodeBigDecimalin interfaceEncoder- Parameters:
value- The BigDecimal, nevernull- Throws:
IOException- If an error occurs
-
encodeNull
Description copied from interface:EncoderEncodenull.- Specified by:
encodeNullin interfaceEncoder- Throws:
IOException- If an error occurs
-