KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > mappings > converters > Converter


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.mappings.converters;
23
24 import java.io.Serializable JavaDoc;
25 import oracle.toplink.essentials.mappings.*;
26 import oracle.toplink.essentials.sessions.Session;
27
28 /**
29  * <p><b>Purpose</b>: Conversion interface to allow conversion between object and data types.
30  * This can be used in any mapping to convert between the object and data types without requiring code
31  * placed in the object model.
32  * TopLink provides several common converters, but the application can also define it own.
33  *
34  * @see DirectToFieldMapping#setConverter(Converter)
35  * @see DirectCollectionMapping#setConverter(Converter)
36  * @see ObjectTypeConverter
37  * @see TypeConversionConverter
38  * @see SerializedObjectConverter
39  *
40  * @author James Sutherland
41  * @since OracleAS TopLink 10<i>g</i> (10.0.3)
42  */

43 public interface Converter extends Serializable JavaDoc {
44
45     /**
46      * PUBLIC:
47      * Convert the object's representation of the value to the databases' data representation.
48      * For example this could convert between a Calendar Java type and the sql.Time datatype.
49      */

50     Object JavaDoc convertObjectValueToDataValue(Object JavaDoc objectValue, Session session);
51
52     /**
53      * PUBLIC:
54      * Convert the databases' data representation of the value to the object's representation.
55      * For example this could convert between an sql.Time datatype and the Java Calendar type.
56      */

57     Object JavaDoc convertDataValueToObjectValue(Object JavaDoc dataValue, Session session);
58
59     /**
60      * PUBLIC:
61      * If the converter converts the value to a mutable value, i.e.
62      * a value that can have its' parts changed without being replaced,
63      * then it must return true. If the value is not mutable, cannot be changed without
64      * replacing the whole value then false must be returned.
65      * This is used within the UnitOfWork to determine how to clone.
66      */

67     public boolean isMutable();
68
69     /**
70      * PUBLIC:
71      * Allow for any initialization.
72      */

73     void initialize(DatabaseMapping mapping, Session session);
74 }
75
Popular Tags