From: James Ahlborn Date: Fri, 16 Aug 2013 01:06:27 +0000 (+0000) Subject: Fix reading of Properties with multiple value blocks (issue 96) X-Git-Tag: jackcess-2.0.0~7 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=790b943d773fc72a11089b6acaf17aa341f92ae4;p=jackcess.git Fix reading of Properties with multiple value blocks (issue 96) git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@780 f203690c-595d-4dc9-a70b-905162fa7fd2 --- 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/impl/PropertyMapImpl.java b/src/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java index e267c9b..7b2b919 100644 --- a/src/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java +++ b/src/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java @@ -88,6 +88,25 @@ public class PropertyMapImpl implements PropertyMap return _props.values().iterator(); } + public PropertyMapImpl merge(PropertyMapImpl opm) { + if(opm == null) { + return this; + } + + // merge into least map type + PropertyMapImpl dest = opm; + PropertyMapImpl 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/impl/PropertyMaps.java b/src/java/com/healthmarketscience/jackcess/impl/PropertyMaps.java index 41468aa..adc556b 100644 --- a/src/java/com/healthmarketscience/jackcess/impl/PropertyMaps.java +++ b/src/java/com/healthmarketscience/jackcess/impl/PropertyMaps.java @@ -101,7 +101,8 @@ public class PropertyMaps implements Iterable * Adds the given PropertyMap to this group. */ public void put(PropertyMapImpl map) { - _maps.put(DatabaseImpl.toLookupName(map.getName()), map); + String mapName = DatabaseImpl.toLookupName(map.getName()); + _maps.put(mapName, map.merge(_maps.get(mapName))); } public Iterator iterator() { @@ -179,11 +180,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);