001/* 002 * Copyright 2002-2016 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.oxm; 018 019import java.io.IOException; 020import javax.xml.transform.Source; 021 022/** 023 * Defines the contract for Object XML Mapping unmarshallers. Implementations of this 024 * interface can deserialize a given XML Stream to an Object graph. 025 * 026 * @author Arjen Poutsma 027 * @since 3.0 028 * @see Marshaller 029 */ 030public interface Unmarshaller { 031 032 /** 033 * Indicate whether this unmarshaller can unmarshal instances of the supplied type. 034 * @param clazz the class that this unmarshaller is being asked if it can marshal 035 * @return {@code true} if this unmarshaller can indeed unmarshal to the supplied class; 036 * {@code false} otherwise 037 */ 038 boolean supports(Class<?> clazz); 039 040 /** 041 * Unmarshal the given {@link Source} into an object graph. 042 * @param source the source to marshal from 043 * @return the object graph 044 * @throws IOException if an I/O error occurs 045 * @throws XmlMappingException if the given source cannot be mapped to an object 046 */ 047 Object unmarshal(Source source) throws IOException, XmlMappingException; 048 049}