Firstly, I am still pretty new to Digester.
I am needing to use Digester to read xml of the form of this test case:
public void test1() throws Exception
{
String xml = "<Collection>" +
" <ID>1</ID> " +
"</Collection>";
Digester digester = new Digester();
digester.addObjectCreate("Collection", java.util.ArrayList.class);
digester.addObjectCreate("Collection/ID", java.lang.Long.class);
digester.addSetNext("Collection/ID", "add" , "java.lang.Object");
Collection collection = (Collection)digester.parse( new StringReader(xml)
);
assertTrue("Should contain 1 instance: size=" + collection.size(),
collection.size()==1);
assertTrue("Should contain 1: size=" + collection.size() + ",
collection=" + collection, collection.contains(new Long(1)));
}
At the end of the day, I want this:
<Collection>
<ID>101</ID>
<IDI>105</ID>
</Collection>
To be digested into a Collection of Long wrappers.
But I am of course getting the following exception:
java.lang.InstantiationException: java.lang.Long
because there is no no-arg constructor for long. I really am hoping I don't
have to create an ObjectCreationFactory, as I was hoping there'd be some
helper class within Digester to assist with primitives as such (such as a
NumberObjectCreationFactory?).
Any help would be appreciated.
cheers,
_________________________
Paul Smith
Lawlex Compliance Solutions
phone: +61 3 9278 1511
email: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]