KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > mappings > DirectToFieldMapping


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;
23
24 import oracle.toplink.essentials.internal.helper.DatabaseField;
25 import oracle.toplink.essentials.mappings.foundation.AbstractDirectMapping;
26 import oracle.toplink.essentials.internal.sessions.AbstractRecord;
27
28 /**
29  * <b>Purpose</b>: Maps an attribute to the corresponding database field type.
30  * The list of field types that are supported by TopLink's direct to field mapping
31  * is dependent on the relational database being used.
32  * A converter can be used to convert between the object and data type if they do not match.
33  *
34  * @see oracle.toplink.essentials.mappings.converters.Converter
35  * @see oracle.toplink.essentials.mappings.converters.ObjectTypeConverter
36  * @see oracle.toplink.essentials.mappings.converters.TypeConversionConverter
37  * @see oracle.toplink.essentials.mappings.converters.SerializedObjectConverter
38  *
39  * @author Sati
40  * @since TopLink/Java 1.0
41  */

42 public class DirectToFieldMapping extends AbstractDirectMapping implements RelationalMapping {
43
44     /**
45      * Default constructor.
46      */

47     public DirectToFieldMapping() {
48         super();
49     }
50
51     /**
52      * INTERNAL:
53      */

54     public boolean isRelationalMapping() {
55         return true;
56     }
57
58     /**
59      * PUBLIC:
60      * Set the field name in the mapping.
61      */

62     public void setFieldName(String JavaDoc FieldName) {
63         setField(new DatabaseField(FieldName));
64     }
65
66     protected void writeValueIntoRow(AbstractRecord row, DatabaseField field, Object JavaDoc fieldValue) {
67         row.add(getField(), fieldValue);
68     }
69 }
70
Popular Tags