]> source.dussan.org Git - jackcess.git/commitdiff
Fix reading of Properties with multiple value blocks (issue 96)
authorJames Ahlborn <jtahlborn@yahoo.com>
Fri, 16 Aug 2013 01:06:27 +0000 (01:06 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Fri, 16 Aug 2013 01:06:27 +0000 (01:06 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@780 f203690c-595d-4dc9-a70b-905162fa7fd2

src/changes/changes.xml
src/java/com/healthmarketscience/jackcess/impl/PropertyMapImpl.java
src/java/com/healthmarketscience/jackcess/impl/PropertyMaps.java

index 6886107c15bc0c7d8b621d62765acbc3d0ed2d5d..28c348f36d72bf81583d2c47f14ec3f8023e5854 100644 (file)
@@ -4,6 +4,11 @@
     <author email="javajedi@users.sf.net">Tim McCune</author>
   </properties>
   <body>
+    <release version="1.2.14.2" date="TBD">
+      <action dev="jahlborn" type="fix" system="SourceForge2" issue="96">
+        Fix reading of Properties with multiple value blocks.
+      </action>
+    </release>
     <release version="1.2.14.1" date="2013-08-11">
       <action dev="jahlborn" type="fix" system="SourceForge2Features"
               issue="25">
index e267c9bef222fcccfa9c8b0ebe4e7d75d5598ed4..7b2b91991b9c8d299f40a36147122b7fb59497b4 100644 (file)
@@ -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();
index 41468aaf0815a973e2b1bbf7520db5dc6b6a3f12..adc556bbdf1417ec3e987af4176e85e14932056a 100644 (file)
@@ -101,7 +101,8 @@ public class PropertyMaps implements Iterable<PropertyMapImpl>
    * 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<PropertyMapImpl> iterator() {
@@ -179,11 +180,8 @@ public class PropertyMaps implements Iterable<PropertyMapImpl>
 
         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);