1 5 package org.h2.table; 6 7 import java.sql.SQLException ; 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 NAME = "SYSTEM_RANGE"; 22 private long min, max; 23 24 public RangeTable(Schema schema, long min, long max) throws SQLException { 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 getCreateSQL() { 35 return null; 36 } 37 38 public String getSQL() { 39 return NAME + "(" + min + ", " + max + ")"; 40 } 41 42 public void lock(Session session, boolean exclusive) throws SQLException { 43 } 44 45 public void close(Session session) throws SQLException { 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 indexName, int indexId, Column[] cols, IndexType indexType, int headPos, String comment) throws SQLException { 56 throw Message.getUnsupportedException(); 57 } 58 59 public void removeRow(Session session, Row row) throws SQLException { 60 throw Message.getUnsupportedException(); 61 } 62 63 public void addRow(Session session, Row row) throws SQLException { 64 throw Message.getUnsupportedException(); 65 } 66 67 public void checkSupportAlter() throws SQLException { 68 throw Message.getUnsupportedException(); 69 } 70 71 public void checkRename() throws SQLException { 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 { 84 return (int)(max - min); 86 } 87 88 public String getTableType() { 89 throw Message.getInternalError(); 90 } 91 92 public Index getScanIndex(Session session) throws SQLException { 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 { 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 |