Java XML JAXB Marshaller getMarshaller(final String contextPath)

Here you can find the source of getMarshaller(final String contextPath)

Description

get Marshaller

License

Open Source License

Parameter

Parameter Description
contextPath a parameter

Exception

Parameter Description
JAXBException an exception

Return

Marshaller

Declaration

public static Marshaller getMarshaller(final String contextPath) throws JAXBException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Manchester Centre for Integrative Systems Biology
 * University of Manchester/*from w w  w  . j  a v  a 2s  .c o m*/
 * Manchester M1 7ND
 * United Kingdom
 * 
 * Copyright (C) 2007 University of Manchester
 * 
 * This program is released under the Academic Free License ("AFL") v3.0.
 * (http://www.opensource.org/licenses/academic.php)
 *******************************************************************************/

import javax.xml.bind.*;

public class Main {
    /**
     * 
     * @param contextPath
     * @return Marshaller
     * @throws JAXBException
     */
    public static Marshaller getMarshaller(final String contextPath) throws JAXBException {
        final JAXBContext jaxbContext = JAXBContext.newInstance(contextPath);
        final Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        return marshaller;
    }
}

Related

  1. getMarshaller()
  2. getMarshaller()
  3. getMarshaller(boolean prettyFormat)
  4. getMarshaller(Class c)
  5. getMarshaller(Class clazz)
  6. getMarshaller(String jaxbContext, boolean pretty)
  7. getSchemaLocation(@Nonnull final Marshaller aMarshaller)
  8. getSunNamespacePrefixMapper(@Nonnull final Marshaller aMarshaller)
  9. isInternalSunJAXB2Marshaller(@Nullable final Marshaller aMarshaller)