1 21 22 package org.apache.derbyTesting.unitTests.store; 23 24 import org.apache.derby.iapi.store.access.*; 25 26 import org.apache.derby.iapi.services.io.Storable; 27 28 import org.apache.derby.iapi.types.DataValueDescriptor; 29 30 import org.apache.derby.iapi.types.CloneableObject; 31 32 import org.apache.derby.iapi.types.SQLInteger; 33 34 import org.apache.derby.iapi.error.StandardException; 35 36 public class T_AccessRow 37 { 38 39 protected DataValueDescriptor column[]; 40 41 44 public T_AccessRow(int ncols) 45 { 46 column = new DataValueDescriptor[ncols]; 47 for (int i = 0; i < ncols; i++) 48 column[i] = new SQLInteger(0); 49 } 50 51 55 public T_AccessRow(int col0value, int col1value, int col2value) 56 { 57 column = new DataValueDescriptor[3]; 58 column[0] = new SQLInteger(col0value); 59 column[1] = new SQLInteger(col1value); 60 column[2] = new SQLInteger(col2value); 61 } 62 63 public DataValueDescriptor getCol(int colid) 64 { 65 if (colid >= column.length) 66 return null; 67 else 68 return column[colid]; 69 } 70 71 public void setCol(int colid, DataValueDescriptor val) 72 { 73 if (colid >= column.length) 74 realloc(colid + 1); 75 column[colid] = val; 76 } 77 78 public boolean equals(T_AccessRow other) throws StandardException 79 { 80 if (other == null) 81 return false; 82 if (other.column.length != this.column.length) 83 return false; 84 for (int i = 0; i < this.column.length; i++) 85 if (this.column[i].compare(other.column[i]) != 0) 86 return false; 87 return true; 88 } 89 90 public String toString() 91 { 92 String s = "{ "; 93 for (int i = 0; i < column.length; i++) 94 { 95 s += column[i].toString(); 96 if (i < (column.length - 1)) 97 s += ", "; 98 } 99 s += " }"; 100 return s; 101 } 102 103 protected void realloc(int ncols) 106 { 107 DataValueDescriptor newcol[] = new DataValueDescriptor[ncols]; 108 for (int i = 0; i < column.length; i++) 109 newcol[i] = column[i]; 110 column = newcol; 111 } 112 113 public Storable getStorableColumn(int colid) 114 { 115 return column[colid]; 116 } 117 118 public void setStorableColumn(int colid, Storable value) { 119 column[colid] = (DataValueDescriptor) value; 120 } 121 122 public int nColumns() 123 { 124 return column.length; 125 } 126 127 public DataValueDescriptor[] getRowArray() { 128 return column; 129 } 130 131 public DataValueDescriptor[] getRowArrayClone() { 132 DataValueDescriptor[] retval = new DataValueDescriptor[column.length]; 133 for (int index = 0; index < column.length; index++) 134 retval[index] = column[index].getClone(); 135 return retval; 136 } 137 } 138 139 140 141 142 | Popular Tags |