XmlObjectMapper class abstract interface

Extends the ObjectMapper interface to provide specialized support for XML serialization and deserialization.

The XmlObjectMapper builds upon the base ObjectMapper contract by adding XML-specific methods for reading and writing Dart objects in XML format. It maintains full compatibility with the standard JSON mapper interface while providing XML-focused operations.

Core Methods

Design Notes

  • Inherits all JSON serialization methods from ObjectMapper
  • XML-specific methods follow the same naming patterns as JSON counterparts
  • Supports both tree-based (DOM) and streaming (SAX-like) XML processing
  • Integrates with Jetson's naming strategies and converters

Example

final mapper = XmlObjectMapper();

// Serialization
final user = User(id: 1, name: 'Alice');
final xml = mapper.writeValueAsXml(user);
// Output: <user><id>1</id><name>Alice</name></user>

// Deserialization
final restored = mapper.readXmlValue<User>(xml, Class<User>());
Implemented types
Implementers

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

disableFeature(String featureName) → void
Disables a configurable feature flag.
inherited
enableFeature(String featureName) → void
Enables a configurable feature flag within the mapping engine.
inherited
getConversionService() → ConversionService
Returns the global ConversionService responsible for type coercions and primitive value conversions.
inherited
getEnvironment() → Environment
Returns the active Environment configuration associated with this mapper.
inherited
getNamingStrategy() NamingStrategy
Returns the naming strategy used for field name conversion.
inherited
isFeatureEnabled(String featureName) bool
Returns whether a feature flag is currently enabled.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readValue<T>(String data, Class<T> type, [ObjectMapperType mapWith = ObjectMapperType.JSON]) → T
Deserializes a structured string into an object of type T.
inherited
readValueFromMap<T>(Map<String, dynamic> map, Class<T> type, [ObjectMapperType mapWith = ObjectMapperType.JSON]) → T
Deserializes a pre-parsed map into an object of type T.
inherited
readXmlContentTree(String content) XmlNode
Parses the given XML content string into an XmlNode tree.
readXmlTree(XmlParser parser) XmlNode
Reads and parses XML content from the given XmlParser into an XmlNode tree.
readXmlValue<T>(String xml, Class<T> type) → T
Deserializes an XML string into an object of type T.
readXmlValueFromMap<T>(Map<String, dynamic> map, Class<T> type) → T
Deserializes an XML-compatible map into an instance of type T.
registerAdapter(Class type, ObjectSerializationAdapter<dynamic, Generator, Parser, DeserializationContext<Parser>, SerializationContext<Generator>> adapter) → void
Registers a bidirectional adapter (ObjectSerializationAdapter) for type T.
inherited
registerDeserializer(Class type, ObjectDeserializer<dynamic, Parser, DeserializationContext<Parser>> deserializer) → void
Registers a custom deserializer for type T.
inherited
registerSerializer(Class type, ObjectSerializer<dynamic, Generator, SerializationContext<Generator>> serializer) → void
Registers a custom serializer for type T.
inherited
setDeserializationContext(DeserializationContext<Parser> context) → void
Assigns the DeserializationContext used during deserialization.
inherited
setNamingStrategy(NamingStrategy strategy) → void
Sets the active NamingStrategy for this mapper.
inherited
setSerializationContext(SerializationContext<Generator> context) → void
Assigns the SerializationContext used during serialization.
inherited
setXmlGenerator(XmlGenerator generatorr) → void
Sets the active XmlGenerator used for serializing Dart objects to XML.
toString() String
A string representation of this object.
inherited
writeValueAsMap(Object? value, [ObjectMapperType mapWith = ObjectMapperType.JSON]) Map<String, dynamic>
Serializes a Dart object into a Map<String, dynamic> representation.
inherited
writeValueAsString(Object? value, [ObjectMapperType mapWith = ObjectMapperType.JSON]) String
Serializes a Dart object into a structured format string.
inherited
writeValueAsXml(Object? value) String
Serializes a Dart object into an XML string.
writeValueAsXmlMap(Object? value) Map<String, dynamic>
Serializes a Dart object into an XML Map<String, dynamic> representation.

Operators

operator ==(Object other) bool
The equality operator.
inherited