Java XML JAXB Unmarshaller unmarshal(File f)

Here you can find the source of unmarshal(File f)

Description

Unmarshals a file.

License

Apache License

Parameter

Parameter Description
f The file.

Exception

Parameter Description
JAXBException If any unexpected errors occur while unmarshalling
UnmarshalException If the ValidationEventHandler returns false fromits handleEvent method or the Unmarshaller is unable to performthe XML to Java binding.
IllegalArgumentException If the file parameter is null

Return

The object unmarshaled.

Declaration

public static Object unmarshal(File f) throws JAXBException 

Method Source Code


//package com.java2s;
/*// w w  w  . j av a  2 s .co  m
 * 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.JAXBException;

import javax.xml.bind.Unmarshaller;

public class Main {
    private static Unmarshaller unmar;

    /**
     * Unmarshals a file.
     * 
     * @param f The file.
     * @return The object unmarshaled.
     * @throws JAXBException If any unexpected errors occur while unmarshalling
     * @throws UnmarshalException If the ValidationEventHandler returns false from
     *           its handleEvent method or the Unmarshaller is unable to perform
     *           the XML to Java binding.
     * @throws IllegalArgumentException If the file parameter is null
     */
    public static Object unmarshal(File f) throws JAXBException {
        return unmar.unmarshal(f);
    }
}

Related

  1. unmarshal(Class c, Object o)
  2. unmarshal(Class clazz, Source source)
  3. unmarshal(Class clazz, String xml)
  4. unmarshal(Class clazz, String xmlInClassPath)
  5. unmarshal(Class clz, File file)
  6. unmarshal(final Class clazz, String json)
  7. unmarshal(final String xml, Class clazz, InputStream inputSchema)
  8. unmarshal(final String xml, final Class clazz)
  9. unmarshal(InputSource inputSource, Class clazz)