]> source.dussan.org Git - jackcess.git/commitdiff
add convenience method for converting a rowMap to an array of row values
authorJames Ahlborn <jtahlborn@yahoo.com>
Mon, 10 Mar 2008 18:03:45 +0000 (18:03 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Mon, 10 Mar 2008 18:03:45 +0000 (18:03 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@263 f203690c-595d-4dc9-a70b-905162fa7fd2

src/java/com/healthmarketscience/jackcess/Table.java

index 8d09f8b8f952d504757c7a35eb1b035a4bb63175..eeea925f01e6931a2a110c4cfc34ae3d3768ebb1 100644 (file)
@@ -1039,6 +1039,21 @@ public class Table
     // up-to-date
     ++_modCount;
   }
+
+  /**
+   * Converts a map of columnName -> columnValue to an array of row values
+   * appropriate for a call to {@link #addRow(Object...)}.
+   */
+  public Object[] asRow(Map<String,Object> rowMap) {
+    Object[] row = new Object[_columns.size()];
+    if(rowMap == null) {
+      return row;
+    }
+    for(Column col : _columns) {
+      row[col.getColumnIndex()] = rowMap.get(col.getName());
+    }
+    return row;
+  }
   
   /**
    * Add a single row to this table and write it to disk