Revision 10627 trunk/libraries/libGDBMS/src/main/java/com/hardcode/gdbms/engine/data/db/FakeTransactionDataWare.java

View differences:

FakeTransactionDataWare.java
1 1
package com.hardcode.gdbms.engine.data.db;
2 2

  
3
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
4
import com.hardcode.gdbms.driver.exceptions.WriteDriverException;
3 5
import com.hardcode.gdbms.engine.data.InnerDBUtils;
4 6
import com.hardcode.gdbms.engine.data.driver.DBDriver;
5
import com.hardcode.gdbms.engine.data.driver.DriverException;
6 7
import com.hardcode.gdbms.engine.data.edition.DeletionInfo;
7 8
import com.hardcode.gdbms.engine.data.edition.EditionInfo;
8 9
import com.hardcode.gdbms.engine.data.edition.PKTable;
......
19 20
 */
20 21
public class FakeTransactionDataWare extends DBDataSourceAdapter
21 22
    implements DBDataWare {
22
    
23

  
23 24
    private FakeTransactionSupport ftSupport = new FakeTransactionSupport(this);
24
    
25
    public void start() throws DriverException {
25

  
26
    public void start() throws ReadDriverException {
26 27
        throw new RuntimeException("Invoke beginTrans in a DataWare");
27 28
    }
28 29

  
29
    public void stop() throws DriverException {
30
    public void stop() throws ReadDriverException {
30 31
        throw new RuntimeException("Invoke commitTrans/rollBackTrans in a DataWare");
31 32
    }
32 33

  
33 34
    /**
35
     * @throws WriteDriverException
34 36
     * @see com.hardcode.gdbms.engine.data.edition.DataWare#commitTrans()
35 37
     */
36
    public void commitTrans() throws DriverException {
38
    public void commitTrans() throws ReadDriverException, WriteDriverException {
37 39
        //Deleted records
38 40
        for (int i = 0; i < ftSupport.getPKTable().getDeletedPKCount(); i++) {
39 41
            /*
......
116 118
     *      int)
117 119
     */
118 120
    public Value getFieldValue(long rowIndex, int fieldId)
119
        throws DriverException {
121
        throws ReadDriverException {
120 122
        //If there is no transaction
121 123
        if (!ftSupport.isTransaction()) {
122 124
            return super.getFieldValue(rowIndex, fieldId);
......
137 139
    /**
138 140
     * @see com.hardcode.gdbms.engine.data.driver.ReadAccess#getRowCount()
139 141
     */
140
    public long getRowCount() throws DriverException {
142
    public long getRowCount() throws ReadDriverException {
141 143
        if (ftSupport.isTransaction()) {
142 144
            //If there is a transaction
143 145
            return ftSupport.getPKTable().getPKCount();
......
153 155
     * @param rowIndex index of the row to be retrieved
154 156
     *
155 157
     * @return Row values
156
     *
157
     * @throws DriverException if the operation fails
158
     * @throws ReadDriverException TODO
158 159
     */
159
    private Value[] getOriginalRow(long rowIndex) throws DriverException {
160
    private Value[] getOriginalRow(long rowIndex) throws ReadDriverException {
160 161
        Value[] ret = new Value[getFieldCount()];
161 162

  
162 163
        for (int i = 0; i < ret.length; i++) {
......
172 173
     * @param rowIndex index of the row to be read
173 174
     *
174 175
     * @return PK
175
     *
176
     * @throws DriverException If the operation fails
176
     * @throws ReadDriverException TODO
177 177
     */
178
    private ValueCollection getOriginalPKValue(long rowIndex) throws DriverException {
178
    private ValueCollection getOriginalPKValue(long rowIndex) throws ReadDriverException {
179 179
        int[] fieldsId = getPrimaryKeys();
180 180
        Value[] pks = new Value[fieldsId.length];
181 181

  
......
185 185

  
186 186
        return ValueFactory.createValue(pks);
187 187
    }
188
    public void beginTrans() throws DriverException {
188
    public void beginTrans() throws ReadDriverException {
189 189
        super.start();
190 190
        ftSupport.beginTrans();
191 191
    }
192
    public void deleteRow(long rowId) throws DriverException {
192
    public void deleteRow(long rowId) throws WriteDriverException, ReadDriverException {
193 193
        ftSupport.deleteRow(rowId);
194 194
    }
195
    public void insertEmptyRow(ValueCollection pk) throws DriverException {
195
    public void insertEmptyRow(ValueCollection pk) throws WriteDriverException {
196 196
        ftSupport.insertEmptyRow(pk);
197 197
    }
198
    public void insertFilledRow(Value[] values) throws DriverException {
198
    public void insertFilledRow(Value[] values) throws WriteDriverException, ReadDriverException {
199 199
        ftSupport.insertFilledRow(values);
200 200
    }
201
    public void rollBackTrans() throws DriverException {
201
    public void rollBackTrans() throws ReadDriverException, WriteDriverException {
202 202
        ftSupport.rollBackTrans();
203 203
        super.stop();
204 204
    }
205
    public void setFieldValue(long row, int fieldId, Value value) throws DriverException {
205
    public void setFieldValue(long row, int fieldId, Value value) throws WriteDriverException, ReadDriverException {
206 206
        ValueCollection pkValue = null;
207 207
        Value[] originalRow = null;
208 208
        if (row < super.getRowCount()){

Also available in: Unified diff