KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > table > RangeTable


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.table;
6
7 import java.sql.SQLException JavaDoc;
8
9 import org.h2.engine.Session;
10 import org.h2.index.Index;
11 import org.h2.index.IndexType;
12 import org.h2.index.RangeIndex;
13 import org.h2.message.Message;
14 import org.h2.result.Row;
15 import org.h2.schema.Schema;
16 import org.h2.util.ObjectArray;
17 import org.h2.value.Value;
18
19 public class RangeTable extends Table {
20     
21     public static final String JavaDoc NAME = "SYSTEM_RANGE";
22     private long min, max;
23
24     public RangeTable(Schema schema, long min, long max) throws SQLException JavaDoc {
25         super(schema, 0, NAME, true);
26         Column[] cols = new Column[]{
27                 new Column("X", Value.LONG, 0, 0)
28         };
29         this.min = min;
30         this.max = max;
31         setColumns(cols);
32     }
33     
34     public String JavaDoc getCreateSQL() {
35         return null;
36     }
37     
38     public String JavaDoc getSQL() {
39         return NAME + "(" + min + ", " + max + ")";
40     }
41
42     public void lock(Session session, boolean exclusive) throws SQLException JavaDoc {
43     }
44
45     public void close(Session session) throws SQLException JavaDoc {
46     }
47
48     public void unlock(Session s) {
49     }
50     
51     public boolean isLockedExclusively() {
52         return false;
53     }
54
55     public Index addIndex(Session session, String JavaDoc indexName, int indexId, Column[] cols, IndexType indexType, int headPos, String JavaDoc comment) throws SQLException JavaDoc {
56         throw Message.getUnsupportedException();
57     }
58
59     public void removeRow(Session session, Row row) throws SQLException JavaDoc {
60         throw Message.getUnsupportedException();
61     }
62
63     public void addRow(Session session, Row row) throws SQLException JavaDoc {
64         throw Message.getUnsupportedException();
65     }
66
67     public void checkSupportAlter() throws SQLException JavaDoc {
68         throw Message.getUnsupportedException();
69     }
70
71     public void checkRename() throws SQLException JavaDoc {
72         throw Message.getUnsupportedException();
73     }
74
75     public boolean canGetRowCount() {
76         return true;
77     }
78     
79     public boolean canDrop() {
80         return false;
81     }
82
83     public int getRowCount() throws SQLException JavaDoc {
84         // TODO document system_range: count(*) for system_range could be wrong (long to int conversion)
85
return (int)(max - min);
86     }
87
88     public String JavaDoc getTableType() {
89         throw Message.getInternalError();
90     }
91
92     public Index getScanIndex(Session session) throws SQLException JavaDoc {
93         return new RangeIndex(this, columns, min, max);
94     }
95
96     public ObjectArray getIndexes() {
97         return null;
98     }
99
100     public void truncate(Session session) throws SQLException JavaDoc {
101         throw Message.getUnsupportedException();
102     }
103
104     public long getMaxDataModificationId() {
105         return 0;
106     }
107
108     public Index getUniqueIndex() {
109         return null;
110     }
111
112 }
113
Popular Tags