Class XmlStaxEncoder
java.lang.Object
io.micronaut.serde.xml.XmlStaxEncoder
- All Implemented Interfaces:
Encoder, KeysAwareEncoder, XmlEncoder, AutoCloseable
An
Encoder that serializes objects to XML using a StAX XMLStreamWriter.
Each returned encoder owns exactly one XML scope. Object scopes retain one pending property
between encodeKey(String) and the following value call; array scopes retain only their
item layout. XML content is written directly to the StAX writer.
- Since:
- 3.2
-
Method Summary
Modifier and TypeMethodDescriptionencodeArray(io.micronaut.core.type.Argument<?> type) Encodes an array.voidencodeAttributeKey(QName key) Encode an XML attribute key.voidencodeBigDecimal(BigDecimal value) Encode a BigDecimal.voidencodeBigInteger(BigInteger value) Encode a BigInteger.voidencodeBinary(byte[] data) Encode the given binary data.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 by index from the supplied key set.voidEncode a key.voidencodeLong(long value) Encode a long.voidEncodenull.encodeObject(io.micronaut.core.type.Argument<?> type) Encodes an object.voidencodeShort(short value) Encode a short.voidencodeString(String value) Encode a string.voidFinalize a previously created structure, like an array or object.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Encoder
close, currentPathMethods inherited from interface KeysAwareEncoder
encodeStringValue
-
Method Details
-
encodeArray
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
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
-
encodeKey
Description copied from interface:EncoderEncode a key.- Specified by:
encodeKeyin interfaceEncoder- Parameters:
key- The key, nevernull- Throws:
IOException- If an error occurs
-
encodeAttributeKey
Description copied from interface:XmlEncoderEncode an XML attribute key.- Specified by:
encodeAttributeKeyin interfaceXmlEncoder- Parameters:
key- The qualified attribute name- Throws:
IOException- if an error occurs
-
encodeKey
Description copied from interface:KeysAwareEncoderEncode a key by index from the supplied key set.- Specified by:
encodeKeyin interfaceKeysAwareEncoder- Parameters:
keys- The keysindex- The key index- Throws:
IOException- If an unrecoverable 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
-
encodeBinary
Description copied from interface:EncoderEncode 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.- Specified by:
encodeBinaryin interfaceEncoder- Parameters:
data- The input data- Throws:
IOException
-
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
-