From: James Ahlborn Date: Sat, 23 Sep 2006 18:21:19 +0000 (+0000) Subject: create method for interpreting boolean values X-Git-Tag: rel_1_1_7~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=78c26cb7fe9a4e20b7e6dfca3e375a3c0c927134;p=jackcess.git create method for interpreting boolean values git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@119 f203690c-595d-4dc9-a70b-905162fa7fd2 --- diff --git a/src/java/com/healthmarketscience/jackcess/Column.java b/src/java/com/healthmarketscience/jackcess/Column.java index 3fb63db..5237c2b 100644 --- a/src/java/com/healthmarketscience/jackcess/Column.java +++ b/src/java/com/healthmarketscience/jackcess/Column.java @@ -1006,6 +1006,13 @@ public class Column implements Comparable { return value.toString(); } } + + /** + * Interpret a boolean value (null == false) + */ + public static boolean toBooleanValue(Object obj) { + return ((obj != null) && ((Boolean)obj).booleanValue()); + } /** * Swaps the bytes of the given numeric in place. @@ -1033,5 +1040,5 @@ public class Column implements Comparable { } return obj; } - + } diff --git a/src/java/com/healthmarketscience/jackcess/Table.java b/src/java/com/healthmarketscience/jackcess/Table.java index 25008d8..ba65ab7 100644 --- a/src/java/com/healthmarketscience/jackcess/Table.java +++ b/src/java/com/healthmarketscience/jackcess/Table.java @@ -793,11 +793,9 @@ public class Table buffer.put(col.write(row.get(index), 0)); } if (col.getType() == DataType.BOOLEAN) { - if (row.get(index) != null) { - if (!((Boolean) row.get(index)).booleanValue()) { - //Booleans are stored in the null mask - nullMask.markNull(index); - } + if(!Column.toBooleanValue(row.get(index))) { + //Booleans are stored in the null mask + nullMask.markNull(index); } } else if (row.get(index) == null) { nullMask.markNull(index);