Package net.hironico.common.utils
Class XMLFile
java.lang.Object
net.hironico.common.utils.XMLFile
Utility class for XML serialization and deserialization using Jackson XmlMapper.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TLoads an object from XML file.static <T> Tload(InputStream in, Class<T> clazz) Loads an object from XML input stream.static voidSaves an object to a file in XML format.static StringSerializes an object to XML string.
-
Constructor Details
-
XMLFile
public XMLFile()
-
-
Method Details
-
serialize
Serializes an object to XML string.- Parameters:
obj- the object to serialize- Returns:
- the XML string representation
- Throws:
IOException- if serialization fails
-
saveAs
Saves an object to a file in XML format.- Parameters:
file- the file to save toobj- the object to serialize- Throws:
IOException- if writing fails
-
load
Loads an object from XML input stream.- Type Parameters:
T- the type- Parameters:
in- the input stream containing XMLclazz- the class to deserialize to- Returns:
- the deserialized object
- Throws:
IOException- if reading fails
-
load
Loads an object from XML file.- Type Parameters:
T- the type- Parameters:
file- the file containing XMLclazz- the class to deserialize to- Returns:
- the deserialized object
- Throws:
IOException- if reading fails
-