01: package org.apache.ojb.broker.accesslayer.conversions;
02:
03: /* Copyright 2002-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: import java.io.Serializable;
19:
20: /**
21: * The class <em>FieldConversion</em> declares a protocol for type and value
22: * conversions between persistent classes attributes and counterpart objects supported by the
23: * JDBC specification, e.g. <em>String</em> is supported by JDBC, so only an <em>empty</em> field
24: * conversion is needed. But if the persistent class attribute is of type <code>int[]</code> a
25: * field conversion to a supported field type is needed - e.g. <code>int[] ---> String</code>.
26: * <p/>
27: * The default implementation {@link FieldConversionDefaultImpl} does not modify its input.
28: * OJB users can use predefined implementation and can also
29: * build their own conversions that perform arbitrary mappings.
30: * The mapping has to defined in the OJB mapping configuration file - more see documentation.
31: *
32: * @author Thomas Mahler
33: * @version $Id: FieldConversion.java,v 1.6.2.2 2005/12/21 22:23:38 tomdz Exp $
34: */
35: public interface FieldConversion extends Serializable {
36: /**
37: * Convert an object of the persistent class to a counterpart object
38: * supported by the JDBC specification.
39: */
40: public Object javaToSql(Object source) throws ConversionException;
41:
42: /**
43: * Convert a JDBC object to a persistent class value.
44: */
45: public Object sqlToJava(Object source) throws ConversionException;
46:
47: }
|