Java XML JAXB Marshaller marshal(Class clz, T marshalObj)

Here you can find the source of marshal(Class clz, T marshalObj)

Description

marshal

License

Open Source License

Declaration

public static <T extends Object> void marshal(Class clz, T marshalObj) throws JAXBException 

Method Source Code

//package com.java2s;
/* ?Copyright 2012 Megam Systems??
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.//from  w w  w.  j av  a  2 s  .c om
    
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

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

public class Main {
    public static <T extends Object> void marshal(Class clz, T marshalObj) throws JAXBException {
        JAXBContext context = JAXBContext.newInstance(clz);
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        marshaller.marshal(marshalObj, System.out);

    }
}

Related

  1. getSchemaLocation(@Nonnull final Marshaller aMarshaller)
  2. getSunNamespacePrefixMapper(@Nonnull final Marshaller aMarshaller)
  3. isInternalSunJAXB2Marshaller(@Nullable final Marshaller aMarshaller)
  4. isSunCanonicalization(@Nonnull final Marshaller aMarshaller)
  5. isSunJAXB2Marshaller(@Nullable final Marshaller aMarshaller)
  6. marshal(Class c, String xml)
  7. marshal(Class c, String xml)
  8. marshal(Class clazz, T obj)
  9. marshal(Class clazz, T object)