From 9726035fbe9f3d606b45e4254fffe50c315463f9 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Thu, 3 Aug 2006 13:38:02 +0000 Subject: [PATCH] fix handling of skipped rows git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@83 f203690c-595d-4dc9-a70b-905162fa7fd2 --- .../healthmarketscience/jackcess/Table.java | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/java/com/healthmarketscience/jackcess/Table.java b/src/java/com/healthmarketscience/jackcess/Table.java index 854a6b4..c51798c 100644 --- a/src/java/com/healthmarketscience/jackcess/Table.java +++ b/src/java/com/healthmarketscience/jackcess/Table.java @@ -49,6 +49,8 @@ import org.apache.commons.logging.LogFactory; public class Table { private static final Log LOG = LogFactory.getLog(Table.class); + + private static final short OFFSET_MASK = (short)0x1FFF; /** Table type code for system tables */ public static final byte TYPE_SYSTEM = 0x53; @@ -316,16 +318,19 @@ public class Table { // code follows the actual code, which disagrees with the HACKING doc boolean deletedRow = ((_rowStart & 0x4000) != 0); boolean overflowRow = ((_rowStart & 0x8000) != 0); + + _rowStart = (short)(_rowStart & OFFSET_MASK); if (deletedRow) { // Deleted row. Skip. + _lastRowStart = _rowStart; return positionAtNextRow(); } else if (overflowRow) { // Overflow page. // FIXME - Currently skipping this. Need to figure out how to read it. - _buffer.position(_rowStart - 0x4000); - int overflow = _buffer.getInt(); - _lastRowStart -= 4; +// _buffer.position(_rowStart); +// int overflow = _buffer.getInt(); + _lastRowStart = _rowStart; return positionAtNextRow(); } else { _buffer.position(_rowStart); @@ -692,5 +697,23 @@ public class Table { } return rtn.toString(); } + + public static short findRowStart(ByteBuffer buffer, int rowNum, + JetFormat format) + { + return (short)(buffer.getShort(format.OFFSET_ROW_START + + (format.SIZE_ROW_LOCATION * rowNum)) + & OFFSET_MASK); + } + + public static short findRowEnd(ByteBuffer buffer, int rowNum, + JetFormat format) + { + return (short)((rowNum == 0) ? + format.PAGE_SIZE : + (buffer.getShort(format.OFFSET_ROW_START + + (format.SIZE_ROW_LOCATION * (rowNum - 1))) + & OFFSET_MASK)); + } } -- 2.39.5