KickJava   Java API By Example, From Geeks To Geeks.

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


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: JDOBaseTable.java,v 1.2 2002/10/17 21:00:56 pierreg0 Exp $
9  */

10
11 package com.triactive.jdo.store;
12
13
14 class JDOBaseTable extends BaseTable implements JDOTable
15 {
16     protected final int tableID;
17     protected final String JavaDoc javaName;
18
19     private int nextHiValue = -1;
20     private int nextLoValue = -1;
21
22
23     JDOBaseTable(TableMetadata tmd, StoreManager storeMgr)
24     {
25         super(tmd.tableName, storeMgr);
26
27         this.tableID = tmd.tableID;
28         this.javaName = tmd.javaName;
29     }
30
31
32     public void initialize()
33     {
34         assertIsUninitialized();
35
36         state = TABLE_STATE_INITIALIZED;
37     }
38
39
40     public int getTableID()
41     {
42         return tableID;
43     }
44
45
46     public String JavaDoc getJavaName()
47     {
48         return javaName;
49     }
50
51
52     public synchronized final OID newOID()
53     {
54         if (nextHiValue < 0)
55         {
56             nextHiValue = storeMgr.getNextOIDHiValue(tableID);
57             nextLoValue = 0;
58         }
59
60         OID id = new OID(tableID, nextHiValue, nextLoValue);
61
62         if (nextLoValue == OID.MAX_OBJIDLO)
63             nextHiValue = nextLoValue = -1;
64         else
65             ++nextLoValue;
66
67         return id;
68     }
69 }
70
Popular Tags