Mercurial > dive4elements > framework
diff artifact-database/src/main/java/de/intevation/artifactdatabase/state/DefaultSection.java @ 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 | ab3900303f25 |
children |
line wrap: on
line diff
--- 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) {