XmlSerializable<T> Interface
Type Parameters
- T
The type of the object that is XML serializable.
public interface XmlSerializable
Indicates that the implementing class can be serialized to and deserialized from XML.
Since deserialization needs to work without an instance of the class, implementing this interface it's assumed the class has a static method fromXml(XmlReader)
that deserializes an instance of that class. The contract for reading XML... TODO (alzimmer): finish this javadoc
Method Summary
Modifier and Type | Method and Description |
---|---|
static T |
fromXml(XmlReader xmlReader)
Reads an XML stream into an object. |
static T |
fromXml(XmlReader xmlReader, String rootElementName)
Reads an XML stream into an object. |
abstract
Xml |
toXml(XmlWriter xmlWriter)
Writes the object to the passed XmlWriter. |
abstract
Xml |
toXml(XmlWriter xmlWriter, String rootElementName)
Writes the object to the passed XmlWriter. |
Method Details
fromXml
public static T
Reads an XML stream into an object.
Implementations of XmlSerializable<T> must define this method, otherwise an UnsupportedOperationException will be thrown.
Parameters:
Returns:
Throws:
xmlReader
.
fromXml
public static T
Reads an XML stream into an object.
Implementations of XmlSerializable<T> must define this method, otherwise an UnsupportedOperationException will be thrown.
Parameters:
Returns:
Throws:
xmlReader
.
toXml
public abstract XmlWriter toXml(XmlWriter xmlWriter)
Writes the object to the passed XmlWriter.
The contract for writing XML to XmlWriter is that the object being written will handle opening and closing its own XML object. So, for objects calling out to other XmlSerializable<T> objects for serialization, they'll pass the XmlWriter to the other XmlSerializable<T> object. This way objects writing XML will be self-encapsulated for writing properly formatted XML.
Parameters:
Returns:
Throws:
xmlWriter
.
toXml
public abstract XmlWriter toXml(XmlWriter xmlWriter, String rootElementName)
Writes the object to the passed XmlWriter.
The contract for writing XML to XmlWriter is that the object being written will handle opening and closing its own XML object. So, for objects calling out to other XmlSerializable<T> objects for serialization, they'll pass the XmlWriter to the other XmlSerializable<T> object. This way objects writing XML will be self-encapsulated for writing properly formatted XML.
Parameters:
Returns:
Throws:
xmlWriter
.
Applies to
Azure SDK for Java