]> source.dussan.org Git - jackcess.git/commitdiff
minor refactor
authorJames Ahlborn <jtahlborn@yahoo.com>
Wed, 23 Dec 2009 01:50:52 +0000 (01:50 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Wed, 23 Dec 2009 01:50:52 +0000 (01:50 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@423 f203690c-595d-4dc9-a70b-905162fa7fd2

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

index f17fd301d397c00f36307316054c31900ef1baaf..0eb9f9c2fe285c429ae855dfe9092176c899bd13 100644 (file)
@@ -1140,14 +1140,7 @@ public class Table
    * 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;
+    return asRow(rowMap, null);
   }
   
   /**
@@ -1155,8 +1148,18 @@ public class Table
    * appropriate for a call to {@link #updateCurrentRow(Object...)}.
    */
   public Object[] asUpdateRow(Map<String,Object> rowMap) {
+    return asRow(rowMap, Column.KEEP_VALUE);
+  }
+
+  /**
+   * Converts a map of columnName -> columnValue to an array of row values.
+   */
+  private Object[] asRow(Map<String,Object> rowMap, Object defaultValue)
+  {
     Object[] row = new Object[_columns.size()];
-    Arrays.fill(row, Column.KEEP_VALUE);
+    if(defaultValue != null) {
+      Arrays.fill(row, defaultValue);
+    }
     if(rowMap == null) {
       return row;
     }