KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > triactive > jdo > store > Mapping


1 /*
2  * Copyright 2004 (C) TJDO.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the TJDO License version 1.0.
6  * See the terms of the TJDO License in the documentation provided with this software.
7  *
8  * $Id: Mapping.java,v 1.5 2004/01/18 03:01:06 jackknifebarber Exp $
9  */

10
11 package com.triactive.jdo.store;
12
13
14 /**
15  * An object that maps between a Java type and its relational representation
16  * in the data store.
17  * <p>
18  * Subclasses of Mapping define and perform the storage and retrieval functions
19  * for a particular Java type.
20  * They also assist in arbitrary SQL generation such as done during Query
21  * compilation.
22  * <p>
23  * Individual Mapping objects are sometimes bound to specific database tables
24  * or columns, and are re-used for all data transfers.
25  * Other times a Mapping is merely prototypical, and is used for transferring
26  * to or from any suitable table/column.
27  *
28  * @author <a HREF="mailto:mmartin5@austin.rr.com">Mike Martin</a>
29  * @version $Revision: 1.5 $
30  *
31  * @see DatabaseAdapter#getMapping(Class)
32  * @see DatabaseAdapter#getMapping(ClassBaseTable,int)
33  */

34
35 public abstract class Mapping
36 {
37     protected final DatabaseAdapter dba;
38     protected final Class JavaDoc type;
39
40
41     /**
42      * Create a new Mapping with the given DatabaseAdapter for the given type.
43      *
44      * @param dba The DatabaseAdapter that this Mapping should use.
45      * @param type The Class that this mapping maps to the database.
46      */

47     protected Mapping(DatabaseAdapter dba, Class JavaDoc type)
48     {
49         this.dba = dba;
50         this.type = type;
51     }
52
53     /**
54      * Return the Class that this Mapping maps to the database.
55      *
56      * @return The Class that this Mapping maps to the database.
57      */

58     public Class JavaDoc getType()
59     {
60         return type;
61     }
62
63     public abstract SQLExpression newSQLLiteral(QueryStatement qs, Object JavaDoc value);
64
65     public abstract SQLExpression newSQLExpression(QueryStatement qs, TableExpression te, String JavaDoc fieldName);
66
67     public abstract SQLExpression newSQLExpression(QueryStatement qs, QueryStatement.QueryColumn qsc, String JavaDoc fieldName);
68 }
69
Popular Tags