From c7d0f58880d7abd80b8f572903f29636eb6c1181 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Mon, 10 Mar 2008 18:03:45 +0000 Subject: [PATCH] add convenience method for converting a rowMap to an array of row values git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@263 f203690c-595d-4dc9-a70b-905162fa7fd2 --- .../com/healthmarketscience/jackcess/Table.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/java/com/healthmarketscience/jackcess/Table.java b/src/java/com/healthmarketscience/jackcess/Table.java index 8d09f8b..eeea925 100644 --- a/src/java/com/healthmarketscience/jackcess/Table.java +++ b/src/java/com/healthmarketscience/jackcess/Table.java @@ -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 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 -- 2.39.5