[Simple-support] obligation of "static public class" ?
Brought to you by:
niallg
|
From: Patrice B. <pat...@sm...> - 2009-04-21 08:56:43
|
Hello,
I see some persons mention a similar problem: an exception occuring
when reading a list of elements. And I read Niall answering "you must
declare a 'static public class' for the embedded items. So I changed
my code to have both outer and inner classes in same file, with inner
class declared as static public class within the first class, like this:
@Root
public class PropertyList {
@ElementList
private List<Entry> list;
@Attribute
private String name;
public String getName() {
return name;
}
public List getProperties() {
return list;
}
@Root
public static class Entry {
@Attribute
private String key;
@Element
private String value;
public String getName() {
return name;
}
public String getValue() {
return value;
}
}
}
(I take this from the tutorial page, but with a minor change to embed
"Entry" into "PropertyList" and make it static.)
However, I still get the same exception when reading. What is exactly
this obligation of a "public static class" and is it possible to find
the rules that apply. The tutorial is VERY well done, for giving a
overview of the possibilities, but is it possible that the sample code
that are in the tutorial would not work ?
Sorry for this beginner's question. I did go through the archive
trying to find the answer (although search function seems to be
unavailable).
|