]> source.dussan.org Git - jackcess.git/commitdiff
Allow ImportFilter and ExportFilter to return null from filterRow() to indicate that...
authorJames Ahlborn <jtahlborn@yahoo.com>
Fri, 25 Nov 2011 00:30:53 +0000 (00:30 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Fri, 25 Nov 2011 00:30:53 +0000 (00:30 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@597 f203690c-595d-4dc9-a70b-905162fa7fd2

src/changes/changes.xml
src/java/com/healthmarketscience/jackcess/ExportFilter.java
src/java/com/healthmarketscience/jackcess/ExportUtil.java
src/java/com/healthmarketscience/jackcess/ImportFilter.java
src/java/com/healthmarketscience/jackcess/ImportUtil.java

index 17dacb243851febf3dabba456b1a53f42dcc8d01..2fa0e8d7604fbfc31b02c7fae37246baa808905e 100644 (file)
         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">
index b9c6124e90ec01c299acaf6f43634ab5ecf0f36f..f145fd565c0391df71a90e1a362df2d42d7d2008 100644 (file)
@@ -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;
 
index 7876fb09739cc1a7e9afcf6fe0deabb18f5906f3..472d328c8b7f980009781069c5349078944e3d9b 100644 (file)
@@ -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++) {
index 6bcc6202c6e4f3aeb0a5087cd34e4ce2ab05204e..144b481059a39ee8e74254ea03d8ce30f6eb5f3e 100644 (file)
@@ -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;
index 0cd418e56da5de5cc190e1f866e64f614d6d2b41..b647570b89b20a5300d25cdf0ed0f1f16e96bb95 100644 (file)
@@ -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();