KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > helper > EJB30ConversionManager


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, 2006, Oracle. All rights reserved.
22
package oracle.toplink.essentials.internal.helper;
23
24 /**
25  * <p>
26  * <b>Purpose</b>: Extension to the existing conversion manager to support the
27  * EJB 3.0 spec.
28  * <p>
29  * <b>Responsibilities</b>:
30  * <ul>
31  * <li> Allow a null value default to be read into primitives. With the current
32  * conversion manager, setting a null into a primitive causes and exception.
33  * This conversion manager was added to avoid that exception and therefore, add
34  * support for schemas that were built before the object model was mapped
35  * (using a primitive). Therefore, TopLink will not change the null column value
36  * in the database through this conversion. The value on the dataabse will only
37  * be changed if the user actually sets a new primitive value.
38  * <li> Allows users to define their own set of default null values to be used
39  * in the conversion.
40  * </ul>
41  *
42  * @author Guy Pelletier
43  * @since TopLink 10.1.4 RI
44  */

45 public class EJB30ConversionManager extends ConversionManager {
46     public EJB30ConversionManager() {
47         super();
48     }
49
50     /**
51      * INTERNAL:
52      */

53     public Object JavaDoc getDefaultNullValue(Class JavaDoc theClass) {
54         Object JavaDoc defaultNullValue = getDefaultNullValues().get(theClass);
55         
56         if (defaultNullValue == null && theClass.isPrimitive()) {
57             return 0;
58         } else {
59             return defaultNullValue;
60         }
61     }
62 }
63
Popular Tags