]> source.dussan.org Git - jackcess.git/commitdiff
further cleanup on row reading; fix recent issue of reading var len data twice
authorJames Ahlborn <jtahlborn@yahoo.com>
Tue, 8 Aug 2006 12:03:54 +0000 (12:03 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Tue, 8 Aug 2006 12:03:54 +0000 (12:03 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@99 f203690c-595d-4dc9-a70b-905162fa7fd2

src/java/com/healthmarketscience/jackcess/Table.java

index dd067ee10b3c7783772ef7c75e753993bac24153..70c3ddfbb5d8d0347b3535c7ce21aa2cf083f873 100644 (file)
@@ -265,35 +265,38 @@ public class Table
           value = new Boolean(!isNull);  //Boolean values are stored in the null mask
         } else {
           if(!isNull) {
+
+            // locate the column data bytes
+            int colDataPos = 0;
+            int colDataLen = 0;
             if (!column.isVariableLength()) 
             {
-              //Read in fixed length column data
-              columnData = new byte[column.getLength()];
-              _buffer.position(dataStart + column.getFixedDataOffset());
-              _buffer.get(columnData);
+              // find fixed length column data
+              colDataPos = dataStart + column.getFixedDataOffset();
+              colDataLen = column.getLength();
             } 
             else
             {
-              // read in var length column data
+              // find var length column data
               int varDataIdx = (rowVarColumnCount -
                                 column.getVarLenTableIndex() - 1);
               int varDataStart = varColumnOffsets[varDataIdx];
               int varDataEnd = ((varDataIdx > 0) ?
                                 varColumnOffsets[varDataIdx - 1] :
                                 lastVarColumnStart);
-              columnData = new byte[varDataEnd - varDataStart];
-              _buffer.position(_rowStart + varDataStart);
-              _buffer.get(columnData);
+              colDataPos = _rowStart + varDataStart;
+              colDataLen = varDataEnd - varDataStart;
             }
+
             // parse the column data
-            value = column.read(columnData);
-          }
-          if (!isNull && columnData != null)
-          {
-            //Add the value if we are interested in it.
+            columnData = new byte[colDataLen];
+            _buffer.position(colDataPos);
+            _buffer.get(columnData);
             value = column.read(columnData);
           }
         }
+
+        //Add the value to the row data
         rtn.put(column.getName(), value);
       }
     }