1 24 25 package com.mckoi.database; 26 27 import com.mckoi.database.global.SQLTypes; 28 29 38 39 abstract class GTDataSource implements MutableTableDataSource { 40 41 44 private TransactionSystem system; 45 46 47 50 public GTDataSource(TransactionSystem system) { 51 this.system = system; 52 } 53 54 59 protected TObject columnValue(int column, Object ob) { 60 TType type = getDataTableDef().columnAt(column).getTType(); 61 return new TObject(type, ob); 62 } 63 64 66 public TransactionSystem getSystem() { 67 return system; 68 } 69 70 public abstract DataTableDef getDataTableDef(); 71 72 public abstract int getRowCount(); 73 74 public RowEnumeration rowEnumeration() { 75 return new SimpleRowEnumeration(getRowCount()); 76 } 77 78 public SelectableScheme getColumnScheme(int column) { 79 return new BlindSearch(this, column); 80 } 81 82 public abstract TObject getCellContents(final int column, final int row); 83 84 86 public int addRow(RowData row_data) { 87 throw new RuntimeException ("Functionality not available."); 88 } 89 90 public void removeRow(int row_index) { 91 throw new RuntimeException ("Functionality not available."); 92 } 93 94 public int updateRow(int row_index, RowData row_data) { 95 throw new RuntimeException ("Functionality not available."); 96 } 97 98 public MasterTableJournal getJournal() { 99 throw new RuntimeException ("Functionality not available."); 100 } 101 102 public void flushIndexChanges() { 103 throw new RuntimeException ("Functionality not available."); 104 } 105 106 public void constraintIntegrityCheck() { 107 throw new RuntimeException ("Functionality not available."); 108 } 109 110 public void dispose() { 111 } 112 113 public void addRootLock() { 114 } 116 117 public void removeRootLock() { 118 } 120 121 123 127 protected static DataTableColumnDef stringColumn(String name) { 128 DataTableColumnDef column = new DataTableColumnDef(); 129 column.setName(name); 130 column.setNotNull(true); 131 column.setSQLType(SQLTypes.VARCHAR); 132 column.setSize(Integer.MAX_VALUE); 133 column.setScale(-1); 134 column.setIndexScheme("BlindSearch"); 135 column.initTTypeInfo(); 136 return column; 137 } 138 139 protected static DataTableColumnDef booleanColumn(String name) { 140 DataTableColumnDef column = new DataTableColumnDef(); 141 column.setName(name); 142 column.setNotNull(true); 143 column.setSQLType(SQLTypes.BIT); 144 column.setSize(-1); 145 column.setScale(-1); 146 column.setIndexScheme("BlindSearch"); 147 column.initTTypeInfo(); 148 return column; 149 } 150 151 protected static DataTableColumnDef numericColumn(String name) { 152 DataTableColumnDef column = new DataTableColumnDef(); 153 column.setName(name); 154 column.setNotNull(true); 155 column.setSQLType(SQLTypes.NUMERIC); 156 column.setSize(-1); 157 column.setScale(-1); 158 column.setIndexScheme("BlindSearch"); 159 column.initTTypeInfo(); 160 return column; 161 } 162 163 protected static DataTableColumnDef dateColumn(String name) { 164 DataTableColumnDef column = new DataTableColumnDef(); 165 column.setName(name); 166 column.setNotNull(true); 167 column.setSQLType(SQLTypes.TIMESTAMP); 168 column.setSize(-1); 169 column.setScale(-1); 170 column.setIndexScheme("BlindSearch"); 171 column.initTTypeInfo(); 172 return column; 173 } 174 175 } 176 | Popular Tags |