Java XML JAXB Marshaller marshal(JAXBElement e, File f)

Here you can find the source of marshal(JAXBElement e, File f)

Description

Marshals the given element to file.

License

Apache License

Parameter

Parameter Description
e The element.
f The file.

Exception

Parameter Description
JAXBException If any unexpected problem occurs during themarshalling.
MarshalException If the ValidationEventHandler returns false fromits handleEvent method or the Marshaller is unable to marshal obj(or any object reachable from obj).
IllegalArgumentException If any of the method parameters are null

Declaration

public static void marshal(JAXBElement<?> e, File f) throws JAXBException 

Method Source Code


//package com.java2s;
/*// w  w  w . j av a  2  s.  c om
 * Copyright 2010 The Rabbit Eclipse Plug-in Project
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

import java.io.File;

import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;

import javax.xml.bind.Marshaller;

public class Main {
    private static Marshaller mar;

    /**
     * Marshals the given element to file.
     * 
     * @param e The element.
     * @param f The file.
     * @throws JAXBException If any unexpected problem occurs during the
     *           marshalling.
     * @throws MarshalException If the ValidationEventHandler returns false from
     *           its handleEvent method or the Marshaller is unable to marshal obj
     *           (or any object reachable from obj).
     * @throws IllegalArgumentException If any of the method parameters are null
     */
    public static void marshal(JAXBElement<?> e, File f) throws JAXBException {
        mar.marshal(e, f);
    }
}

Related

  1. marshal(Class clazz, T object)
  2. marshal(final Object obj, final Class... classes)
  3. marshal(final Object object)
  4. marshal(final Object object)
  5. marshal(JAXBContext context, Object object, Writer writer, Map properties)
  6. marshal(JAXBElement jaxbElement, Class cls)
  7. marshal(JAXBElement value, String contextPath, OutputStream out, ClassLoader classLoader)
  8. marshal(Marshaller m, File out, Object o)
  9. marshal(Marshaller marshaller, Object object, String filename)