Class XmlObjectMapper
java.lang.Object
io.micronaut.serde.xml.XmlObjectMapper
- All Implemented Interfaces:
io.micronaut.json.JsonMapper, ObjectMapper
The XmlObjectMapper class provides a concrete implementation of the
ObjectMapper interface, utilizing XML serialization and deserialization.- Since:
- 3.2
- Author:
- Mousrij Hamza
-
Nested Class Summary
Nested classes/interfaces inherited from interface ObjectMapper
ObjectMapper.CloseableObjectMapper -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionXmlObjectMapper(SerdeRegistry registry, @Nullable SerdeConfiguration serdeConfiguration, @Nullable XmlSerdeConfiguration xmlConfiguration) Constructs an XML object mapper. -
Method Summary
Modifier and TypeMethodDescriptionio.micronaut.json.JsonStreamConfig<T> TreadValue(byte[] byteArray, io.micronaut.core.type.Argument<T> type) Deserializes XML bytes into an object of the requested type.<T> TreadValue(InputStream inputStream, io.micronaut.core.type.Argument<T> type) Deserializes an XML stream into an object of the requested type.<T> TDeserializes an XML string into an object of the requested type.<T> TreadValueFromTree(io.micronaut.json.tree.JsonNode tree, io.micronaut.core.type.Argument<T> type) Deserializes a JSON tree into an object of the requested type.<T> voidwriteValue(OutputStream outputStream, io.micronaut.core.type.Argument<T> type, @Nullable T object) Serializes a typed value as XML into an output stream.voidwriteValue(OutputStream outputStream, @Nullable Object object) Serializes a value as XML into an output stream.<T> byte[]writeValueAsBytes(io.micronaut.core.type.Argument<T> type, @Nullable T object) Serializes a typed value as XML bytes.byte[]writeValueAsBytes(@Nullable Object object) Serializes a value as XML bytes.writeValueAsString(@Nullable Object object) Serializes a value as an XML string.<T> io.micronaut.json.tree.JsonNodewriteValueToTree(io.micronaut.core.type.Argument<T> type, @Nullable T value) Serializes a typed value into a JSON tree.io.micronaut.json.tree.JsonNodewriteValueToTree(@Nullable Object value) Serializes a value into a JSON tree.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.json.JsonMapper
cloneWithViewClass, createReactiveParser, createSpecific, detectFeatures, readValue, readValue, readValue, readValue, readValue, readValueFromTree, updateValueFromTree, writeValueAsString, writeValueAsStringMethods inherited from interface ObjectMapper
cloneWithConfiguration, cloneWithConfiguration, cloneWithFeatures, getSerdeRegistry, updateValue, updateValue, updateValue, updateValue, updateValue
-
Field Details
-
XML_MAPPER_NAME
-
-
Constructor Details
-
XmlObjectMapper
public XmlObjectMapper(SerdeRegistry registry, @Nullable SerdeConfiguration serdeConfiguration, @Nullable XmlSerdeConfiguration xmlConfiguration) throws SerdeException Constructs an XML object mapper.- Parameters:
registry- The serde registryserdeConfiguration- The shared serde configurationxmlConfiguration- The XML serde configuration- Throws:
SerdeException- If the XML output factory cannot apply the configured XML features
-
-
Method Details
-
readValue
public <T> T readValue(InputStream inputStream, io.micronaut.core.type.Argument<T> type) throws IOException Deserializes an XML stream into an object of the requested type.- Specified by:
readValuein interfaceio.micronaut.json.JsonMapper- Type Parameters:
T- The target type- Parameters:
inputStream- The XML input streamtype- The target type- Returns:
- The deserialized value
- Throws:
IOException- If an error occurs reading or decoding XML
-
readValue
public <T> T readValue(byte[] byteArray, io.micronaut.core.type.Argument<T> type) throws IOException Deserializes XML bytes into an object of the requested type.- Specified by:
readValuein interfaceio.micronaut.json.JsonMapper- Type Parameters:
T- The target type- Parameters:
byteArray- The XML bytestype- The target type- Returns:
- The deserialized value
- Throws:
IOException- If an error occurs reading or decoding XML
-
readValue
Deserializes an XML string into an object of the requested type.- Specified by:
readValuein interfaceio.micronaut.json.JsonMapper- Type Parameters:
T- The target type- Parameters:
string- The XML stringtype- The target type- Returns:
- The deserialized value
- Throws:
IOException- If an error occurs reading or decoding XML
-
readValueFromTree
public <T> T readValueFromTree(io.micronaut.json.tree.JsonNode tree, io.micronaut.core.type.Argument<T> type) throws IOException Deserializes a JSON tree into an object of the requested type.- Specified by:
readValueFromTreein interfaceio.micronaut.json.JsonMapper- Type Parameters:
T- The target type- Parameters:
tree- The source treetype- The target type- Returns:
- The deserialized value
- Throws:
IOException- If an error occurs decoding the tree
-
writeValueToTree
Serializes a value into a JSON tree.- Specified by:
writeValueToTreein interfaceio.micronaut.json.JsonMapper- Parameters:
value- The value to serialize- Returns:
- The serialized tree
- Throws:
IOException- If an error occurs serializing the value
-
writeValueToTree
public <T> io.micronaut.json.tree.JsonNode writeValueToTree(io.micronaut.core.type.Argument<T> type, @Nullable T value) throws IOException Serializes a typed value into a JSON tree.- Specified by:
writeValueToTreein interfaceio.micronaut.json.JsonMapper- Type Parameters:
T- The value type- Parameters:
type- The value typevalue- The value to serialize- Returns:
- The serialized tree
- Throws:
IOException- If an error occurs serializing the value
-
writeValue
Serializes a value as XML into an output stream.- Specified by:
writeValuein interfaceio.micronaut.json.JsonMapper- Parameters:
outputStream- The destination output streamobject- The value to serialize- Throws:
IOException- If an error occurs writing or encoding XML
-
writeValue
public <T> void writeValue(OutputStream outputStream, io.micronaut.core.type.Argument<T> type, @Nullable T object) throws IOException Serializes a typed value as XML into an output stream.- Specified by:
writeValuein interfaceio.micronaut.json.JsonMapper- Type Parameters:
T- The value type- Parameters:
outputStream- The destination output streamtype- The value typeobject- The value to serialize- Throws:
IOException- If an error occurs writing or encoding XML
-
writeValueAsBytes
Serializes a value as XML bytes.- Specified by:
writeValueAsBytesin interfaceio.micronaut.json.JsonMapper- Parameters:
object- The value to serialize- Returns:
- The serialized XML bytes
- Throws:
IOException- If an error occurs writing or encoding XML
-
writeValueAsBytes
public <T> byte[] writeValueAsBytes(io.micronaut.core.type.Argument<T> type, @Nullable T object) throws IOException Serializes a typed value as XML bytes.- Specified by:
writeValueAsBytesin interfaceio.micronaut.json.JsonMapper- Type Parameters:
T- The value type- Parameters:
type- The value typeobject- The value to serialize- Returns:
- The serialized XML bytes
- Throws:
IOException- If an error occurs writing or encoding XML
-
writeValueAsString
Serializes a value as an XML string.- Specified by:
writeValueAsStringin interfaceio.micronaut.json.JsonMapper- Parameters:
object- The value to serialize- Returns:
- The serialized XML string
- Throws:
IOException- If an error occurs writing or encoding XML
-
getStreamConfig
public io.micronaut.json.JsonStreamConfig getStreamConfig()- Specified by:
getStreamConfigin interfaceio.micronaut.json.JsonMapper- Returns:
- The stream configuration used by this mapper
-