001    package org.apache.ojb.broker.accesslayer.conversions;
002    
003    /* Copyright 2002-2005 The Apache Software Foundation
004     *
005     * Licensed under the Apache License, Version 2.0 (the "License");
006     * you may not use this file except in compliance with the License.
007     * You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    
018    import java.io.Serializable;
019    
020    
021    /**
022     * The class <em>FieldConversion</em> declares a protocol for type and value
023     * conversions between persistent classes attributes and counterpart objects supported by the
024     * JDBC specification, e.g. <em>String</em> is supported by JDBC, so only an <em>empty</em> field
025     * conversion is needed. But if the persistent class attribute is of type <code>int[]</code> a
026     * field conversion to a supported field type is needed - e.g. <code>int[] ---> String</code>.
027     * <p/>
028     * The default implementation {@link FieldConversionDefaultImpl} does not modify its input.
029     * OJB users can use predefined implementation and can also 
030     * build their own conversions that perform arbitrary mappings.
031     * The mapping has to defined in the OJB mapping configuration file - more see documentation.
032     * 
033     * @author Thomas Mahler
034     * @version $Id: FieldConversion.java,v 1.1 2007-08-24 22:17:31 ewestfal Exp $
035     */
036    public interface FieldConversion extends Serializable
037    {
038            /**
039         * Convert an object of the persistent class to a counterpart object
040         * supported by the JDBC specification.
041         */
042        public Object javaToSql(Object source) throws ConversionException;
043    
044        /**
045         * Convert a JDBC object to a persistent class value.
046         */
047        public Object sqlToJava(Object source) throws ConversionException;
048    
049    }