[Simple-support] Bug in scattered inlined elements
Brought to you by:
niallg
|
From: Filip P. <fil...@ev...> - 2007-12-11 16:47:05
|
Bug in scattered inlined elements:
When using scattered inlined elements, the set(List list) method is =
called once only containing the first Element that is found. See the =
below test case:
Possible fix: Call the set(List list) method only after alla element in =
the list has been added.
import java.util.LinkedList;
import java.util.List;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.load.Persister;
@Root(name=3D"t")
public class InlinePrimitiveList {
public static boolean showBug;
=20
@Element String name;
private List<String> data =3D new LinkedList<String>();
=20
@ElementList(inline=3Dtrue)
void setList(List<String> list) {
if(showBug) {
data =3D new LinkedList(list);
} else {
data =3D list;
}
}
=20
@ElementList(inline=3Dtrue)
List<String> getList() {
return data;
}
=20
public String toString() {
return " name: " + name + " " + data;
}
=20
public static void main(String[] args) throws Exception {
showBug =3D false;
test();
showBug =3D true;
test();
}
=20
private static void test() throws Exception {
System.out.println("Object: " + new =
Persister().read(InlinePrimitiveList.class, =
"<t><string>1</string><name>a</name><string>2</string></t>"));
}
=20
}
/Filip Perlhagen
|