Re: [Simple-support] Beginner Question
Brought to you by:
niallg
|
From: Graham S. <gr...@mo...> - 2008-06-10 23:43:38
|
On Tue, Jun 10, 2008 at 3:59 PM, Timo Rumland <cr...@ol...> wrote: > Hello Graham, > >> But if I omit the class attribute then this: > >> TaskInterface o = serializer.read(TaskInterface.class, "<task1 >> a=\"14\" b=\"13\"/>>"); >> will fail with > > you want to get a TaskInterface, which is apparently an interface, > returned by the serializer. This is possible only if the serializer > knows what implementation to instantiate. If you have no "class" > parameter in the XML, how can the serializer know which class to > instantiate (you can't instantiate an interface)? Right, i entirely expect to have to provide the class attribute when i'm deserializing to an interface. How do i get the serializer to put it there? If i have TaskInterface myTask = new Task1(14,13); myPersister.write(myTask, "output.xml"); then it writes out the xml without the class attribute, so I end up with: <task1 a="14" b="13"/> instead of what I really want, which is: <task1 class="com.company.om.tasks.Task1" a="14" b="13"/> Does that make sense? How do I get Persister.write() to include the class attribute? thanks again, Graham |