Package org.rapidcontext.core.data
Class XmlSerializer
java.lang.Object
org.rapidcontext.core.data.XmlSerializer
A data serializer for XML. It will read and write stand-alone XML
documents in the UTF-8 character set. The following basic
requirements must be met in order to serialize an object:
- No circular references are permitted.
- String, Integer, Boolean, Date, Array and Dict values are supported.
- Other value types are converted to strings.
- Key names should consist of valid XML tag characters (or will be transformed).
- Version:
- 1.0
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic void
serialize
(Object obj, OutputStream os) Serializes an object into an XML representation.static String
Serializes an object into an XML representation.static Object
Unserializes an object from an XML representation.
-
Field Details
-
PROLOG
The XML file prolog (XML declaration).- See Also:
-
-
Method Details
-
serialize
Serializes an object into an XML representation.- Parameters:
obj
- the object to convert, or nullos
- the output stream to write to- Throws:
IOException
- if the data couldn't be serialized
-
serialize
Serializes an object into an XML representation. The string returned is a stand-alone XML document marked as being in the UTF-8 charset.- Parameters:
id
- the data identifierobj
- the object to convert, or null- Returns:
- an XML representation
-
unserialize
Unserializes an object from an XML representation.- Parameters:
is
- the input stream to load- Returns:
- the object read
- Throws:
IOException
- if an error occurred while reading
-