1 package com.daffodilwoods.daffodildb.server.sql99.dml; 2 import java.util.*; 3 import java.io.*; 4 import com.daffodilwoods.daffodildb.server.datadictionarysystem._ColumnCharacteristics; 5 import com.daffodilwoods.database.resource.*; 6 import com.daffodilwoods.database.utility.P; 7 8 public class DMLResult implements Externalizable{ 9 private Object [][] autoIncrementColumnValues; 10 public int rowsEffected; 11 private ArrayList values; 12 public boolean isInitialised = false; 13 private _ColumnCharacteristics cc ; 14 public DMLResult(){ 15 values = new ArrayList(); 16 } 17 18 public void setColumnCharacteristics(_ColumnCharacteristics cc0) throws 19 DException { 20 cc = cc0; 21 } 22 23 public void addValue(Object values0){ 24 values.add(values0); 25 } 26 27 28 public void isInitialised(boolean flag){ 29 isInitialised = flag; 30 } 31 32 public Object [][] getAutoIncrementValues() throws DException{ 33 if(autoIncrementColumnValues == null) 34 autoIncrementColumnValues = convertTo2dArray(); 35 return autoIncrementColumnValues; 36 } 37 38 private Object [][] convertTo2dArray() throws DException{ 39 Object [][] columnValues = new Object [values.size()][cc.getColumnCount()]; 40 for (int i = 0; i < values.size(); i++) { 41 Object [] temp = (Object []) values.get(i); 42 for (int j = 0; j < cc.getColumnCount(); j++) { 43 columnValues[i][j] = temp[j]; 44 } 45 } 46 return columnValues; 47 } 48 public void setrowsEffected(int rows){ 49 rowsEffected = rows; 50 } 51 52 public int getrowsEffected(){ 53 return rowsEffected; 54 } 55 56 57 public _ColumnCharacteristics getColumnCharacteristics(){ 58 return cc; 59 } 60 61 public void writeExternal(ObjectOutput oo) throws IOException{ 62 oo.writeInt(rowsEffected); 63 try { 64 autoIncrementColumnValues = convertTo2dArray(); 65 } 66 catch (DException ex) { 67 throw new IOException("Problem in reading data"); 68 } 69 oo.writeObject(autoIncrementColumnValues); 70 oo.writeBoolean(isInitialised); 71 oo.writeObject(cc); 72 } 73 74 public void readExternal(ObjectInput oi) throws IOException,ClassNotFoundException { 75 rowsEffected = oi.readInt(); 76 autoIncrementColumnValues = (Object [][])oi.readObject(); 77 isInitialised = oi.readBoolean(); 78 cc = (_ColumnCharacteristics)oi.readObject(); 79 } 80 81 } 82 | Popular Tags |