Java XML JAXB Marshaller createMarshaller(Class clazz)

Here you can find the source of createMarshaller(Class clazz)

Description

create Marshaller

License

Apache License

Declaration

private static <T> Marshaller createMarshaller(Class<T> clazz) throws JAXBException 

Method Source Code

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

import java.util.HashMap;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;

public class Main {
    private static HashMap<Class<?>, Marshaller> marshallers = new HashMap<>();

    private static <T> Marshaller createMarshaller(Class<T> clazz) throws JAXBException {
        Marshaller marshaller = createJAXBContext(clazz).createMarshaller();
        marshallers.put(clazz, marshaller);
        return marshaller;
    }//w  w w.  j  a v  a  2  s  .  c om

    private static <T> JAXBContext createJAXBContext(Class<T> clazz) throws JAXBException {
        return JAXBContext.newInstance(clazz);
    }
}

Related

  1. createJAXBMarshaller(JAXBContext jaxbContext)
  2. createMarshall(String pkgName)
  3. createMarshaller()
  4. createMarshaller(Class clazz, Map settings)
  5. createMarshaller(JAXBContext context)
  6. createMarshaller(JAXBContext ctx, boolean indent)
  7. createMarshaller(Object object)
  8. createMarshaller(String pack)