public final class JaxbUtils extends Object
| Constructor and Description |
|---|
JaxbUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
marshal(JAXBElement<?> value,
Writer output)
Marshals a JAXBElement object into XML data to write to a character stream.
|
static Document |
marshalToDom(JAXBElement<?> value)
Marshals a JAXBElement object into a DOM document.
|
static String |
marshalToString(JAXBElement<?> value)
Marshals a JAXBElement object into a XML data string.
|
static <T> T |
unmarshal(Node xmlNode,
Class<T> jaxbClass)
Unmarshals the XML data in a DOM node into a Java object using JAXB.
|
static <T> T |
unmarshal(Reader reader,
Class<T> jaxbClass)
Unmarshals the XML data from a character stream into a Java object using
JAXB.
|
public static <T> T unmarshal(Node xmlNode, Class<T> jaxbClass) throws JAXBException
javax.xml.bind.Unmarshaller#unmarshal(Source).T - The type of class.xmlNode - DOM node to read the XML data from. Cannot be null.jaxbClass - JAXB-generated class that represents the XML data as a Java class.
Cannot be null.JAXBException - Exception if any issues arise.public static <T> T unmarshal(Reader reader, Class<T> jaxbClass) throws JAXBException
javax.xml.bind.Unmarshaller#unmarshal(Source).T - The type of the class.reader - Character stream to read the XML data from. Cannot be null.jaxbClass - JAXB-generated class that represents the XML data as a Java class.
Cannot be null.JAXBException - Exception if anything goes wrong.public static void marshal(JAXBElement<?> value, Writer output) throws JAXBException, IOException
javax.xml.bind.Marshaller#marshal(Object, Writer). A JAXBElement can be
created from the ObjectFactory generated by JAXB for each package.value - JAXBElement to marshal into XML data. Cannot be null.output - Character stream to write to. Cannot be null.JAXBException - Exception if handling JAXBElement goes wrong.IOException - Exception if problems with output.public static String marshalToString(JAXBElement<?> value) throws JAXBException
javax.xml.bind.Marshaller#marshal(Object, Writer). A JAXBElement can be
created from the ObjectFactory generated by JAXB for each package.value - JAXBElement to marshal into XML data. Cannot be null.JAXBException - Exception raised if handling JAXBElement goes wrong.public static Document marshalToDom(JAXBElement<?> value) throws JAXBException, ParserConfigurationException
javax.xml.bind.Marshaller#marshal(Object, Node). A JAXBElement can be
created from the ObjectFactory generated by JAXB for each package.value - JAXBElement to marshal into XML data. Cannot be null.JAXBException - Exception raised if handling JAXBElement goes wrong.ParserConfigurationException - Exception if parser problems arise.Copyright © 2021. All rights reserved.