001    package org.apache.ojb.broker.metadata;
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     * OJB implements the mapping conventions for JDBC as specified by the JDBC 3.0 specification and
022     * this class representing the jdbc java types of the sql types mappings - e.g.
023     * VARCHAR --> String, NUMERIC --> BigDecimal
024     * (see JDBC 3.0 specification <em>Appendix B, Data Type Conversion Tables</em>).
025     * <p/>
026     * We differ two types of fields, <em>immutable</em> (like Integer, Long, String, ...) and <em>mutable</em>
027     * (like Date, byte[], most SQL3 datatypes, ...).
028     *
029     * @version $Id: FieldType.java,v 1.1 2007-08-24 22:17:29 ewestfal Exp $
030     */
031    public interface FieldType extends Serializable
032    {
033        /**
034         * Returns a copy of the specified persistent class field (e.g. Long, Integer,...).
035         * <br/>
036         * NOTE: The specified field value 
037         * @param fieldValue The field to copy.
038         * @return A copy of the field or the same instance if copying is not possible. Depends on
039         * the implementation.
040         */
041        public Object copy(Object fieldValue);
042    
043        /**
044         * Returns <em>true</em> if the field value hasn't changed.
045         * @param firstValue A field value object.
046         * @param secondValue A field value object.
047         * @return <em>true</em> if the field value hasn't changed.
048         */
049        public boolean equals(Object firstValue, Object secondValue);
050    
051        /**
052         * Returns the sql {@link java.sql.Types} of this field.
053         */
054        public int getSqlType();
055    
056        /**
057         * Dets the associated sql field type of this field.
058         * @param jdbcType The associated {@link org.apache.ojb.broker.metadata.JdbcType}.
059         */
060        public void setSqlType(JdbcType jdbcType);
061    
062        /**
063         * Returns <em>true</em> if the field type is mutable, e.g. a jdbc BLOB field or
064         * jdbc TIMESTAMP field.
065         * @return
066         */
067        public boolean isMutable();
068    }