01: /*
02: * Copyright 2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.Result;
20:
21: /**
22: * Defines the contract for Object XML Mapping Marshallers. Implementations of this interface can serialize a given
23: * Object to an XML Stream.
24: * <p/>
25: * Although the <code>marshal</code> method accepts a <code>java.lang.Object</code> as its first parameter, most
26: * <code>Marshaller</code> implementations cannot handle arbitrary <code>java.lang.Object</code>. Instead, a object
27: * class must be registered with the marshaller, or have a common base class.
28: *
29: * @author Arjen Poutsma
30: * @since 1.0.0
31: */
32: public interface Marshaller {
33:
34: /**
35: * Marshals the object graph with the given root into the provided {@link Result}.
36: *
37: * @param graph the root of the object graph to marshal
38: * @param result the result to marshal to
39: * @throws XmlMappingException if the given object cannot be marshalled to the result
40: * @throws IOException if an I/O exception occurs
41: */
42: void marshal(Object graph, Result result)
43: throws XmlMappingException, IOException;
44:
45: /**
46: * Indicates whether this marshaller can marshal instances of the supplied type.
47: *
48: * @param clazz the class that this marshaller is being asked if it can marshal
49: * @return <code>true</code> if this marshaller can indeed marshal instances of the supplied class;
50: * <code>false</code> otherwise
51: */
52: boolean supports(Class clazz);
53:
54: }
|