changeset 419:92b51af2d02d

Keep insertion order of attributes in DefaultSection. artifacts/trunk@5301 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 30 Aug 2012 00:09:14 +0000
parents 8d8aed23c323
children 0f4ee5886f86 a8b6b4924f4e
files ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultSection.java
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Aug 28 14:02:51 2012 +0000
+++ b/ChangeLog	Thu Aug 30 00:09:14 2012 +0000
@@ -1,3 +1,8 @@
+2012-08-30	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultSection.java:
+	  Use LinkedHashMap to keep insertion order of attributes.
+
 2012-08-27	Christian Lins	<christian.lins@intevation.de>
 
 	* artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java,
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultSection.java	Tue Aug 28 14:02:51 2012 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultSection.java	Thu Aug 30 00:09:14 2012 +0000
@@ -1,7 +1,7 @@
 package de.intevation.artifactdatabase.state;
 
 import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -11,6 +11,7 @@
 import org.w3c.dom.Node;
 
 /**
+ * Attributes keep the order in which they were inserted.
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
 public class DefaultSection implements Section {
@@ -19,6 +20,7 @@
 
     protected List<Section> subsections;
 
+    /** Attribute-map. */
     protected Map<String, Attribute> attributes;
 
 
@@ -28,7 +30,8 @@
      */
     public DefaultSection(String id) {
         this.id          = id;
-        this.attributes  = new HashMap<String, Attribute>();
+        // Use LinkedHashMap to keep insertion order.
+        this.attributes  = new LinkedHashMap<String, Attribute>();
         this.subsections = new ArrayList<Section>();
     }
 
@@ -63,6 +66,7 @@
     }
 
 
+    /** Adding attribute to end of list. */
     @Override
     public void addAttribute(String key, Attribute attribute) {
         if (key != null && key.length() > 0 && attribute != null) {

http://dive4elements.wald.intevation.org