View Javadoc

1   /*
2    * Copyright 2005-2007 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.springframework.oxm;
17  
18  import java.io.IOException;
19  import javax.xml.transform.Source;
20  
21  /**
22   * Defines the contract for Object XML Mapping unmarshallers.
23   * <p/>
24   * <p>Implementations of this interface can deserialize a given XML Stream to an Object graph.
25   *
26   * @author Arjen Poutsma
27   * @since 1.0.0
28   */
29  public interface Unmarshaller {
30  
31      /**
32       * Unmarshals the given {@link Source} into an object graph.
33       *
34       * @param source the source to marshal from
35       * @return the object graph
36       * @throws XmlMappingException if the given source cannot be mapped to an object
37       * @throws IOException         if an I/O Exception occurs
38       */
39      Object unmarshal(Source source) throws XmlMappingException, IOException;
40  
41      /**
42       * Indicates whether this unmarshaller can unmarshal instances of the supplied type.
43       *
44       * @param clazz the class that this unmarshaller is being asked if it can marshal
45       * @return <code>true</code> if this unmarshaller can indeed unmarshal to the supplied class; <code>false</code>
46       *         otherwise
47       */
48      boolean supports(Class clazz);
49  
50  }