public class XmlUtils
extends java.lang.Object
| Constructor and Description |
|---|
XmlUtils() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
deSerialize(java.lang.Class<T> docClass,
java.io.File file) |
static <T> T |
deSerialize(java.lang.Class<T> docClass,
java.io.InputStream inputStream)
Deserialize the XML content of a stream into a Java object of the specified type.
|
static <T> T |
deSerialize(java.lang.Class<T> docClass,
java.lang.String xmlString)
Deserialize the XML content of a string into a Java object of the specified type.
|
static java.lang.String |
getFirstAttributeValue(java.io.File file,
java.lang.String attribute) |
static <T> void |
serialize(T object,
java.io.File file) |
static <T> void |
serialize(T object,
java.io.OutputStream out) |
static <T> void |
serialize(T object,
java.nio.file.Path path) |
static javax.xml.transform.Source |
toNonValidatingSAXSource(java.io.InputStream in)
Returns a
SAXSource for the provided InputStream that explicitly forfeit external DTD validation |
public static java.lang.String getFirstAttributeValue(java.io.File file,
java.lang.String attribute)
throws java.io.IOException,
javax.xml.stream.XMLStreamException
java.io.IOExceptionjavax.xml.stream.XMLStreamExceptionpublic static <T> T deSerialize(java.lang.Class<T> docClass,
java.io.File file)
throws javax.xml.bind.JAXBException,
java.io.IOException
javax.xml.bind.JAXBExceptionjava.io.IOExceptionpublic static <T> T deSerialize(java.lang.Class<T> docClass,
java.io.InputStream inputStream)
throws javax.xml.bind.JAXBException
T - The type of object to unmarshall the XML asdocClass - The class of the object to unmarshall the XML asinputStream - An input stream containing the XML to deserializejavax.xml.bind.JAXBException - if an error occurs during deserializationpublic static <T> T deSerialize(java.lang.Class<T> docClass,
java.lang.String xmlString)
throws javax.xml.bind.JAXBException
T - The type of object to unmarshall the XML asdocClass - The class of the object to unmarshall the XML asxmlString - The XML to deserialize, as a stringjavax.xml.bind.JAXBException - if an error occurs during deserializationpublic static javax.xml.transform.Source toNonValidatingSAXSource(java.io.InputStream in)
throws org.xml.sax.SAXException,
javax.xml.parsers.ParserConfigurationException
SAXSource for the provided InputStream that explicitly forfeit external DTD validationin - the InputStream for the SAXSourceSAXSource for the provided InputStream that explicitly forfeit external DTD validationorg.xml.sax.SAXException - if a SAX error occursjavax.xml.parsers.ParserConfigurationException - if a configuration error occurspublic static <T> void serialize(T object,
java.nio.file.Path path)
throws javax.xml.bind.JAXBException,
java.io.IOException
javax.xml.bind.JAXBExceptionjava.io.IOExceptionpublic static <T> void serialize(T object,
java.io.File file)
throws javax.xml.bind.JAXBException,
java.io.IOException
javax.xml.bind.JAXBExceptionjava.io.IOExceptionpublic static <T> void serialize(T object,
java.io.OutputStream out)
throws javax.xml.bind.JAXBException
javax.xml.bind.JAXBExceptionCopyright © 2018 Frederic Thevenet. All rights reserved.