diff flys-artifacts/src/main/java/de/intevation/flys/exports/OutputHelper.java @ 4255:670e98f5a441

Fixed leak while merging facets. The ThemeList that is used by OutputHelper to sort the Facets for an Output now uses a list to store the ManagedFacets. The correct order is made up by sorting the List using Collections.sort() function of the Java JDK. Therfore, the ManagedFacet class implements the Comparable interface. The return value of its compareTo(other) method depends on the value of the 'position' field.
author Ingo Weinzierl <weinzierl.ingo@googlemail.com>
date Thu, 25 Oct 2012 14:01:46 +0200
parents 8e66293c5369
children e8a4d2fd25cc
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/OutputHelper.java	Thu Oct 25 13:42:21 2012 +0200
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/OutputHelper.java	Thu Oct 25 14:01:46 2012 +0200
@@ -2,6 +2,7 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -470,10 +471,10 @@
      */
     private static class ThemeList {
         private Logger logger = Logger.getLogger(ThemeList.class);
-        protected Map<Integer, ManagedFacet> themes;
+        protected List<ManagedFacet> themes;
 
         public ThemeList(Document output) {
-            themes = new HashMap<Integer, ManagedFacet>();
+            themes = new ArrayList<ManagedFacet>();
             parse(output);
         }
 
@@ -496,12 +497,14 @@
                 Element theme = (Element) themeList.item(i);
 
                 ManagedDomFacet facet = new ManagedDomFacet(theme);
-                themes.put(Integer.valueOf(facet.getPosition()-1), facet);
+                themes.add(facet);
             }
+
+            Collections.sort(themes);
         }
 
         public ManagedFacet get(int idx) {
-            return themes.get(Integer.valueOf(idx));
+            return themes.get(idx);
         }
 
         public int size() {

http://dive4elements.wald.intevation.org