I'm currently trying to consume a list of strings from some XML using Apache Digester, as described in the How do I add literal elements to a List object? section of the FAQ.
I'm hitting the following error:
[DEBUG] Digester - [SetNextRule]{job/editorial/articlegroup/article} Call java.util.ArrayList.setFields([This, This, is, is, a, a, test, test, , , , ])
[ERROR] Digester - End event threw exception <java.lang.NoSuchMethodException: No such accessible method: setFields() on object: java.util.ArrayList>java.lang.NoSuchMethodException: No such accessible method: setFields() on object: java.util.ArrayList
A simplified version of the XML I am using is as follows:
<job>
<editorial>
<articlegroup>
<article>
<text>
<content><![CDATA[This]]></content>
</text>
<text>
<content><![CDATA[is]]></content>
</text>
<text>
<content><![CDATA[a]]></content>
</text>
<text>
<content><![CDATA[test]]></content>
</text>
</article>
</articlegroup>
</editorial>
</job>
And the source code:
public class PPJob {
List<String> fields;
public List<String> getFields() {
return fields;
}
public void setFields(List<String> fields) {
this.fields = fields;
}
}
addObjectCreate("job", PPJob.class);
addSetProperties("job");
addObjectCreate("job/editorial/articlegroup/article", ArrayList.class);
addCallMethod("job/editorial/articlegroup/article/text/content", "add", 1);
addCallParam("job/editorial/articlegroup/article/text/content", 0);
addSetNext("job/editorial/articlegroup/article", "setFields");
PPJob result = (PPJob)super.parse([THE XML]);
I'm pretty much a novice at using the Digester, and I'm having a hard time tracking down examples for what I need.
Can anyone see where I'm going wrong?