01: /*
02: * Copyright 2002 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: JDOBaseTable.java,v 1.2 2002/10/17 21:00:56 pierreg0 Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: class JDOBaseTable extends BaseTable implements JDOTable {
14: protected final int tableID;
15: protected final String javaName;
16:
17: private int nextHiValue = -1;
18: private int nextLoValue = -1;
19:
20: JDOBaseTable(TableMetadata tmd, StoreManager storeMgr) {
21: super (tmd.tableName, storeMgr);
22:
23: this .tableID = tmd.tableID;
24: this .javaName = tmd.javaName;
25: }
26:
27: public void initialize() {
28: assertIsUninitialized();
29:
30: state = TABLE_STATE_INITIALIZED;
31: }
32:
33: public int getTableID() {
34: return tableID;
35: }
36:
37: public String getJavaName() {
38: return javaName;
39: }
40:
41: public synchronized final OID newOID() {
42: if (nextHiValue < 0) {
43: nextHiValue = storeMgr.getNextOIDHiValue(tableID);
44: nextLoValue = 0;
45: }
46:
47: OID id = new OID(tableID, nextHiValue, nextLoValue);
48:
49: if (nextLoValue == OID.MAX_OBJIDLO)
50: nextHiValue = nextLoValue = -1;
51: else
52: ++nextLoValue;
53:
54: return id;
55: }
56: }
|