From: James Ahlborn Date: Mon, 10 Mar 2008 18:03:45 +0000 (+0000) Subject: add convenience method for converting a rowMap to an array of row values X-Git-Tag: rel_1_1_13~29 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c7d0f58880d7abd80b8f572903f29636eb6c1181;p=jackcess.git 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 --- 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