01: /*
02: * Copyright 2004-2006 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:
17: package org.compass.core.converter;
18:
19: import org.compass.core.Resource;
20: import org.compass.core.mapping.Mapping;
21: import org.compass.core.marshall.MarshallingContext;
22:
23: /**
24: * A converter is responsible for performing conversion between the actual
25: * object and the resource. Must be thread safe.
26: *
27: * @author kimchy
28: */
29: public interface Converter {
30:
31: /**
32: * Marshall the given <code>Object</code> to the given <code>Resource</code>. Will use
33: * the mapping definition as to how to marshall the object.
34: * <p/>
35: * Returns <code>true</code> if data was saved in the index, and it can
36: * be read as well (i.e. stored).
37: *
38: * @param resource The resource to marhsall the object to
39: * @param root The Object to marshall to the resource
40: * @param mapping The mapping definition of how to marshall the Object to the resoruce
41: * @param context The context for the current marhslling process
42: * @return <code>true</code> if data was saved in the the index that can be read.
43: * @throws ConversionException
44: */
45: boolean marshall(Resource resource, Object root, Mapping mapping,
46: MarshallingContext context) throws ConversionException;
47:
48: /**
49: * Unmarshall the given <code>Resource</code> to the appropiate <code>Object</code>.
50: *
51: * @param resource The resource to unmarshall into an Object
52: * @param mapping The mapping definition of how to unmarshall the Resource into an Object
53: * @param context The context for the current marshalling process
54: * @return The object unmarshalled
55: * @throws ConversionException
56: */
57: Object unmarshall(Resource resource, Mapping mapping,
58: MarshallingContext context) throws ConversionException;
59: }
|