Re: [Simple-support] Deserialization of type Calendar?
Brought to you by:
niallg
|
From: <Nia...@ub...> - 2008-10-01 15:02:45
|
Hi,
If you change Calendar field to a GregorianCalendar field then it should
work fine. Currently it only supports this type of calendar. I intend to
expand this support the the other Calendar types soon enough.
Niall
-----Original Message-----
From: Timo Rumland [mailto:cr...@ol...]
Sent: 01 October 2008 15:26
To: sim...@li...
Subject: [Simple-support] Deserialization of type Calendar?
Hello,
sorry for posting this message twice, but my mail-server is currently
not very reliable :/
I can use Simple to serialize my model class, which holds a field of
type Calendar. But I'm unable to deserialize it, Simple produces this
Exception:
--------------------------
Exception in thread "main"
org.simpleframework.xml.transform.TransformException: Transform of class
java.util.Calendar not supported
at
org.simpleframework.xml.transform.PackageMatcher.matchUtility(PackageMat
cher.java:184)
at
org.simpleframework.xml.transform.PackageMatcher.match(PackageMatcher.ja
va:77)
at
org.simpleframework.xml.transform.DefaultMatcher.matchType(DefaultMatche
r.java:111)
at
org.simpleframework.xml.transform.DefaultMatcher.match(DefaultMatcher.ja
va:90)
...
...
--------------------------
This is my simple test class that produces the exception:
--------------------------
public class CalendarSerializationTest {
public CalendarSerializationTest() throws Exception {
// Create test model
CalendarSerializationTestModel model = new
CalendarSerializationTestModel();
model.setTime( Calendar.getInstance() );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// Serialization
// The method "SerializerFactory.getInstance( true )" just
// creates a new Persister object with a cycle strategy
Serializer serializer = SerializerFactory.getInstance( true );
serializer.write( model, baos );
String xml = baos.toString( "UTF-8" );
System.out.println( xml );
// Deserialization
CalendarSerializationTestModel modelDeserialized =
serializer.read( CalendarSerializationTestModel.class, xml );
}
public static void main( String[] args ) throws Exception {
new CalendarSerializationTest();
}
}
--------------------------
The class CalendarSerializationTestModel is a very simple class:
--------------------------
@Root
public class CalendarSerializationTestModel {
@Element
private Calendar time;
// [...] Getter and setter methods for "time"
}
--------------------------
The test class produces this XML code:
--------------------------
<?xml version="1.0" encoding="UTF-8"?>
<calendarSerializationTestModel xid="0">
<time class="java.util.GregorianCalendar" xid="1">2008-10-01
14:59:43.109 CEST</time>
</calendarSerializationTestModel>
--------------------------
Am I doing anything wrong? What is the reason, that Simple is able to
serialize, but unable to deserialize the type Calendar?
Thanks a lot for your help!
Best regards,
Timo Rumland
------------------------------------------------------------------------
-
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge Build the coolest Linux based applications with Moblin SDK &
win great prizes Grand prize is a trip for two to an Open Source event
anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
Visit our website at http://www.ubs.com
This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.
E-mails are not encrypted and cannot be guaranteed to be secure or
error-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The sender
therefore does not accept liability for any errors or omissions in the
contents of this message which arise as a result of e-mail transmission.
If verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities
or related financial instruments.
UBS Limited is a company registered in England & Wales under company
number 2035362, whose registered office is at 1 Finsbury Avenue,
London, EC2M 2PP, United Kingdom.
UBS AG (London Branch) is registered as a branch of a foreign company
under number BR004507, whose registered office is at
1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
UBS Clearing and Execution Services Limited is a company registered
in England & Wales under company number 03123037, whose registered
office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
|