fix bug in property xml serialization

This commit is contained in:
Sebastian Sdorra
2011-08-17 14:54:19 +02:00
parent a60f04e083
commit 5c9bf56210

View File

@@ -39,7 +39,6 @@ import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------ //~--- JDK imports ------------------------------------------------------------
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -50,7 +49,7 @@ import javax.xml.bind.annotation.adapters.XmlAdapter;
* @author Sebastian Sdorra * @author Sebastian Sdorra
*/ */
public class XmlMapStringAdapter public class XmlMapStringAdapter
extends XmlAdapter<ArrayList<XmlMapStringElement>, Map<String, String>> extends XmlAdapter<XmlMapStringElement[], Map<String, String>>
{ {
/** /**
@@ -64,21 +63,27 @@ public class XmlMapStringAdapter
* @throws Exception * @throws Exception
*/ */
@Override @Override
public ArrayList<XmlMapStringElement> marshal(Map<String, String> map) public XmlMapStringElement[] marshal(Map<String, String> map) throws Exception
throws Exception
{ {
ArrayList<XmlMapStringElement> elements = XmlMapStringElement[] elements = null;
new ArrayList<XmlMapStringElement>();
if (Util.isNotEmpty(map)) if (Util.isNotEmpty(map))
{ {
int i = 0; int i = 0;
int s = map.size();
elements = new XmlMapStringElement[s];
for (Map.Entry<String, String> e : map.entrySet()) for (Map.Entry<String, String> e : map.entrySet())
{ {
elements.add(new XmlMapStringElement(e.getKey(), e.getValue())); elements[i] = new XmlMapStringElement(e.getKey(), e.getValue());
i++;
} }
} }
else
{
elements = new XmlMapStringElement[0];
}
return elements; return elements;
} }
@@ -94,7 +99,7 @@ public class XmlMapStringAdapter
* @throws Exception * @throws Exception
*/ */
@Override @Override
public Map<String, String> unmarshal(ArrayList<XmlMapStringElement> elements) public Map<String, String> unmarshal(XmlMapStringElement[] elements)
throws Exception throws Exception
{ {
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<String, String>();