KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 2002 (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: FieldTable.java,v 1.3 2003/05/24 03:33:13 jackknifebarber Exp $
9  */

10
11 package com.triactive.jdo.store;
12
13 import com.triactive.jdo.ClassNotPersistenceCapableException;
14 import com.triactive.jdo.model.FieldMetaData;
15 import java.lang.reflect.Field JavaDoc;
16 import javax.jdo.JDOFatalInternalException;
17 import javax.jdo.JDOUnsupportedOptionException;
18
19
20 abstract class FieldTable extends JDOBaseTable
21 {
22     protected final FieldMetaData fmd;
23     protected final Field JavaDoc field;
24     protected final Class JavaDoc ownerType;
25
26     protected FieldTable(TableMetadata tmd, FieldMetaData fmd, StoreManager storeMgr)
27     {
28         super(tmd, storeMgr);
29
30         this.fmd = fmd;
31         this.field = fmd.getField();
32         this.ownerType = fmd.getClassMetaData().getPCClass();
33
34         switch (fmd.getPersistenceModifier())
35         {
36             case FieldMetaData.PERSISTENCE_MODIFIER_NONE:
37             default:
38                 throw new JDOFatalInternalException("Invalid persistence modifier on field " + fmd.getName());
39
40             case FieldMetaData.PERSISTENCE_MODIFIER_TRANSACTIONAL:
41                 break;
42
43             case FieldMetaData.PERSISTENCE_MODIFIER_PERSISTENT:
44                 break;
45         }
46     }
47
48
49     public Field JavaDoc getField()
50     {
51         return field;
52     }
53
54
55     protected SQLIdentifier getBaseColumnNameForType(Class JavaDoc c)
56     {
57         ClassBaseTable cbt;
58
59         try
60         {
61             cbt = storeMgr.getClassBaseTable(c);
62         }
63         catch (ClassNotPersistenceCapableException e)
64         {
65             cbt = null;
66         }
67
68         if (cbt == null)
69         {
70             String JavaDoc javaName = c.getName();
71             javaName = javaName.substring(javaName.lastIndexOf('.') + 1);
72             return new ColumnIdentifier(dba, javaName);
73         }
74         else
75             return cbt.getName();
76     }
77 }
78
Popular Tags