Class JaxbExtensions
java.lang.Object
org.apache.groovy.jaxb.extensions.JaxbExtensions
This class defines new groovy methods which appear on Jaxb-related JDK
classes (
JAXBContext, Marshaller) inside the Groovy environment.
Static methods are used with the first parameter being the destination class.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Stringmarshal(javax.xml.bind.JAXBContext self, T jaxbElement) Marshall an object to a xmlString.static <T> Stringmarshal(javax.xml.bind.Marshaller self, T jaxbElement) Marshall an object to a xmlString.static <T> TUnmarshal xml data from the givenStringto object of the given type.static <T> TUnmarshal xml data from the givenStringto object of the given type.
-
Constructor Details
-
JaxbExtensions
public JaxbExtensions()
-
-
Method Details
-
marshal
public static <T> String marshal(javax.xml.bind.Marshaller self, T jaxbElement) throws javax.xml.bind.JAXBException Marshall an object to a xmlString.- Parameters:
self- a Marshaller which can marshall the type of the given objectjaxbElement- object to marshall to aString- Returns:
Stringrepresenting the object as xml- Throws:
javax.xml.bind.JAXBException
-
marshal
public static <T> String marshal(javax.xml.bind.JAXBContext self, T jaxbElement) throws javax.xml.bind.JAXBException Marshall an object to a xmlString.- Parameters:
self- a JaxbContext, which recognizes the type of the given objectjaxbElement- object to marshall to aString- Returns:
- String representing the object as xml
- Throws:
javax.xml.bind.JAXBException
-
unmarshal
public static <T> T unmarshal(javax.xml.bind.Unmarshaller self, String xml, Class<T> declaredType) throws javax.xml.bind.JAXBException Unmarshal xml data from the givenStringto object of the given type.- Parameters:
self- Unmarshaller, a Unmarshaller which can unmarshall the type of the given objectxml- xml data as aStringdeclaredType- appropriate JAXB mapped class to hold node's xml data- Returns:
- instance of destination class unmarshalled from xml
- Throws:
javax.xml.bind.JAXBException
-
unmarshal
public static <T> T unmarshal(javax.xml.bind.JAXBContext self, String xml, Class<T> declaredType) throws javax.xml.bind.JAXBException Unmarshal xml data from the givenStringto object of the given type.- Parameters:
self- a JaxbContext, which recognizes the type of the given objectxml- xml data as aStringdeclaredType- appropriate JAXB mapped class to hold node's xml data- Returns:
- instance of destination class unmarshalled from xml
- Throws:
javax.xml.bind.JAXBException
-