Java XML JAXB Unmarshaller unmarshaller(Class entityType, InputStream in)

Here you can find the source of unmarshaller(Class entityType, InputStream in)

Description

unmarshaller

License

Apache License

Declaration

public static <T> T unmarshaller(Class<T> entityType, InputStream in) throws JAXBException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.InputStream;
import java.io.Reader;

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

import javax.xml.bind.Unmarshaller;

public class Main {
    public static <T> T unmarshaller(Class<T> entityType, InputStream in) throws JAXBException {
        Unmarshaller unmarshaller = createUnmarshaller(entityType);
        return (T) unmarshaller.unmarshal(in);
    }//from  ww  w. ja va  2  s. co m

    public static <T> T unmarshaller(Class<T> entityType, Reader reader) throws JAXBException {
        Unmarshaller unmarshaller = createUnmarshaller(entityType);
        return (T) unmarshaller.unmarshal(reader);
    }

    public static Unmarshaller createUnmarshaller(Class<?> clazz) throws JAXBException {
        JAXBContext jaxbContext = JAXBContext.newInstance(clazz);
        return jaxbContext.createUnmarshaller();
    }
}

Related

  1. unmarshall(String cntxtPkg, InputStream in)
  2. unmarshall(String file, Class desiredClass, Class context)
  3. unmarshall(String xml, Class... classesToBeBound)
  4. unmarshall(String xml, Class clazz)
  5. unmarshall(String xml, URL schemaURL, Class... classesToBeBound)
  6. unmarshaller(String xml, Class T)
  7. unmarshallJAXBElement(JAXBElement v)
  8. unMarshallRequest(String xmlString)
  9. unmarshallString(String str, Class c)