summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2011-11-10 03:33:02 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2011-11-10 03:33:02 +0000
commit84f12a0fbe85d05dc6d2c67ae937633e9fe36609 (patch)
tree0d7564449631ff2fadfd33841adf661fddde6122 /src
parentb3c0419b7e7e0a50fdd94745b62605e223279e2d (diff)
downloadjackcess-84f12a0fbe85d05dc6d2c67ae937633e9fe36609.tar.gz
jackcess-84f12a0fbe85d05dc6d2c67ae937633e9fe36609.zip
Fix problem with reading row from table with deleted/added columns. (fixes 3435774)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@591 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src')
-rw-r--r--src/changes/changes.xml3
-rw-r--r--src/java/com/healthmarketscience/jackcess/NullMask.java25
2 files changed, 20 insertions, 8 deletions
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index a2a9ae6..df41751 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -13,6 +13,9 @@
Fix problem with creating tables with indexes where ms access could
not open the created table.
</action>
+ <action dev="jahlborn" type="fix" issue="3435774">
+ Fix problem with reading row from table with deleted/added columns.
+ </action>
</release>
<release version="1.2.5" date="2011-10-19">
<action dev="jahlborn" type="update">
diff --git a/src/java/com/healthmarketscience/jackcess/NullMask.java b/src/java/com/healthmarketscience/jackcess/NullMask.java
index dd5d959..5be5218 100644
--- a/src/java/com/healthmarketscience/jackcess/NullMask.java
+++ b/src/java/com/healthmarketscience/jackcess/NullMask.java
@@ -36,18 +36,21 @@ import java.nio.ByteBuffer;
*/
public class NullMask {
+ /** num row columns */
+ private final int _columnCount;
/** The actual bitmask */
- private byte[] _mask;
+ private final byte[] _mask;
/**
* @param columnCount Number of columns in the row that this mask will be
* used for
*/
public NullMask(int columnCount) {
+ _columnCount = columnCount;
// we leave everything initially marked as null so that we don't need to
// do anything for deleted columns (we only need to mark as non-null
// valid columns for which we actually have values).
- _mask = new byte[(columnCount + 7) / 8];
+ _mask = new byte[(_columnCount + 7) / 8];
}
/**
@@ -72,14 +75,13 @@ public class NullMask {
*/
public boolean isNull(Column column) {
int columnNumber = column.getColumnNumber();
- int maskIndex = columnNumber / 8;
// if new columns were added to the table, old null masks may not include
// them (meaning the field is null)
- if(maskIndex >= _mask.length) {
+ if(columnNumber >= _columnCount) {
// it's null
return true;
}
- return (_mask[maskIndex] & (byte) (1 << (columnNumber % 8))) == 0;
+ return (_mask[byteIndex(columnNumber)] & bitMask(columnNumber)) == 0;
}
/**
@@ -89,8 +91,8 @@ public class NullMask {
*/
public void markNotNull(Column column) {
int columnNumber = column.getColumnNumber();
- int maskIndex = columnNumber / 8;
- _mask[maskIndex] = (byte) (_mask[maskIndex] | (byte) (1 << (columnNumber % 8)));
+ int maskIndex = byteIndex(columnNumber);
+ _mask[maskIndex] = (byte) (_mask[maskIndex] | bitMask(columnNumber));
}
/**
@@ -99,5 +101,12 @@ public class NullMask {
public int byteSize() {
return _mask.length;
}
-
+
+ private static int byteIndex(int columnNumber) {
+ return columnNumber / 8;
+ }
+
+ private static byte bitMask(int columnNumber) {
+ return (byte) (1 << (columnNumber % 8));
+ }
}