Java XML JAXB Unmarshaller unmarshal(Class clazz, Source source)

Here you can find the source of unmarshal(Class clazz, Source source)

Description

unmarshal

License

Open Source License

Declaration

public static <T> T unmarshal(Class<T> clazz, Source source) throws JAXBException 

Method Source Code

//package com.java2s;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;

import javax.xml.bind.Unmarshaller;

import javax.xml.transform.Source;

public class Main {
    public static <T> T unmarshal(Class<T> clazz, Source source) throws JAXBException {
        JAXBContext jc = JAXBContext.newInstance(clazz);
        Unmarshaller unmarshaller = jc.createUnmarshaller();
        JAXBElement<T> jaxbElement = unmarshaller.unmarshal(source, clazz);
        T object = jaxbElement.getValue();
        return object;
    }/*from  w  ww  .j av  a  2  s .co  m*/
}

Related

  1. getUnmarshaller()
  2. getUnmarshaller(Class jaxbClass)
  3. marshallUnmarshall(T inObj)
  4. unmarshal(Class beanClass, InputStream is)
  5. unmarshal(Class c, Object o)
  6. unmarshal(Class clazz, String xml)
  7. unmarshal(Class clazz, String xmlInClassPath)
  8. unmarshal(Class clz, File file)
  9. unmarshal(File f)