KickJava   Java API By Example, From Geeks To Geeks.

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


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: JDOView.java,v 1.3 2003/02/25 06:55:15 jackknifebarber Exp $
9  */

10
11 package com.triactive.jdo.store;
12
13 import java.sql.Connection JavaDoc;
14 import java.sql.SQLException JavaDoc;
15 import java.util.List JavaDoc;
16 import javax.jdo.JDOFatalInternalException;
17
18
19 class JDOView extends View implements JDOTable
20 {
21     protected final int tableID;
22     protected final String JavaDoc javaName;
23
24     private int nextHiValue = -1;
25     private int nextLoValue = -1;
26
27
28     JDOView(TableMetadata tmd, StoreManager storeMgr)
29     {
30         super(tmd.tableName, storeMgr);
31
32         this.tableID = tmd.tableID;
33         this.javaName = tmd.javaName;
34     }
35
36
37     public void initialize()
38     {
39         assertIsUninitialized();
40
41         state = TABLE_STATE_INITIALIZED;
42     }
43
44
45     protected List JavaDoc getSQLCreateStatements()
46     {
47         throw new JDOFatalInternalException("Cannot create view for a generic JDOView object");
48     }
49
50
51     public int getTableID()
52     {
53         return tableID;
54     }
55
56
57     public String JavaDoc getJavaName()
58     {
59         return javaName;
60     }
61
62
63     public synchronized final OID newOID()
64     {
65         if (nextHiValue < 0)
66         {
67             nextHiValue = 0;
68             nextLoValue = 0;
69         }
70
71         OID id = new OID(tableID, nextHiValue, nextLoValue);
72
73         if (nextLoValue == OID.MAX_OBJIDLO)
74             nextHiValue = nextLoValue = -1;
75         else
76             ++nextLoValue;
77
78         return id;
79     }
80 }
81
Popular Tags