Package repast.simphony.xml
Class XMLSerializer
java.lang.Object
repast.simphony.xml.XMLSerializer
Wraps an XStream instance and adds converters specialized
for simphony.
- Author:
- Nick Collier
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfromXML
(InputStream input) Deserializes an object from an xml input stream.Deserializes an object from an xml reader.Deserializes an object from an xml String.void
registerConverter
(com.thoughtworks.xstream.converters.Converter converter) Registers a xstream converter.void
setClassLoader
(ClassLoader classLoader) Sets the classloader used when serializing / deserializing.void
setXmlFile
(File xmlFile) Set the XML file for converters that need the file path for serializing out objects to other file types in the same folder as the XML file.Serializes the specified object to XML and returns that XML as a String.void
toXML
(Object obj, OutputStream stream) Serializes the specified object to the specified OutputStream.void
Serializes the specified object to the specified writer.
-
Constructor Details
-
XMLSerializer
public XMLSerializer()Creates an XMLSerializer.
-
-
Method Details
-
registerConverter
public void registerConverter(com.thoughtworks.xstream.converters.Converter converter) Registers a xstream converter.- Parameters:
converter
- the converter to register
-
toXML
Serializes the specified object to XML and returns that XML as a String.- Parameters:
obj
- the object to serialize- Returns:
- the XML
- Throws:
com.thoughtworks.xstream.XStreamException
- if the object cannot be serialized
-
toXML
Serializes the specified object to the specified writer.- Parameters:
obj
- the object to serializedwriter
- the writer to write the XML to- Throws:
com.thoughtworks.xstream.XStreamException
- if the object cannot be serialized
-
toXML
Serializes the specified object to the specified OutputStream.- Parameters:
obj
- the object to serializedstream
- the OutputStream to write the XML to- Throws:
com.thoughtworks.xstream.XStreamException
- if the object cannot be serialized
-
fromXML
Deserializes an object from an xml input stream.- Parameters:
input
- the input stream- Returns:
- the deserialized object.
- Throws:
com.thoughtworks.xstream.XStreamException
- if the object cannot be deserialized
-
fromXML
Deserializes an object from an xml reader.- Parameters:
reader
- the xml reader- Returns:
- the deserialized object.
- Throws:
com.thoughtworks.xstream.XStreamException
- if the object cannot be deserialized
-
fromXML
Deserializes an object from an xml String.- Parameters:
xml
- the xml String- Returns:
- the deserialized object.
- Throws:
com.thoughtworks.xstream.XStreamException
- if the object cannot be deserialized
-
setClassLoader
Sets the classloader used when serializing / deserializing.- Parameters:
classLoader
- the classloader to use
-
setXmlFile
Set the XML file for converters that need the file path for serializing out objects to other file types in the same folder as the XML file.- Parameters:
xmlFile
-
-