1 30 31 32 package org.hsqldb; 33 34 import java.io.IOException ; 35 36 import org.hsqldb.rowio.RowInputInterface; 37 import org.hsqldb.rowio.RowOutputInterface; 38 39 42 48 class CachedDataRow extends CachedRow { 49 50 53 CachedDataRow(Table t, Object [] o) throws HsqlException { 54 55 super(t, o); 56 57 hasDataChanged = true; 58 } 59 60 64 CachedDataRow(Table t, 65 RowInputInterface in) throws IOException , HsqlException { 66 67 tTable = t; 68 iPos = in.getPos(); 69 storageSize = in.getSize(); 70 oData = in.readData(tTable.getColumnTypes()); 71 hasDataChanged = false; 72 } 73 74 78 Row getUpdatedRow() throws HsqlException { 79 return tTable.getRow(iPos, nPrimaryNode); 80 } 81 82 86 void setNewNodes() { 87 88 int index = tTable.getIndexCount(); 89 90 nPrimaryNode = Node.newNode(this, 0, tTable); 91 92 Node n = nPrimaryNode; 93 94 for (int i = 1; i < index; i++) { 95 n.nNext = Node.newNode(this, i, tTable); 96 n = n.nNext; 97 } 98 } 99 100 105 void setPrimaryNode(Node primary) { 106 nPrimaryNode = primary; 107 } 108 109 112 public int getRealSize(RowOutputInterface out) { 113 return out.getSize(this); 114 } 115 116 121 public void write(RowOutputInterface out) { 122 123 out.writeSize(storageSize); 124 out.writeData(oData, tTable); 125 out.writeEnd(); 126 127 hasDataChanged = false; 128 } 129 130 public boolean hasChanged() { 131 return hasDataChanged; 132 } 133 134 140 public void setPos(int pos) { 141 142 iPos = pos; 143 144 Node n = nPrimaryNode; 145 146 while (n != null) { 147 ((PointerNode) n).iData = iPos; 148 n = n.nNext; 149 } 150 } 151 152 161 public boolean equals(Object obj) { 162 163 if (obj == this) { 164 return true; 165 } 166 167 if (obj instanceof CachedDataRow) { 168 return ((CachedDataRow) obj).iPos == iPos 169 && ((CachedDataRow) obj).tTable == tTable; 170 } 171 172 return false; 173 } 174 } 175 | Popular Tags |