public final class XmlUtility extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T extends Serializable> |
create(String xml,
Class<T> classType)
Helper method to de-serialize XML to an object.
|
static String |
descapeStringForXml(String valueToDeserialize)
Helper method to decode a string from XML string
Returns the same string if null or empty
|
static String |
escapeStringForXml(String valueToSerialize)
Helper method to encode a string to XML
Returns the same string if null or empty
|
static String |
getRootElementXml(String xmlString)
Removes the XML prologue
|
static <T extends Serializable> |
getRootElementXml(T entity)
Removes the XML prologue
|
static <T extends Serializable> |
getXml(T entity)
Helper method to serialize an object to XML.
|
public static <T extends Serializable> String getXml(T entity) throws IOException, javax.xml.bind.JAXBException
T - class that implements Serializableentity - Object to serializeIOException - if errors during serializationjavax.xml.bind.JAXBException - if errors during serializationpublic static <T extends Serializable> T create(String xml, Class<T> classType) throws javax.xml.bind.JAXBException, ParserConfigurationException, SAXException
T - class that implements Serializablexml - object serialized into valid XMLclassType - Class Type of the object to be de-serialized intojavax.xml.bind.JAXBException - if errors during de-serializationParserConfigurationExceptionSAXExceptionpublic static String escapeStringForXml(String valueToSerialize)
valueToSerialize - string value to encode into xmlpublic static String descapeStringForXml(String valueToDeserialize)
valueToDeserialize - string value to decode from xmlpublic static <T extends Serializable> String getRootElementXml(T entity)
entity - object to remove prologueCopyright © 2021. All rights reserved.