Re: [Simple-support] Beginner Question
Brought to you by:
niallg
|
From: Niall G. <gal...@ya...> - 2008-06-10 21:01:36
|
Hi, The class attribute is a special attribute that is ignored by the deserialization. Can you use object.getClass().getName() ? Also you dont need to cast, the following. TaskInterface o = (TaskInterface) serializer.read(TaskInterface.class, serializedText); works as: TaskInterface o = serializer.read(TaskInterface.class, serializedText); Its casted by the class type TaskInterface.class, the return type is autocasted at compile time. Hope this helps, Niall --- On Tue, 6/10/08, Graham Stewart <gr...@mo...> wrote: > From: Graham Stewart <gr...@mo...> > Subject: [Simple-support] Beginner Question > To: sim...@li... > Date: Tuesday, June 10, 2008, 12:36 PM > First let me say that simple looks great - it's > refreshing to find a > java serialization tool that works without 5 megs of > dependencies! > > > I'm trying to use Simple in a situation very similar to > this tutorial example > > http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#override > > I have two classes that implement TaskInterface, Task1 and > Task2 and > i'd like to be able to serialize the TaskInterface and > get usable XML. > > Putting the class name in the xml seems to work and both of > these > deserialize fine: > > <task1 class="com.somispo.om.tasks.Task1" > a="14" b="13"/> > <task2 class="com.somispo.om.tasks.Task2" > c="15" d="16"/> > > TaskInterface o = (TaskInterface) > serializer.read(TaskInterface.class, > serializedText); > > > What I can't figure out is how to get that class > attribute in the xml > output from the Persister? It seems like it should be > straightforward, > but I can't get it to show when I try to persist a > TaskInterface. > > thanks, > Graham > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support |