Here you can find the source of unmarshall(Class
Parameter | Description |
---|---|
T | a parameter |
cls | a parameter |
domRequest | a parameter |
private static <T> T unmarshall(Class<T> cls, Element domRequest)
//package com.java2s; //License from project: LGPL import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import org.w3c.dom.Element; public class Main { /**//w ww. j av a 2 s . c o m * Unmarshall from DOM Element to a generic JAXBElement * * @param <T> * @param cls * @param domRequest * @return */ private static <T> T unmarshall(Class<T> cls, Element domRequest) { try { JAXBContext jc = JAXBContext.newInstance(cls); Unmarshaller unmarshaller = jc.createUnmarshaller(); JAXBElement<T> jaxbObject = unmarshaller.unmarshal(domRequest, cls); return jaxbObject.getValue(); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }