Java XML JAXB Marshaller createMarshall(String pkgName)

Here you can find the source of createMarshall(String pkgName)

Description

create Marshall

License

Open Source License

Declaration

private static Marshaller createMarshall(String pkgName) throws JAXBException 

Method Source Code

//package com.java2s;
//License from project: Open Source 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 final HashMap<String, JAXBContext> marshallContexts = new HashMap<String, JAXBContext>();

    private static Marshaller createMarshall(String pkgName) throws JAXBException {
        JAXBContext jaxbCtx = null;
        if ((jaxbCtx = marshallContexts.get(pkgName)) == null) {
            jaxbCtx = JAXBContext.newInstance(pkgName);
            marshallContexts.put(pkgName, jaxbCtx);
        }// w ww. j a  v  a  2s  .c  o m
        Marshaller marshaller = jaxbCtx.createMarshaller();
        return marshaller;
    }
}

Related

  1. createJAXBMarshaller(JAXBContext jaxbContext)
  2. createMarshaller()
  3. createMarshaller(Class clazz, Map settings)
  4. createMarshaller(Class clazz)
  5. createMarshaller(JAXBContext context)