aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2011-11-25 00:30:53 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2011-11-25 00:30:53 +0000
commit2661755b796d99fb8331393c075c9f9309a687cd (patch)
treea5759f617862668a9a79495a94e0ea1c8a6896c2
parent329d12ecc1367db2fad16c3ea953884c5c78c568 (diff)
downloadjackcess-2661755b796d99fb8331393c075c9f9309a687cd.tar.gz
jackcess-2661755b796d99fb8331393c075c9f9309a687cd.zip
Allow ImportFilter and ExportFilter to return null from filterRow() to indicate that a row should be skipped.
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@597 f203690c-595d-4dc9-a70b-905162fa7fd2
-rw-r--r--src/changes/changes.xml4
-rw-r--r--src/java/com/healthmarketscience/jackcess/ExportFilter.java3
-rw-r--r--src/java/com/healthmarketscience/jackcess/ExportUtil.java3
-rw-r--r--src/java/com/healthmarketscience/jackcess/ImportFilter.java3
-rw-r--r--src/java/com/healthmarketscience/jackcess/ImportUtil.java12
5 files changed, 21 insertions, 4 deletions
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 17dacb2..2fa0e8d 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -20,6 +20,10 @@
Reuse previously written memo/ole values when updating other values in
a row in order to reduce unnecessary data duplication.
</action>
+ <action dev="jahlborn" type="update">
+ Allow ImportFilter and ExportFilter to return null from filterRow() to
+ indicate that a row should be skipped.
+ </action>
</release>
<release version="1.2.5" date="2011-10-19">
<action dev="jahlborn" type="update">
diff --git a/src/java/com/healthmarketscience/jackcess/ExportFilter.java b/src/java/com/healthmarketscience/jackcess/ExportFilter.java
index b9c6124..f145fd5 100644
--- a/src/java/com/healthmarketscience/jackcess/ExportFilter.java
+++ b/src/java/com/healthmarketscience/jackcess/ExportFilter.java
@@ -54,7 +54,8 @@ public interface ExportFilter {
* @param row
* the row data as determined by the import code, may be directly
* modified
- * @return the row data as it should be written to the import table
+ * @return the row data as it should be written to the import table. if
+ * {@code null}, the row will be skipped
*/
public Object[] filterRow(Object[] row) throws IOException;
diff --git a/src/java/com/healthmarketscience/jackcess/ExportUtil.java b/src/java/com/healthmarketscience/jackcess/ExportUtil.java
index 7876fb0..472d328 100644
--- a/src/java/com/healthmarketscience/jackcess/ExportUtil.java
+++ b/src/java/com/healthmarketscience/jackcess/ExportUtil.java
@@ -332,6 +332,9 @@ public class ExportUtil {
// apply filter
Object[] rowData = filter.filterRow(unfilteredRowData);
+ if(rowData == null) {
+ continue;
+ }
// print row
for (int i = 0; i < columns.size(); i++) {
diff --git a/src/java/com/healthmarketscience/jackcess/ImportFilter.java b/src/java/com/healthmarketscience/jackcess/ImportFilter.java
index 6bcc620..144b481 100644
--- a/src/java/com/healthmarketscience/jackcess/ImportFilter.java
+++ b/src/java/com/healthmarketscience/jackcess/ImportFilter.java
@@ -56,7 +56,8 @@ public interface ImportFilter {
* The desired values for the row.
* @param row the row data as determined by the import code, may be directly
* modified
- * @return the row data as it should be written to the import table
+ * @return the row data as it should be written to the import table. if
+ * {@code null}, the row will be skipped
*/
public Object[] filterRow(Object[] row)
throws SQLException, IOException;
diff --git a/src/java/com/healthmarketscience/jackcess/ImportUtil.java b/src/java/com/healthmarketscience/jackcess/ImportUtil.java
index 0cd418e..b647570 100644
--- a/src/java/com/healthmarketscience/jackcess/ImportUtil.java
+++ b/src/java/com/healthmarketscience/jackcess/ImportUtil.java
@@ -164,7 +164,11 @@ public class ImportUtil
for (int i = 0; i < row.length; i++) {
row[i] = source.getObject(i + 1);
}
- rows.add(filter.filterRow(row));
+ row = filter.filterRow(row);
+ if(row == null) {
+ continue;
+ }
+ rows.add(row);
if (rows.size() == COPY_TABLE_BATCH_SIZE) {
table.addRows(rows);
rows.clear();
@@ -385,7 +389,11 @@ public class ImportUtil
while ((line = in.readLine()) != null)
{
Object[] data = splitLine(line, delimPat, quote, in, numColumns);
- rows.add(filter.filterRow(data));
+ data = filter.filterRow(data);
+ if(data == null) {
+ continue;
+ }
+ rows.add(data);
if (rows.size() == COPY_TABLE_BATCH_SIZE) {
table.addRows(rows);
rows.clear();