simple-support Mailing List for Simple (Page 69)
Brought to you by:
niallg
You can subscribe to this list here.
| 2007 |
Jan
|
Feb
(2) |
Mar
(2) |
Apr
(13) |
May
(13) |
Jun
(27) |
Jul
(4) |
Aug
(14) |
Sep
(7) |
Oct
|
Nov
(6) |
Dec
(24) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
|
Feb
(21) |
Mar
(10) |
Apr
(15) |
May
(24) |
Jun
(24) |
Jul
(30) |
Aug
(5) |
Sep
(19) |
Oct
(27) |
Nov
(16) |
Dec
(24) |
| 2009 |
Jan
(34) |
Feb
(24) |
Mar
(35) |
Apr
(26) |
May
(8) |
Jun
(17) |
Jul
(28) |
Aug
(31) |
Sep
(36) |
Oct
(35) |
Nov
(20) |
Dec
(16) |
| 2010 |
Jan
(40) |
Feb
(21) |
Mar
(47) |
Apr
(45) |
May
(34) |
Jun
(68) |
Jul
(46) |
Aug
(39) |
Sep
(47) |
Oct
(20) |
Nov
(42) |
Dec
(13) |
| 2011 |
Jan
(41) |
Feb
(16) |
Mar
(32) |
Apr
(44) |
May
(28) |
Jun
(35) |
Jul
(37) |
Aug
(33) |
Sep
(60) |
Oct
(20) |
Nov
(35) |
Dec
(23) |
| 2012 |
Jan
(34) |
Feb
(23) |
Mar
(34) |
Apr
(21) |
May
(48) |
Jun
(24) |
Jul
(31) |
Aug
(39) |
Sep
(25) |
Oct
(10) |
Nov
(27) |
Dec
(28) |
| 2013 |
Jan
(32) |
Feb
(24) |
Mar
(24) |
Apr
(9) |
May
(4) |
Jun
(6) |
Jul
(2) |
Aug
(5) |
Sep
|
Oct
(5) |
Nov
(1) |
Dec
(12) |
| 2014 |
Jan
(14) |
Feb
(16) |
Mar
(5) |
Apr
(3) |
May
(2) |
Jun
(8) |
Jul
(2) |
Aug
|
Sep
(6) |
Oct
|
Nov
(6) |
Dec
|
| 2015 |
Jan
(3) |
Feb
(15) |
Mar
(7) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
(1) |
| 2016 |
Jan
|
Feb
(6) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2019 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Lardy <na...@he...> - 2009-01-18 00:25:45
|
I don't need readable XML - in fact it is a hindrance since I am sending large amounts of it over a network and all those spaces and new lines just add to the bulk - and so I need to stop simpleXML inserting spaces and new lines. I can't find anything on Style, Format, etc. that allows this. How would I go about it? I see I can set the indent to 0 but I need to stop the new lines being output too as I write each XML on a single line for easy reading at the other end. Nice library BTW - up and running in a few minutes. Thanks -- View this message in context: http://www.nabble.com/How-to-disable-pretty-formatting--tp21522727p21522727.html Sent from the Simple XML Serialization mailing list archive at Nabble.com. |
|
From: Rinaldo D. <Rin...@Su...> - 2009-01-05 19:22:58
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Niall Gallagher wrote:
<blockquote cite="mid:508...@we..."
type="cite">
<pre wrap="">Hi,
Just out of interest did you get this because you did not have the StAX API and implementation in the classpath. Therefore getting the class not found error, then moving to 1.6 which has StAX as part of the JDK it worked?
Niall
</pre>
</blockquote>
Yes moving to 1.6 fixed it. I did not have the StAX API
on the classpath? <br>
<br>
Rinaldo<br>
<blockquote cite="mid:508...@we..."
type="cite">
<pre wrap="">
--- On Mon, 1/5/09, Rinaldo DiGiorgio <a class="moz-txt-link-rfc2396E" href="mailto:Rin...@Su..."><Rin...@Su...></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">From: Rinaldo DiGiorgio <a class="moz-txt-link-rfc2396E" href="mailto:Rin...@Su..."><Rin...@Su...></a>
Subject: Re: [Simple-support] Question about missing XMLInputFactory
To: <a class="moz-txt-link-abbreviated" href="mailto:sim...@li...">sim...@li...</a>
Date: Monday, January 5, 2009, 9:51 AM
Rinaldo DiGiorgio wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hello,
I thought I read the directions. I am trying to
</pre>
</blockquote>
<pre wrap="">read an XML file
</pre>
<blockquote type="cite">
<pre wrap="">and I get the following error. I am using
1.6 on a Mac.
</pre>
</blockquote>
<pre wrap="">I figured it out, NetBeans sets my default for 1.5 and 1.6
is required.
Please ignore the previous question.
</pre>
<blockquote type="cite">
<pre wrap=""> Serializer serializer = new Persister();
File source = new
</pre>
</blockquote>
<pre wrap="">File("configuration.xml");
</pre>
<blockquote type="cite">
<pre wrap=""> Configuration configuration = null;
try {
configuration =
</pre>
</blockquote>
<pre wrap="">serializer.read(Configuration.class, source);
</pre>
<blockquote type="cite">
<pre wrap=""> } catch (Exception ex) {
</pre>
</blockquote>
<pre wrap="">Logger.getLogger(ProcessUrlWithCalais.class.getName()).log(Level.SEVERE,
</pre>
<blockquote type="cite">
<pre wrap="">null, ex);
System.exit(0);
}
Exception in thread "main"
</pre>
</blockquote>
<pre wrap="">java.lang.NoClassDefFoundError:
</pre>
<blockquote type="cite">
<pre wrap="">javax/xml/stream/XMLInputFactory
at
</pre>
</blockquote>
<pre wrap="">org.simpleframework.xml.stream.NodeBuilder.<clinit>(NodeBuilder.java:48)
</pre>
<blockquote type="cite">
<pre wrap=""> at
</pre>
</blockquote>
<pre wrap="">org.simpleframework.xml.core.Persister.read(Persister.java:489)
</pre>
<blockquote type="cite">
<pre wrap=""> at
</pre>
</blockquote>
<pre wrap="">org.simpleframework.xml.core.Persister.read(Persister.java:471)
</pre>
<blockquote type="cite">
<pre wrap=""> at
</pre>
</blockquote>
<pre wrap="">org.simpleframework.xml.core.Persister.read(Persister.java:452)
</pre>
<blockquote type="cite">
<pre wrap=""> at
</pre>
</blockquote>
<pre wrap="">org.simpleframework.xml.core.Persister.read(Persister.java:431)
</pre>
<blockquote type="cite">
<pre wrap=""> at
</pre>
</blockquote>
<pre wrap="">calaisie.ProcessUrlWithCalais.main(ProcessUrlWithCalais.java:135)
</pre>
<pre wrap="">
------------------------------------------------------------------------------
_______________________________________________
Simple-support mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Sim...@li...">Sim...@li...</a>
<a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/simple-support">https://lists.sourceforge.net/lists/listinfo/simple-support</a>
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
</body>
</html>
|
|
From: Niall G. <gal...@ya...> - 2009-01-05 19:15:38
|
Hi,
Just out of interest did you get this because you did not have the StAX API and implementation in the classpath. Therefore getting the class not found error, then moving to 1.6 which has StAX as part of the JDK it worked?
Niall
--- On Mon, 1/5/09, Rinaldo DiGiorgio <Rin...@Su...> wrote:
> From: Rinaldo DiGiorgio <Rin...@Su...>
> Subject: Re: [Simple-support] Question about missing XMLInputFactory
> To: sim...@li...
> Date: Monday, January 5, 2009, 9:51 AM
> Rinaldo DiGiorgio wrote:
> > Hello,
> >
> > I thought I read the directions. I am trying to
> read an XML file
> > and I get the following error. I am using
> > 1.6 on a Mac.
> >
> >
> I figured it out, NetBeans sets my default for 1.5 and 1.6
> is required.
> Please ignore the previous question.
>
> > Serializer serializer = new Persister();
> > File source = new
> File("configuration.xml");
> >
> > Configuration configuration = null;
> > try {
> > configuration =
> serializer.read(Configuration.class, source);
> > } catch (Exception ex) {
> >
> >
> Logger.getLogger(ProcessUrlWithCalais.class.getName()).log(Level.SEVERE,
>
> > null, ex);
> > System.exit(0);
> > }
> >
> > Exception in thread "main"
> java.lang.NoClassDefFoundError:
> > javax/xml/stream/XMLInputFactory
> > at
> >
> org.simpleframework.xml.stream.NodeBuilder.<clinit>(NodeBuilder.java:48)
> > at
> org.simpleframework.xml.core.Persister.read(Persister.java:489)
> > at
> org.simpleframework.xml.core.Persister.read(Persister.java:471)
> > at
> org.simpleframework.xml.core.Persister.read(Persister.java:452)
> > at
> org.simpleframework.xml.core.Persister.read(Persister.java:431)
> > at
> >
> calaisie.ProcessUrlWithCalais.main(ProcessUrlWithCalais.java:135)
> >
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Rinaldo D. <Rin...@Su...> - 2009-01-05 17:53:34
|
Rinaldo DiGiorgio wrote:
> Hello,
>
> I thought I read the directions. I am trying to read an XML file
> and I get the following error. I am using
> 1.6 on a Mac.
>
>
I figured it out, NetBeans sets my default for 1.5 and 1.6 is required.
Please ignore the previous question.
> Serializer serializer = new Persister();
> File source = new File("configuration.xml");
>
> Configuration configuration = null;
> try {
> configuration = serializer.read(Configuration.class, source);
> } catch (Exception ex) {
>
> Logger.getLogger(ProcessUrlWithCalais.class.getName()).log(Level.SEVERE,
> null, ex);
> System.exit(0);
> }
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> javax/xml/stream/XMLInputFactory
> at
> org.simpleframework.xml.stream.NodeBuilder.<clinit>(NodeBuilder.java:48)
> at org.simpleframework.xml.core.Persister.read(Persister.java:489)
> at org.simpleframework.xml.core.Persister.read(Persister.java:471)
> at org.simpleframework.xml.core.Persister.read(Persister.java:452)
> at org.simpleframework.xml.core.Persister.read(Persister.java:431)
> at
> calaisie.ProcessUrlWithCalais.main(ProcessUrlWithCalais.java:135)
>
|
|
From: Rinaldo D. <Rin...@Su...> - 2009-01-05 16:12:53
|
Hello,
I thought I read the directions. I am trying to read an XML file and
I get the following error. I am using
1.6 on a Mac.
Serializer serializer = new Persister();
File source = new File("configuration.xml");
Configuration configuration = null;
try {
configuration = serializer.read(Configuration.class, source);
} catch (Exception ex) {
Logger.getLogger(ProcessUrlWithCalais.class.getName()).log(Level.SEVERE,
null, ex);
System.exit(0);
}
Exception in thread "main" java.lang.NoClassDefFoundError:
javax/xml/stream/XMLInputFactory
at
org.simpleframework.xml.stream.NodeBuilder.<clinit>(NodeBuilder.java:48)
at org.simpleframework.xml.core.Persister.read(Persister.java:489)
at org.simpleframework.xml.core.Persister.read(Persister.java:471)
at org.simpleframework.xml.core.Persister.read(Persister.java:452)
at org.simpleframework.xml.core.Persister.read(Persister.java:431)
at calaisie.ProcessUrlWithCalais.main(ProcessUrlWithCalais.java:135)
|
|
From: Niall G. <gal...@ya...> - 2009-01-02 17:49:41
|
Hi,
The problem is class="java.beans.XMLDecoder". An option you can try is this.
Strategy strategy = new TreeStrategy("type", "length")
Persister persister = new Persister(strategy);
This will create a persister that uses a type= attribute to define the types rather than the class= attribute. The persister is reading the class= attribute to determine the type. So because the class="java.beans.XMLDecoder" is not the type you are deserializing you need to ignore it, using type= instead will ignore the class= attributes.
Niall
--- On Fri, 1/2/09, Mouad El Gharbaoui <mou...@gm...> wrote:
> From: Mouad El Gharbaoui <mou...@gm...>
> Subject: Re: [Simple-support] problems to deserialize an xml file
> To: gal...@ya...
> Date: Friday, January 2, 2009, 9:14 AM
> hi, thanks for the quick response,
>
> the xml contains the line <java
> version="1.6.0_07"
> class="java.beans.XMLDecoder">
> and the class = attributes too.
> I am using no strategy, didn t read anything about in the
> tutorial!
>
> i have already posted the code for:
> com.flowfact.client.app.configuration.UserConfiguration.readXStream(UserConfiguration.java:232)
> tha t s the few lines that i have posted at the beginning.
>
> thanks
>
> Mouad
>
>
>
> -------- Original-Nachricht --------
> > Datum: Fri, 2 Jan 2009 09:00:24 -0800 (PST)
> > Von: Niall Gallagher <gal...@ya...>
> > An: sim...@li..., Mouad El
> Gharbaoui <mou...@gm...>
> > Betreff: Re: [Simple-support] problems to deserialize
> an xml file
>
> > Hi,
> >
> > Looks like the XML content you are trying to
> deserialize is incorrect. In
> > this case you are deserializing an XMLDecoder and
> trying to assign it to a
> > UserConfiguration object. Attach the code for
> >
> >
> com.flowfact.client.app.configuration.UserConfiguration.readXStream(UserConfiguration.java:232)
> >
> > Does your XML source contain "class="
> attributes that contain either of
> > the classes? Also what strategy are you using?
> >
> > Niall
> >
> >
> > --- On Fri, 1/2/09, Mouad El Gharbaoui
> <mou...@gm...> wrote:
> >
> > > From: Mouad El Gharbaoui <mou...@gm...>
> > > Subject: [Simple-support] problems to deserialize
> an xml file
> > > To: sim...@li...
> > > Date: Friday, January 2, 2009, 8:52 AM
> > > I am trying the first time to deserialize an xml
> file to a
> > > given object with following codelines:
> > >
> > > Serializer serializer = new Persister();
> > > File source = new File(getPath() +
> getFileName());
> > > UserConfiguration conf =
> > > decoder.read(UserConfiguration.class, source);
> > >
> > > But i become following exception:
> > >
> org.simpleframework.xml.core.InstantiationException: Type
> > > class java.beans.XMLDecoder is not compatible
> with class
> > >
> com.flowfact.client.app.configuration.UserConfiguration
> > > at
> > >
> org.simpleframework.xml.core.Factory.getOverride(Factory.java:106)
> > > at
> > >
> >
> org.simpleframework.xml.core.ObjectFactory.getInstance(ObjectFactory.java:63)
> > > at
> > >
> org.simpleframework.xml.core.Composite.read(Composite.java:125)
> > > at
> > >
> org.simpleframework.xml.core.Traverser.read(Traverser.java:78)
> > > at
> > >
> org.simpleframework.xml.core.Persister.read(Persister.java:544)
> > > at
> > >
> org.simpleframework.xml.core.Persister.read(Persister.java:526)
> > > at
> > >
> org.simpleframework.xml.core.Persister.read(Persister.java:507)
> > > at
> > >
> org.simpleframework.xml.core.Persister.read(Persister.java:489)
> > > at
> > >
> org.simpleframework.xml.core.Persister.read(Persister.java:471)
> > > at
> > >
> org.simpleframework.xml.core.Persister.read(Persister.java:452)
> > > at
> > >
> org.simpleframework.xml.core.Persister.read(Persister.java:431)
> > > at
> > >
> >
> com.flowfact.client.app.configuration.UserConfiguration.readXStream(UserConfiguration.java:232)
> > > at
> > >
> >
> com.flowfact.util.configuration.Configuration.load(Configuration.java:121)
> > > at
> > >
> >
> com.flowfact.client.app.FlowFactActivator.getUserConfiguration(FlowFactActivator.java:106)
> > > at
> > >
> >
> com.flowfact.client.app.splashHandlers.InteractiveSplashHandler.requestTargetServerInformation(InteractiveSplashHandler.java:351)
> > > at
> > >
> >
> com.flowfact.client.app.ApplicationWorkbenchAdvisor.preStartup(ApplicationWorkbenchAdvisor.java:59)
> > > at
> > >
> >
> org.eclipse.ui.internal.Workbench$27.runWithException(Workbench.java:1359)
> > > at
> > >
> >
> org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
> > > at
> > >
> org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
> > > at
> > >
> >
> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:133)
> > > at
> > >
> org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3800)
> > > at
> > >
> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3425)
> > > at
> > >
> org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2293)
> > > at
> > >
> org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
> > > at
> > >
> org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
> > > at
> > >
> >
> org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
> > > at
> > >
> >
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488)
> > > at
> > >
> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
> > > at
> > >
> >
> com.flowfact.client.app.FlowFactApplication.start(FlowFactApplication.java:28)
> > > at
> > >
> >
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
> > > at
> > >
> >
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
> > > at
> > >
> >
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
> > > at
> > >
> >
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
> > > at
> > >
> >
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
> > > at
> sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > > Method)
> > > at
> > >
> >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> > > at
> > >
> >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> > > at
> java.lang.reflect.Method.invoke(Method.java:597)
> > > at
> > >
> org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
> > > at
> > >
> org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
> > > at
> org.eclipse.equinox.launcher.Main.run(Main.java:1236)
> > > at
> org.eclipse.equinox.launcher.Main.main(Main.java:1212)
> > >
> > > Does anybpdy know what is the reason?
> > >
> > > Thanks
> > >
> > > Mouad
> > >
> > > --
> > > Psssst! Schon vom neuen GMX MultiMessenger
> gehört? Der
> > > kann`s mit allen:
> http://www.gmx.net/de/go/multimessenger
> > >
> > >
> >
> ------------------------------------------------------------------------------
> > > _______________________________________________
> > > Simple-support mailing list
> > > Sim...@li...
> > >
> https://lists.sourceforge.net/lists/listinfo/simple-support
> >
> >
> >
>
> --
> Sensationsangebot verlängert: GMX FreeDSL -
> Telefonanschluss + DSL
> für nur 16,37 Euro/mtl.!*
> http://dsl.gmx.de/?ac=OM.AD.PD003K1308T4569a
|
|
From: Niall G. <gal...@ya...> - 2009-01-02 17:00:35
|
Hi, Looks like the XML content you are trying to deserialize is incorrect. In this case you are deserializing an XMLDecoder and trying to assign it to a UserConfiguration object. Attach the code for com.flowfact.client.app.configuration.UserConfiguration.readXStream(UserConfiguration.java:232) Does your XML source contain "class=" attributes that contain either of the classes? Also what strategy are you using? Niall --- On Fri, 1/2/09, Mouad El Gharbaoui <mou...@gm...> wrote: > From: Mouad El Gharbaoui <mou...@gm...> > Subject: [Simple-support] problems to deserialize an xml file > To: sim...@li... > Date: Friday, January 2, 2009, 8:52 AM > I am trying the first time to deserialize an xml file to a > given object with following codelines: > > Serializer serializer = new Persister(); > File source = new File(getPath() + getFileName()); > UserConfiguration conf = > decoder.read(UserConfiguration.class, source); > > But i become following exception: > org.simpleframework.xml.core.InstantiationException: Type > class java.beans.XMLDecoder is not compatible with class > com.flowfact.client.app.configuration.UserConfiguration > at > org.simpleframework.xml.core.Factory.getOverride(Factory.java:106) > at > org.simpleframework.xml.core.ObjectFactory.getInstance(ObjectFactory.java:63) > at > org.simpleframework.xml.core.Composite.read(Composite.java:125) > at > org.simpleframework.xml.core.Traverser.read(Traverser.java:78) > at > org.simpleframework.xml.core.Persister.read(Persister.java:544) > at > org.simpleframework.xml.core.Persister.read(Persister.java:526) > at > org.simpleframework.xml.core.Persister.read(Persister.java:507) > at > org.simpleframework.xml.core.Persister.read(Persister.java:489) > at > org.simpleframework.xml.core.Persister.read(Persister.java:471) > at > org.simpleframework.xml.core.Persister.read(Persister.java:452) > at > org.simpleframework.xml.core.Persister.read(Persister.java:431) > at > com.flowfact.client.app.configuration.UserConfiguration.readXStream(UserConfiguration.java:232) > at > com.flowfact.util.configuration.Configuration.load(Configuration.java:121) > at > com.flowfact.client.app.FlowFactActivator.getUserConfiguration(FlowFactActivator.java:106) > at > com.flowfact.client.app.splashHandlers.InteractiveSplashHandler.requestTargetServerInformation(InteractiveSplashHandler.java:351) > at > com.flowfact.client.app.ApplicationWorkbenchAdvisor.preStartup(ApplicationWorkbenchAdvisor.java:59) > at > org.eclipse.ui.internal.Workbench$27.runWithException(Workbench.java:1359) > at > org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31) > at > org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) > at > org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:133) > at > org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3800) > at > org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3425) > at > org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2293) > at > org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198) > at > org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493) > at > org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) > at > org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488) > at > org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) > at > com.flowfact.client.app.FlowFactApplication.start(FlowFactApplication.java:28) > at > org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) > at > org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) > at > org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) > at > org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382) > at > org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native > Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at > org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549) > at > org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) > at org.eclipse.equinox.launcher.Main.run(Main.java:1236) > at org.eclipse.equinox.launcher.Main.main(Main.java:1212) > > Does anybpdy know what is the reason? > > Thanks > > Mouad > > -- > Psssst! Schon vom neuen GMX MultiMessenger gehört? Der > kann`s mit allen: http://www.gmx.net/de/go/multimessenger > > ------------------------------------------------------------------------------ > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Mouad El G. <mou...@gm...> - 2009-01-02 16:53:04
|
I am trying the first time to deserialize an xml file to a given object with following codelines: Serializer serializer = new Persister(); File source = new File(getPath() + getFileName()); UserConfiguration conf = decoder.read(UserConfiguration.class, source); But i become following exception: org.simpleframework.xml.core.InstantiationException: Type class java.beans.XMLDecoder is not compatible with class com.flowfact.client.app.configuration.UserConfiguration at org.simpleframework.xml.core.Factory.getOverride(Factory.java:106) at org.simpleframework.xml.core.ObjectFactory.getInstance(ObjectFactory.java:63) at org.simpleframework.xml.core.Composite.read(Composite.java:125) at org.simpleframework.xml.core.Traverser.read(Traverser.java:78) at org.simpleframework.xml.core.Persister.read(Persister.java:544) at org.simpleframework.xml.core.Persister.read(Persister.java:526) at org.simpleframework.xml.core.Persister.read(Persister.java:507) at org.simpleframework.xml.core.Persister.read(Persister.java:489) at org.simpleframework.xml.core.Persister.read(Persister.java:471) at org.simpleframework.xml.core.Persister.read(Persister.java:452) at org.simpleframework.xml.core.Persister.read(Persister.java:431) at com.flowfact.client.app.configuration.UserConfiguration.readXStream(UserConfiguration.java:232) at com.flowfact.util.configuration.Configuration.load(Configuration.java:121) at com.flowfact.client.app.FlowFactActivator.getUserConfiguration(FlowFactActivator.java:106) at com.flowfact.client.app.splashHandlers.InteractiveSplashHandler.requestTargetServerInformation(InteractiveSplashHandler.java:351) at com.flowfact.client.app.ApplicationWorkbenchAdvisor.preStartup(ApplicationWorkbenchAdvisor.java:59) at org.eclipse.ui.internal.Workbench$27.runWithException(Workbench.java:1359) at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:133) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3800) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3425) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2293) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at com.flowfact.client.app.FlowFactApplication.start(FlowFactApplication.java:28) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504) at org.eclipse.equinox.launcher.Main.run(Main.java:1236) at org.eclipse.equinox.launcher.Main.main(Main.java:1212) Does anybpdy know what is the reason? Thanks Mouad -- Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger |
|
From: Niall G. <gal...@ya...> - 2008-12-26 12:49:13
|
Hi, Yes this is possible, this and other strategy based questions are probably the most common questions asked. So, I will make sure there are several new entries in the tutorial to describe how to use them. For now there is a good example in the following test case. http://simple.svn.sourceforge.net/viewvc/simple/trunk/download/stream/src/test/java/org/simpleframework/xml/core/InterceptorTest.java?revision=1128&view=markup Here you would change the logic slightly to ensure that serialization does not include the class attribute and that deserialization maps the element name to the class. Hope this helps, Niall --- On Wed, 12/24/08, Carl H. Sayres <ca...@da...> wrote: > From: Carl H. Sayres <ca...@da...> > Subject: [Simple-support] deserializing a list of subclasses > To: sim...@li... > Date: Wednesday, December 24, 2008, 2:38 AM > Is it possible to specify how elements map to classes in the > java code, > rather than in the xml using the class attribute? > Here's an example of > what I mean: > > Suppose I have classes as follows: > > package a.b.c.d; > class Component {} > class TextField extends Component {} > class TextArea extends Component {} > class Choice extends Component {} > > Using Simple, I can deserialize the following XML easily: > > <ComponentList> > <Component class="a.b.c.d.TextField" /> > <Component class="a.b.c.d.TextArea" /> > <Component class="a.b.c.d.Choice" /> > </ComponentList> > > I would like to be able to use the following instead: > > <ComponentList> > <TextField" /> > <TextArea" /> > <Choice" /> > </ComponentList> > > and specify how TextField, etc.. maps to an > a.b.c.d.TextField in the java > code. (Perhaps using some kind of Strategy?) > > Is this possible? > > Thanks, > > Carl > > > > > ------------------------------------------------------------------------------ > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Carl H. S. <ca...@da...> - 2008-12-24 10:38:31
|
Is it possible to specify how elements map to classes in the java code,
rather than in the xml using the class attribute? Here's an example of
what I mean:
Suppose I have classes as follows:
package a.b.c.d;
class Component {}
class TextField extends Component {}
class TextArea extends Component {}
class Choice extends Component {}
Using Simple, I can deserialize the following XML easily:
<ComponentList>
<Component class="a.b.c.d.TextField" />
<Component class="a.b.c.d.TextArea" />
<Component class="a.b.c.d.Choice" />
</ComponentList>
I would like to be able to use the following instead:
<ComponentList>
<TextField" />
<TextArea" />
<Choice" />
</ComponentList>
and specify how TextField, etc.. maps to an a.b.c.d.TextField in the java
code. (Perhaps using some kind of Strategy?)
Is this possible?
Thanks,
Carl
|
|
From: Carl H. S. <ch...@da...> - 2008-12-24 10:21:02
|
Is it possible to specify how elements map to classes in the code,
rather than in the xml using the class attribute? Here's an example of
what I mean:
Suppose I have classes as follows:
package a.b.c.d;
class Component {}
class TextField extends Component {}
class TextArea extends Component {}
class Choice extends Component {}
Using Simple, I can deserialize the following XML easily:
<ComponentList>
<Component class="a.b.c.d.TextField" />
<Component class="a.b.c.d.TextArea" />
<Component class="a.b.c.d.Choice" />
</ComponentList>
I would like to be able to use the following instead:
<ComponentList>
<TextField" />
<TextArea" />
<Choice" />
</ComponentList>
and specify how TextField maps to an a.b.c.d.TextField in the java
code. (Perhaps using some kind of Strategy?)
Is this possible?
Thanks,
Carl
|
|
From: Joe <fis...@ya...> - 2008-12-16 16:53:46
|
Hi,
> Your suggestion should work fine.
an optimisation is to encode only empty strings and strings starting
with the encoding prefix character.
<testData>
<_values class="java.util.Arrays$ArrayList">
<string>A</string> -> normal text
<string></string> -> null
<string>*</string> -> empty
<string>**</string> -> *
</_values>
</testData>
For better readabilty a <SPACE> could be used.
> I think there may be another
> alternative using a strategy, so that you could have.
>
> <testData>
> <_values class="java.util.Arrays$ArrayList">
> <string>A</string>
> <string null="false"></string>
> <string null="true"></string>
> </_values>
> </testData>
>
> This would basically involve adding an attribute to all elements where
> the value to be written is null. Don't know if deserialization would
> respect this though so I would have to investigate.
i like it, even more readable.
|
|
From: Joe <fis...@ya...> - 2008-12-16 16:14:38
|
Hi,
> So it looks like if you really need the empty string
> "" then you will need to either treat null as a special case, or
> substitute "" for some token such as "NULL".
I think i will use a slightly different approach, inspired by the base64
encoding example in your tutorial.
I encode every value with a prefix (here '*') only null values are ignored.
So
Arrays.asList("A", "", null)
will be serialized as:
<testData>
<_values class="java.util.Arrays$ArrayList">
<string>*A</string>
<string>*</string>
<string></string>
</_values>
</testData>
Using @Commit the deserialization can be adjusted, to getting back
the original values.
The output of the following example is the expected String:
values: [A, , null]
public class TestData
{
@ElementList()
private List<String> _values = new ArrayList<String>();
public List<String> getValues()
{
return _values;
}
public void setValues(List<String> values)
{
_values = values;
}
@Persist
public void persist()
{
for (int i = 0; i < _values.size(); i++)
if (_values.get(i) != null)
_values.set(i, "*" + _values.get(i));
else
_values.set(i, "");
}
@Commit
public void commit()
{
for (int i = 0; i < _values.size(); i++)
{
String val = _values.get(i);
if (val != null)
_values.set(i, _values.get(i).substring(1));
}
}
public static void main(String[] args) throws Exception
{
Serializer serializer = new Persister();
File xmlFile = new File("test.xml");
TestData data = new TestData();
data.setValues(Arrays.asList("A", "", null));
serializer.write(data, xmlFile);
TestData sqlData = serializer.read(TestData.class, xmlFile);
System.out.println("values: " + sqlData.getValues());
}
}
|
|
From: Joe <fis...@ya...> - 2008-12-16 16:14:16
|
Hi,
> So it looks like if you really need the empty string
> "" then you will need to either treat null as a special case, or
> substitute "" for some token such as "NULL".
I think i will use a slightly different approach, inspired by the base64
encoding example in your tutorial.
I encode every value with a prefix (here '*') only null values are ignored.
So
Arrays.asList("A", "", null)
will be serialized as:
<testData>
<_values class="java.util.Arrays$ArrayList">
<string>*A</string>
<string>*</string>
<string></string>
</_values>
</testData>
Using @Commit the deserialization can be adjusted, to getting back
the original values.
The output of the following example is the expected String:
values: [A, , null]
public class TestData
{
@ElementList()
private List<String> _values = new ArrayList<String>();
public List<String> getValues()
{
return _values;
}
public void setValues(List<String> values)
{
_values = values;
}
@Persist
public void persist()
{
for (int i = 0; i < _values.size(); i++)
if (_values.get(i) != null)
_values.set(i, "*" + _values.get(i));
else
_values.set(i, "");
}
@Commit
public void commit()
{
for (int i = 0; i < _values.size(); i++)
{
String val = _values.get(i);
if (val != null)
_values.set(i, _values.get(i).substring(1));
}
}
public static void main(String[] args) throws Exception
{
Serializer serializer = new Persister();
File xmlFile = new File("test.xml");
TestData data = new TestData();
data.setValues(Arrays.asList("A", "", null));
serializer.write(data, xmlFile);
TestData sqlData = serializer.read(TestData.class, xmlFile);
System.out.println("values: " + sqlData.getValues());
}
}
|
|
From: <Nia...@ub...> - 2008-12-16 16:13:05
|
Hi,
Your suggestion should work fine. I think there may be another
alternative using a strategy, so that you could have.
<testData>
<_values class="java.util.Arrays$ArrayList">
<string>A</string>
<string null="false"></string>
<string null="true"></string>
</_values>
</testData>
This would basically involve adding an attribute to all elements where
the value to be written is null. Don't know if deserialization would
respect this though so I would have to investigate. Bottom line though
is that StAX does not treat <string></string> and </string> differently
which would have provided a really nice way to differentiate "" from
null.
Regards,
Niall
-----Original Message-----
From: Joe [mailto:fis...@ya...]
Sent: 16 December 2008 16:07
To: Gallagher, Niall-N
Cc: sim...@li...
Subject: Re: [Simple-support] erialize/deserialize Lists with empty
Strings
Hi,
> So it looks like if you really need the empty string "" then you will
> need to either treat null as a special case, or substitute "" for some
> token such as "NULL".
I think i will use a slightly different approach, inspired by the base64
encoding example in your tutorial.
I encode every value with a prefix (here '*') only null values are
ignored.
So
Arrays.asList("A", "", null)
will be serialized as:
<testData>
<_values class="java.util.Arrays$ArrayList">
<string>*A</string>
<string>*</string>
<string></string>
</_values>
</testData>
Using @Commit the deserialization can be adjusted, to getting back the
original values.
The output of the following example is the expected String:
values: [A, , null]
public class TestData
{
@ElementList()
private List<String> _values = new ArrayList<String>();
public List<String> getValues()
{
return _values;
}
public void setValues(List<String> values)
{
_values = values;
}
@Persist
public void persist()
{
for (int i = 0; i < _values.size(); i++)
if (_values.get(i) != null)
_values.set(i, "*" + _values.get(i));
else
_values.set(i, "");
}
@Commit
public void commit()
{
for (int i = 0; i < _values.size(); i++)
{
String val = _values.get(i);
if (val != null)
_values.set(i, _values.get(i).substring(1));
}
}
public static void main(String[] args) throws Exception
{
Serializer serializer = new Persister();
File xmlFile = new File("test.xml");
TestData data = new TestData();
data.setValues(Arrays.asList("A", "", null));
serializer.write(data, xmlFile);
TestData sqlData = serializer.read(TestData.class, xmlFile);
System.out.println("values: " + sqlData.getValues());
}
}
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.
|
|
From: <Nia...@ub...> - 2008-12-16 15:01:46
|
Hi,
Just to explain what is happening now, the first two entries are because
the ArrayList instance is being reused for efficiency and to allow
various types that do not have a no argument constructor to be used (e.g
EumSet). So when you serialize the empty string becomes
<string></string>
This is then deserialized as null, so it re-adds the ["A", null]. To the
existing ["A", ""]. So it looks like if you really need the empty string
"" then you will need to either treat null as a special case, or
substitute "" for some token such as "NULL".
Niall
-----Original Message-----
From: Joe [mailto:fis...@ya...]
Sent: 16 December 2008 14:53
To: sim...@li...
Subject: Re: [Simple-support] erialize/deserialize Lists with empty
Strings
Hi,
> Hi,
>
> What version are you using? Clearly not the latest 2.0.2? Also could
> you supply the XML that is generated?
>
yes 1.7.3, now updated to 2.0.2.
Now the printed output is a little bit different, but still reflecting
the null problem.
values: [A, , A, null]
The xml file(same in both versions)
<testData>
<values class="java.util.ArrayList">
<string>A</string>
<string></string>
</values>
</testData>
------------------------------------------------------------------------
------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas,
Nevada.
The future of the web can't happen without you. Join us at MIX09 to
help pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.
com/
_______________________________________________
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.
|
|
From: Joe <fis...@ya...> - 2008-12-16 14:52:55
|
Hi,
> Hi,
>
> What version are you using? Clearly not the latest 2.0.2? Also could you
> supply the XML that is generated?
>
yes 1.7.3, now updated to 2.0.2.
Now the printed output is a little bit different, but still reflecting
the null problem.
values: [A, , A, null]
The xml file(same in both versions)
<testData>
<values class="java.util.ArrayList">
<string>A</string>
<string></string>
</values>
</testData>
|
|
From: <Nia...@ub...> - 2008-12-16 14:24:27
|
Hi,
What version are you using? Clearly not the latest 2.0.2? Also could you
supply the XML that is generated?
Thanks,
Niall
-----Original Message-----
From: Joe [mailto:fis...@ya...]
Sent: 16 December 2008 13:56
To: sim...@li...
Subject: [Simple-support] erialize/deserialize Lists with empty Strings
Hi,
The following code prints:
values: [A, null]
Why null and not an empty String?
How can serialize/deserialize Lists with empty Strings?
thx
public class TestData
{
@ElementList(name = "values", required = false)
private List<String> _values = new ArrayList<String>();
TestData()
{
_values.add("A");
_values.add("");
}
List<String> getValues()
{
return _values;
}
public static void main(String[] args) throws Exception
{
Serializer serializer = new Persister();
File xmlFile = new File("test.xml");
serializer.write(new TestData(), xmlFile);
TestData sqlData = serializer.read(TestData.class, xmlFile);
System.out.println("values: " + sqlData.getValues());
}
}
------------------------------------------------------------------------
------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas,
Nevada.
The future of the web can't happen without you. Join us at MIX09 to
help pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.
com/
_______________________________________________
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.
|
|
From: <Nia...@ub...> - 2008-12-16 14:14:26
|
Hi,
Yes this is true. And here is why the empty string is a bit of a special
case. In XML the following two structures are equal, daft but true.
<string></string>
And
</string>
So how do you write an empty string as an element, versus null? Well for
@Attribute and @Text you will notice I have an empty() attribute for the
annotation so that if I were to write null I could have some form of
replacement like so.
@Attribute(empty="NULL")
private String field = null;
This would be written like so:
field="NULL"
So that deserialization knows to substitute "NULL" the string value with
a null. For elements its not as easy, perhaps there should be a similar
attribute for the @ElementList annotation. But for now, I am afraid the
empty string needs to be differentiated from null by some means. Usually
its best to use an @Persist and @Complete to replace "" values with
something so that they can be converted back to "" when read in again
using an @Commit method callback. Hope this helps.
Niall
-----Original Message-----
From: Joe [mailto:fis...@ya...]
Sent: 16 December 2008 13:56
To: sim...@li...
Subject: [Simple-support] erialize/deserialize Lists with empty Strings
Hi,
The following code prints:
values: [A, null]
Why null and not an empty String?
How can serialize/deserialize Lists with empty Strings?
thx
public class TestData
{
@ElementList(name = "values", required = false)
private List<String> _values = new ArrayList<String>();
TestData()
{
_values.add("A");
_values.add("");
}
List<String> getValues()
{
return _values;
}
public static void main(String[] args) throws Exception
{
Serializer serializer = new Persister();
File xmlFile = new File("test.xml");
serializer.write(new TestData(), xmlFile);
TestData sqlData = serializer.read(TestData.class, xmlFile);
System.out.println("values: " + sqlData.getValues());
}
}
------------------------------------------------------------------------
------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas,
Nevada.
The future of the web can't happen without you. Join us at MIX09 to
help pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.
com/
_______________________________________________
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.
|
|
From: Joe <fis...@ya...> - 2008-12-16 13:55:47
|
Hi,
The following code prints:
values: [A, null]
Why null and not an empty String?
How can serialize/deserialize Lists with empty Strings?
thx
public class TestData
{
@ElementList(name = "values", required = false)
private List<String> _values = new ArrayList<String>();
TestData()
{
_values.add("A");
_values.add("");
}
List<String> getValues()
{
return _values;
}
public static void main(String[] args) throws Exception
{
Serializer serializer = new Persister();
File xmlFile = new File("test.xml");
serializer.write(new TestData(), xmlFile);
TestData sqlData = serializer.read(TestData.class, xmlFile);
System.out.println("values: " + sqlData.getValues());
}
}
|
|
From: Niall G. <gal...@ya...> - 2008-12-12 13:05:06
|
Hi,
This issue has not been resolved in 2.0.2. You can now read EnumMap and EnumSet values annotated with @ElementMap and @ElementList. However, these must be instantiated initially. For example
@ElementMap
private EnumMap<Enumeration, String> map = new EnumMap<Enumeration, String>(Enumeration.class);
This will maintain the original instance and you will not see the exception thrown in 1.7.3 where it can not instantiate the EnumMap.
Regards,
Niall
--- On Sun, 11/23/08, Niall Gallagher <gal...@ya...> wrote:
> From: Niall Gallagher <gal...@ya...>
> Subject: Re: [Simple-support] Simple1.7.3 EnumMap deserialization bug
> To: "Rob Gilson" <rob...@ar...>, sim...@li...
> Cc: "Arise" <ar...@si...>
> Date: Sunday, November 23, 2008, 1:40 AM
> Hi,
>
> The only way to do it currently would be to use an @Commit
> annotation and pass it from a Map to an EnumMap.
>
> @Commit
> public void commit() {
> enumMap.putAll(normalMap);
> }
>
> Support for EnumMap objects will be added in an upcoming
> release.
>
> Niall
>
>
>
>
> ________________________________
> From: Rob Gilson <rob...@ar...>
> To: sim...@li...
> Cc: Arise <ar...@si...>
> Sent: Saturday, November 22, 2008 8:04:39 PM
> Subject: [Simple-support] Simple1.7.3 EnumMap
> deserialization bug
>
> Hi all,
> I've been working on a project which is heavily reliant
> on the Simple xml serialization library and I seem to have
> come across a problem in it's instantiation of EnumMaps.
> As many of you undoubtedly know EnumMaps do not have a zero
> parameter constructor rather they can only be constructed by
> passing the Class of the enum you wish to use due to the
> limitation of java Generics, my problem comes about as it
> seems Simple Xml is trying to use that non-existant
> EnumMap() constructor and is throwing a
> NoSuchMethodException. The stack trace (for
> deserialization, serialization works fine), if i allow java
> to step forward into the exception is as follows:
>
>
> Exception in thread "main"
> java.lang.NoSuchMethodException:
> java.util.EnumMap.<init>()
> at java.lang.Class.getConstructor0(Unknown Source)
> at java.lang.Class.getDeclaredConstructor(Unknown
> Source)
> at
> org.simpleframework.xml.load.ClassType.getInstance(ClassType.java:88)
> at
> org.simpleframework.xml.load.ClassType.getInstance(ClassType.java:72)
> at
> org.simpleframework.xml.load.CompositeMap.read(CompositeMap.java:109)
> at
> org.simpleframework.xml.load.Composite.read(Composite.java:354)
> at
> org.simpleframework.xml.load.Composite.readElement(Composite.java:334)
> at
> org.simpleframework.xml.load.Composite.readElements(Composite.java:250)
> at
> org.simpleframework.xml.load.Composite.read(Composite.java:194)
>
> Any help would be greatly appreciated. Also I just wanted
> to say thanks to the Simple team, you guys have done an
> awsome job with Simple, its very intuitive and very
> powerfull, the combination of which has saved me massive
> amounts of time on this project!
>
> Cheers,
> Rob
>
> My source code:
>
> /**
> *
> */
> package simpleXmlSandpit;
>
> import java.io.File;
> import java.util.EnumMap;
>
> import org.simpleframework.xml.ElementMap;
> import org.simpleframework.xml.Root;
> import org.simpleframework.xml.Serializer;
> import org.simpleframework.xml.load.Persister;
>
> /**
> * @author Rob Gilson, University of Ottawa CEG Student
> */
> @Root
> public class EnumTestSerialization {
> @ElementMap (required=false) public
> EnumMap<TestEnum, String> map = new
> EnumMap<TestEnum, String>(TestEnum.class);
> public static enum TestEnum
> {
> enumTest,
> otherTest
> }
>
> public EnumTestSerialization()
> {
> map.put(TestEnum.enumTest, "hello world this
> is the test #1");
> map.put(TestEnum.otherTest, "hello world this
> is the other test #2");
> }
>
> /**
> * serializes and subsiquently deserializes a object
> containing a enum map
> * to illustrate a potential bug in Simple 1.7.3
> * @param args unused.
> * @throws Exception if the serialization or
> deserialization fail.
> */
> public static void main(String[] args) throws Exception
> {
>
> java.io.File file = new
> File("example.xml");
> Serializer serializer = new Persister();
> EnumTestSerialization example;
>
> //Serialization
> example = new EnumTestSerialization();
> serializer.write(example, file);
>
> example = null;
>
> //Deserialization
> if (file.exists() == false)
> System.err.println("File does not exist!");
> //Exception is thrown here \/
> example =
> serializer.read(EnumTestSerialization.class, file);
> //Exception is thrown here /\
>
> System.out.println(example.map.get(TestEnum.enumTest));
>
> System.exit(1);
> }
>
> }
>
>
>
> -------------------------------------------------------------------------
> 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
|
|
From: Niall G. <gal...@ya...> - 2008-12-11 19:36:58
|
This sounds interesting, so just embed XML like so?
@Literal
public String getBlah() {
return myXmlLiteralText;
}
So do you handle this in reading, is it required, do you validate against it? Also I was thinking about being able to annotate
@Attribute
private static final String blah = "XXX"
This
will allow you to specify some static parts. That you don't read, but
write. But with this do you validate, is it required? Also for XML
literal strings are there other frameworks that use this? It would be
good to see how it works elsewhere, but sounds interesting. I think in
general there should be more ways to manipulate various XML structures
in to an object model that does not match the object type for elemenet.
For example the XmlElementWrapper is a nice feature in JAXB.
Niall
________________________________
From: Mirza Abbas Raza <abb...@ya...>
To: Niall Gallagher <gal...@ya...>; sim...@li...
Sent: Thursday, December 11, 2008 6:37:33 PM
Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization
Just an idea - this is with just initial thought without looking at Simple's serialization code. Can we have an annotation like '@XmlLiteral', which basically just injects a literal xml element tag? Ofcourse, the client code is responsible for keeping the literal well formed. Thoughts?
________________________________
From: Niall Gallagher <gal...@ya...>
To: Niall Gallagher <gal...@ya...>; Mirza Abbas Raza <abb...@ya...>; sim...@li...
Sent: Wednesday, December 10, 2008 3:10:56 PM
Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization
Sorry, where I said "This is not detached from your object model" I meant "This is not atttached from your object model".
Niall
________________________________
From: Niall Gallagher <gal...@ya...>
To: Mirza Abbas Raza <abb...@ya...>; sim...@li...
Sent: Wednesday, December 10, 2008 11:09:04 PM
Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization
Hi,
Well here is what I am thinking. Are you going to be writing more or less code to add static data to the document. I mean if I were to write a decorator that would match the element name or class to complement the attributes and elements like so.
public void decorate(OutputNode node) {
if(x) {
node.addSomething();
} else {
node.addSomethingElse();
}
}
This is not detached from your object model, ant it will be much harder to maintain. Take XStream where the XML structure is not attached to the object. You have to bind by somethiing else, things become difficult to trace. In what way is it associated and how to you know it is. Do you follow the call hierarchies, do you trace the types matched, is it obvious to someone that is new to this code. I would imagine not. It is scattered code, not fundamentally associated with your object model. You just end up writing more code. I realise adding redundant fields or methods is not ideal for your code. But is there any way that involves less coding and is more obvious? I can't think of any simple way to do this that requires less effort and is more obvious than annotating a field. I you can I am very interested.
Look forward to hearing your suggestions,
Niall
________________________________
From: Mirza Abbas Raza <abb...@ya...>
To: Niall Gallagher <gal...@ya...>; sim...@li...
Sent: Wednesday, December 10, 2008 10:19:37 PM
Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization
First off, thanks for the quick reply. The elements typeId, templateId, id, code etc. sprayed around in the document are static. They do not change. Rest of the other elements like custodian, participant etc. are dynamic. The static content has to be be just sticked in. I have not thought in detail about how I would inject in those static elements. Probably I will have objects that read the text literals from a configuration file and have them as instance variables. This is just a thought at this point. Suggestions?
Thanks!
________________________________
From: Niall Gallagher <gal...@ya...>
To: Mirza Abbas Raza <abb...@ya...>; sim...@li...
Sent: Wednesday, December 10, 2008 11:48:12 AM
Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization
Hi,
Took a look at the document, it looks pretty easy to parse. However, I
am not sure what you mean by static content? What difference has this
to the dynamic content, that it does not change? If so what do you need
to achieve, and how do you envision handling static content and how would it differ from dynamic content?
Regards,
Niall
________________________________
From: Mirza Abbas Raza <abb...@ya...>
To: sim...@li...
Sent: Wednesday, December 10, 2008 7:23:18 PM
Subject: [Simple-support] Any suggestion for static and dynamic xml content serialization
Hi,
In the XML that I have to serialize, the content is roughly 20% static (Standardized IDs and such) and 80% dynamic. The document in question is the Continuity of Care Document (http://www.himssehrva.org/ASP/CCD_QSG_20071112.asp). I am debating using XSLT/XSD based serializers or annotation based libraries. With XSLT based serializers, the nice thing is that the static content can easily be extracted out in the XSLT. However, the performance takes the hit with the process of creating the XML in the first place and doing the transformation. Also, one would have to maintain the XSLT. On the other hand, with Simple, we would not have to maintain any XMLs/XSLTs and the performance would be better on the premise that there are fewer steps involved in serialization. The only downside I see is to produce static content in Java. Is there any mechanism that Simple can provide to handle this issue? At this point, from the tutorial, I did not find one. Appreciate
any help.
Thanks,
Abbas
|
|
From: Mirza A. R. <abb...@ya...> - 2008-12-11 18:37:38
|
Just an idea - this is with just initial thought without looking at Simple's serialization code. Can we have an annotation like '@XmlLiteral', which basically just injects a literal xml element tag? Ofcourse, the client code is responsible for keeping the literal well formed. Thoughts?
________________________________
From: Niall Gallagher <gal...@ya...>
To: Niall Gallagher <gal...@ya...>; Mirza Abbas Raza <abb...@ya...>; sim...@li...
Sent: Wednesday, December 10, 2008 3:10:56 PM
Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization
Sorry, where I said "This is not detached from your object model" I meant "This is not atttached from your object model".
Niall
________________________________
From: Niall Gallagher <gal...@ya...>
To: Mirza Abbas Raza <abb...@ya...>; sim...@li...
Sent: Wednesday, December 10, 2008 11:09:04 PM
Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization
Hi,
Well here is what I am thinking. Are you going to be writing more or less code to add static data to the document. I mean if I were to write a decorator that would match the element name or class to complement the attributes and elements like so.
public void decorate(OutputNode node) {
if(x) {
node.addSomething();
} else {
node.addSomethingElse();
}
}
This is not detached from your object model, ant it will be much harder to maintain. Take XStream where the XML structure is not attached to the object. You have to bind by somethiing else, things become difficult to trace. In what way is it associated and how to you know it is. Do you follow the call hierarchies, do you trace the types matched, is it obvious to someone that is new to this code. I would imagine not. It is scattered code, not fundamentally associated with your object model. You just end up writing more code. I realise adding redundant fields or methods is not ideal for your code. But is there any way that involves less coding and is more obvious? I can't think of any simple way to do this that requires less effort and is more obvious than annotating a field. I you can I am very interested.
Look forward to hearing your suggestions,
Niall
________________________________
From: Mirza Abbas Raza <abb...@ya...>
To: Niall Gallagher <gal...@ya...>; sim...@li...
Sent: Wednesday, December 10, 2008 10:19:37 PM
Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization
First off, thanks for the quick reply. The elements typeId, templateId, id, code etc. sprayed around in the document are static. They do not change. Rest of the other elements like custodian, participant etc. are dynamic. The static content has to be be just sticked in. I have not thought in detail about how I would inject in those static elements. Probably I will have objects that read the text literals from a configuration file and have them as instance variables. This is just a thought at this point. Suggestions?
Thanks!
________________________________
From: Niall Gallagher <gal...@ya...>
To: Mirza Abbas Raza <abb...@ya...>; sim...@li...
Sent: Wednesday, December 10, 2008 11:48:12 AM
Subject: Re: [Simple-support] Any suggestion for static and dynamic xml content serialization
Hi,
Took a look at the document, it looks pretty easy to parse. However, I
am not sure what you mean by static content? What difference has this
to the dynamic content, that it does not change? If so what do you need
to achieve, and how do you envision handling static content and how would it differ from dynamic content?
Regards,
Niall
________________________________
From: Mirza Abbas Raza <abb...@ya...>
To: sim...@li...
Sent: Wednesday, December 10, 2008 7:23:18 PM
Subject: [Simple-support] Any suggestion for static and dynamic xml content serialization
Hi,
In the XML that I have to serialize, the content is roughly 20% static (Standardized IDs and such) and 80% dynamic. The document in question is the Continuity of Care Document (http://www.himssehrva.org/ASP/CCD_QSG_20071112.asp). I am debating using XSLT/XSD based serializers or annotation based libraries. With XSLT based serializers, the nice thing is that the static content can easily be extracted out in the XSLT. However, the performance takes the hit with the process of creating the XML in the first place and doing the transformation. Also, one would have to maintain the XSLT. On the other hand, with Simple, we would not have to maintain any XMLs/XSLTs and the performance would be better on the premise that there are fewer steps involved in serialization. The only downside I see is to produce static content in Java. Is there any mechanism that Simple can provide to handle this issue? At this point, from the tutorial, I did not find one. Appreciate
any help.
Thanks,
Abbas |
|
From: Niall G. <gal...@ya...> - 2008-12-11 10:14:58
|
Hi,
You can do it, however Simple currently binds elements to fields or methods using the element name. And these are typed strongly. There are two ways to do what you want to do. The first is to do something like.
@Root
private static class Value {
@Element(name="boolean", required=false)
private Boolean booleanValue;
@Element(name="byte", required=false)
private Byte byteValue;
@Element(name="double", required=false)
private Double doubleValue;
@Element(name="float", required=false)
private Float floatValue;
@Element(name="int", required=false)
private Integer intValue;
@Element(name="long", required=false)
private Long longValue;
@Element(name="short", required=false)
private Short shortValue;
@Element(name="dateTime", required=false)
private Date dateTime;
@Element(name="string", required=false)
private String string;
@Transient
private Object value;
@Validate
private void commit() {
if(booleanValue != null) {
value = booleanValue;
}
if(byteValue != null) {
value = byteValue;
}
if(doubleValue != null) {
value = doubleValue;
}
if(floatValue != null) {
value = floatValue;
}
if(intValue != null) {
value = intValue;
}
if(longValue != null) {
value = longValue;
}
if(shortValue != null) {
value = shortValue;
}
if(dateTime != null) {
value = dateTime;
}
if(string != null) {
value = string;
}
}
public Object get() {
return value;
}
public void set(Object value) {
this.value = value;
}
}
@Root
private static class Properties {
@ElementMap(key="key", value="value", inline=true)
private Map<String, Value> map;
public Object get(String name) {
return map.get(name).get();
}
The other is to create your own Strategy that will bind the type String.class to "string", Boolean.class to "boolean" and so on. This is more involved and there are examples of how to do it in the test cases bundled with the download.
Niall
________________________________
From: Kin Onn Low <ko...@ap...>
To: sim...@li...
Sent: Thursday, December 11, 2008 4:48:11 AM
Subject: [Simple-support] Customizing ElementMap serializer/deserializer
Hello,
I’m new to Simple and is currently evaluating it for
use in a project.
I have an existing XML and would like to deserialize it into
a map (Map<String,Object>):
<properties>
<entry>
<key>boolean-value</key>
<value>
<boolean>true</boolean>
</value>
</entry>
<entry>
<key>string-value</key>
<value>
<string>hello world</string>
</value>
</entry>
<entry>
<key>intvalue</key>
<value>
<int>42</int>
</value>
</entry>
</properties>
The value type can be one of the following:
<boolean>?</boolean>
<byte>?</byte>
<double>?</double>
<float>?</float>
<int>?</int>
<long>?</long>
<short>?</short>
<dateTime>?</dateTime>
<string>?</string>
So far, the closest I’ve been able to get to is this:
<properties
class="java.util.HashMap">
<entry>
<key>boolean-value</key>
<value
class="java.lang.Boolean">true</value>
</entry>
<entry>
<key>string-value</key>
<value
class="java.lang.String">hello world</value>
</entry>
<entry>
<key>intvalue</key>
<value
class="java.lang.Integer">42</value>
</entry>
</properties>
@ElementMap (inline=false,
key="key", value="value")
private Map<String, Object>
properties;
Is it possible to override default map
deserializer/serializer to handle the input XML which I have?
Thanks!
|
|
From: Kin O. L. <ko...@ap...> - 2008-12-11 05:19:22
|
Hello,
I'm new to Simple and is currently evaluating it for use in a project.
I have an existing XML and would like to deserialize it into a map
(Map<String,Object>):
<properties>
<entry>
<key>boolean-value</key>
<value>
<boolean>true</boolean>
</value>
</entry>
<entry>
<key>string-value</key>
<value>
<string>hello world</string>
</value>
</entry>
<entry>
<key>intvalue</key>
<value>
<int>42</int>
</value>
</entry>
</properties>
The value type can be one of the following:
<boolean>?</boolean>
<byte>?</byte>
<double>?</double>
<float>?</float>
<int>?</int>
<long>?</long>
<short>?</short>
<dateTime>?</dateTime>
<string>?</string>
So far, the closest I've been able to get to is this:
<properties class="java.util.HashMap">
<entry>
<key>boolean-value</key>
<value class="java.lang.Boolean">true</value>
</entry>
<entry>
<key>string-value</key>
<value class="java.lang.String">hello world</value>
</entry>
<entry>
<key>intvalue</key>
<value class="java.lang.Integer">42</value>
</entry>
</properties>
@ElementMap (inline=false, key="key", value="value")
private Map<String, Object> properties;
Is it possible to override default map deserializer/serializer to handle
the input XML which I have?
Thanks!
|