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: JDOView.java,v 1.3 2003/02/25 06:55:15 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: import java.sql.Connection;
14: import java.sql.SQLException;
15: import java.util.List;
16: import javax.jdo.JDOFatalInternalException;
17:
18: class JDOView extends View implements JDOTable {
19: protected final int tableID;
20: protected final String javaName;
21:
22: private int nextHiValue = -1;
23: private int nextLoValue = -1;
24:
25: JDOView(TableMetadata tmd, StoreManager storeMgr) {
26: super (tmd.tableName, storeMgr);
27:
28: this .tableID = tmd.tableID;
29: this .javaName = tmd.javaName;
30: }
31:
32: public void initialize() {
33: assertIsUninitialized();
34:
35: state = TABLE_STATE_INITIALIZED;
36: }
37:
38: protected List getSQLCreateStatements() {
39: throw new JDOFatalInternalException(
40: "Cannot create view for a generic JDOView object");
41: }
42:
43: public int getTableID() {
44: return tableID;
45: }
46:
47: public String getJavaName() {
48: return javaName;
49: }
50:
51: public synchronized final OID newOID() {
52: if (nextHiValue < 0) {
53: nextHiValue = 0;
54: nextLoValue = 0;
55: }
56:
57: OID id = new OID(tableID, nextHiValue, nextLoValue);
58:
59: if (nextLoValue == OID.MAX_OBJIDLO)
60: nextHiValue = nextLoValue = -1;
61: else
62: ++nextLoValue;
63:
64: return id;
65: }
66: }
|