From 1eb7bb4bc2bb6569ee52e4c43bf46f4d48243deb Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Thu, 15 Aug 2013 12:58:11 +0000 Subject: [PATCH] Fix reading of Properties with multiple value blocks (issue 96) git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/jackcess-1.2.14@779 f203690c-595d-4dc9-a70b-905162fa7fd2 --- src/changes/changes.xml | 5 +++++ .../jackcess/PropertyMap.java | 18 ++++++++++++++++++ .../jackcess/PropertyMaps.java | 8 +++----- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 6886107..28c348f 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -4,6 +4,11 @@ Tim McCune + + + Fix reading of Properties with multiple value blocks. + + diff --git a/src/java/com/healthmarketscience/jackcess/PropertyMap.java b/src/java/com/healthmarketscience/jackcess/PropertyMap.java index dc25dc0..57b3775 100644 --- a/src/java/com/healthmarketscience/jackcess/PropertyMap.java +++ b/src/java/com/healthmarketscience/jackcess/PropertyMap.java @@ -112,6 +112,24 @@ public class PropertyMap implements Iterable return _props.values().iterator(); } + PropertyMap merge(PropertyMap opm) { + if(opm == null) { + return this; + } + + // merge into least map type + PropertyMap dest = opm; + PropertyMap src = this; + if(dest._mapType < src._mapType) { + dest = this; + src = opm; + } + + dest._props.putAll(src._props); + + return dest; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/src/java/com/healthmarketscience/jackcess/PropertyMaps.java b/src/java/com/healthmarketscience/jackcess/PropertyMaps.java index 51853ee..3ffd908 100644 --- a/src/java/com/healthmarketscience/jackcess/PropertyMaps.java +++ b/src/java/com/healthmarketscience/jackcess/PropertyMaps.java @@ -98,7 +98,8 @@ public class PropertyMaps implements Iterable * Adds the given PropertyMap to this group. */ public void put(PropertyMap map) { - _maps.put(Database.toLookupName(map.getName()), map); + String mapName = Database.toLookupName(map.getName()); + _maps.put(mapName, map.merge(_maps.get(mapName))); } public Iterator iterator() { @@ -176,11 +177,8 @@ public class PropertyMaps implements Iterable if(type == PROPERTY_NAME_LIST) { propNames = readPropertyNames(bbBlock); - } else if((type == DEFAULT_PROPERTY_VALUE_LIST) || - (type == COLUMN_PROPERTY_VALUE_LIST)) { - maps.put(readPropertyValues(bbBlock, propNames, type)); } else { - throw new IOException("Unknown property block type " + type); + maps.put(readPropertyValues(bbBlock, propNames, type)); } bb.position(endPos); -- 2.39.5