Java XML JAXB Marshaller getMarshaller(Class c)

Here you can find the source of getMarshaller(Class c)

Description

get Marshaller

License

Apache License

Declaration

private static Unmarshaller getMarshaller(Class<?> c) throws JAXBException 

Method Source Code

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

import java.util.HashMap;
import java.util.Map;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

public class Main {
    private static Map<Class<?>, Unmarshaller> marshallerMap = new HashMap<>();

    private static Unmarshaller getMarshaller(Class<?> c) throws JAXBException {
        if (marshallerMap.containsKey(c)) {
            return marshallerMap.get(c);
        } else {//from   w ww .j  ava 2s. c o m
            JAXBContext context = JAXBContext.newInstance(c);
            Unmarshaller unmarshaller = context.createUnmarshaller();
            marshallerMap.put(c, unmarshaller);
            return unmarshaller;
        }
    }
}

Related

  1. createMarshaller(String pack)
  2. getJSIDLMarshaller()
  3. getMarshaller()
  4. getMarshaller()
  5. getMarshaller(boolean prettyFormat)
  6. getMarshaller(Class clazz)
  7. getMarshaller(final String contextPath)
  8. getMarshaller(String jaxbContext, boolean pretty)
  9. getSchemaLocation(@Nonnull final Marshaller aMarshaller)