Java XML JAXB Unmarshaller createUnmarshaller(Object object)

Here you can find the source of createUnmarshaller(Object object)

Description

create Unmarshaller

License

Open Source License

Declaration

@SuppressWarnings("rawtypes")
    private static Unmarshaller createUnmarshaller(Object object) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

import javax.xml.bind.Unmarshaller;

public class Main {
    @SuppressWarnings("rawtypes")
    private static Unmarshaller createUnmarshaller(Object object) {
        Class objectClass = object.getClass();

        if (objectClass.getSimpleName().equals("Class")) {
            objectClass = (Class) object;
        }//  www  .jav a 2  s . c  o  m

        JAXBContext context;
        Unmarshaller unmarshaller = null;
        try {
            context = JAXBContext.newInstance(objectClass);
            unmarshaller = context.createUnmarshaller();
        } catch (JAXBException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return unmarshaller;
    }
}

Related

  1. createUnmarshaller()
  2. createUnmarshaller(Class jaxbBindClass)
  3. createUnmarshaller(Class clazz)
  4. createUnmarshaller(Class clazz)
  5. createUnmarshaller(Class clazz)
  6. getUnmarshaller()
  7. getUnmarshaller()
  8. getUnmarshaller()
  9. getUnmarshaller(Class jaxbClass)