simple-support Mailing List for Simple (Page 10)
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: Niall G. <gal...@ya...> - 2012-12-27 00:32:54
|
Use the @ElementUnion or @ElementListUnion to process ANY. --- On Wed, 26/12/12, Jaewoo Lee <dl...@gm...> wrote: > From: Jaewoo Lee <dl...@gm...> > Subject: [Simple-support] about Class Type sensing > To: sim...@li... > Received: Wednesday, 26 December, 2012, 1:11 AM > Hi, > I'm converting from javax to simple > framework.I have a question about > that. > > this is original xml > source.-------------------------------------------------------------------- > > <observation > classCode="OBS" moodCode="EVN"> > ..... > <value > xsi:type="CD"...> > </value> > ..... <entryRelationship > typeCode="REFR"> > <observation > classCode="OBS" > moodCode="EVN"> > <value xsi:type="CE"... > /> > </observation></observation> > > > ---------------------------------------------------------------------- > > and this is schema source about > observation > class.---------------------------------------------------------------------- > > > <xs:complexType > name="POCD_MT000040.Observation"> <xs:sequence> > .... > <xs:element > name="value" type="ANY" > minOccurs="0" > maxOccurs="unbounded"/> ..... > </xs:sequence> ....</xs:complexType> > ---------------------------------------------------------------------- > > > > "value" type is defined as > "ANY" type in schemabut > "CD" and "CE" classes are sub class of > "ANY". > > Q1. If i define > "value" as "ANY" type, is there any way > to sense automatically appropriate its own type, like > "CD" or "CE"? > > Q2. If not, how do i tag their types like that case > according their situation? > Thank you so much for your > help. > > -----Inline Attachment Follows----- > > ------------------------------------------------------------------------------ > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. > Free Trial > Remotely access PCs and mobile devices and provide instant > support > Improve your efficiency, and focus on delivering more > value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > -----Inline Attachment Follows----- > > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > |
|
From: Niall G. <gal...@ya...> - 2012-12-27 00:31:33
|
I don't think you need either to parse the XML in your mail. Parsing with normal annotations will work. Also as of 2.6.9 there is in build ability to grab floating text in the InputNode, so you don't need the hack job. --- On Wed, 26/12/12, Jaewoo Lee <dl...@gm...> wrote: > From: Jaewoo Lee <dl...@gm...> > Subject: [Simple-support] about Element OR Text > To: sim...@li... > Received: Wednesday, 26 December, 2012, 12:51 AM > Hi, I'm converting from > javax to simple framework.I have a question > about that. > this is original xml source. > .... > > <tr> > <td>Resuscitation status</td> > <td> > <content ID="AD1">Do not > resuscitate</content> > </td> > <td>Dr. Robert Dolin, Nov 07, > 1999</td> > <td> > <linkHtml > href="AdvanceDirective.b50b7910-7ffb-4f4c-bbe4-177ed68cbbf3.pdf">Advance > directive</linkHtml> > </td> > > </tr>.... > I saw the example > "HackJobToGrabFloatingTextTest", but I am not sure > whether I have to implement like that example. > cuz I only need ONE node between element OR > text. > Q1. Should I use Converter class > in this case? > Q2. If i should use converter > class like "HackJobToGrabFloatingTextTest", is it > possible to implement like original code? > and if yes, could you explain in more > details? > Thank you so much for your > help. > > -----Inline Attachment Follows----- > > ------------------------------------------------------------------------------ > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. > Free Trial > Remotely access PCs and mobile devices and provide instant > support > Improve your efficiency, and focus on delivering more > value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > -----Inline Attachment Follows----- > > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > |
|
From: Niall G. <gal...@ya...> - 2012-12-26 09:39:10
|
There is a way, however it involves the lower level stream XML API. You would need to wrap the InputNode with something of your own to filter out these things. See org.simpleframework.xml.stream.InputNode. --- On Mon, 24/12/12, Dody Gunawinata <emp...@gm...> wrote: > From: Dody Gunawinata <emp...@gm...> > Subject: [Simple-support] Duplicate element error > To: sim...@li... > Received: Monday, 24 December, 2012, 6:33 AM > I encounter the same exact > problem as this posting http://stackoverflow.com/questions/5973028/simple-xml-element-declared-twice-error > > > public class Channel { > @Element(required = false, name = > "link") @Namespace > public String link; } > > will generate > Element 'link' is already used > with @org.simpleframework.xml.Element(data=false, name=link, > required=false, type=void) on field 'link' > > > if it encounters > <link> and<atom:link>. > I don't care about the atom:link. Is > there anyway to scope the link property to just care about > the default namespace? > > > -- > nomadlife.org > > > > -----Inline Attachment Follows----- > > ------------------------------------------------------------------------------ > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. > Free Trial > Remotely access PCs and mobile devices and provide instant > support > Improve your efficiency, and focus on delivering more > value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > -----Inline Attachment Follows----- > > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > |
|
From: Jaewoo L. <dl...@gm...> - 2012-12-26 09:11:47
|
Hi, I'm converting from javax to simple framework.
I have a question about that.
this is original xml source.
--------------------------------------------------------------------
<observation classCode="OBS" moodCode="EVN">
.....
<value xsi:type="CD"...>
</value>
.....
<entryRelationship typeCode="REFR">
<observation classCode="OBS" moodCode="EVN">
<value xsi:type="CE"... />
</observation>
</observation>
----------------------------------------------------------------------
and this is schema source about observation class.
----------------------------------------------------------------------
<xs:complexType name="POCD_MT000040.Observation">
<xs:sequence>
....
<xs:element name="value" type="ANY" minOccurs="0" maxOccurs="unbounded"/>
.....
</xs:sequence>
....
</xs:complexType>
----------------------------------------------------------------------
"value" type is defined as "ANY" type in schema
but "CD" and "CE" classes are sub class of "ANY".
*Q1. *If i define "value" as "ANY" type, is there any way to sense
automatically appropriate its own type, like "CD" or "CE"?
*Q2. *If not, how do i tag their types like that case according their
situation?
Thank you so much for your help.
|
|
From: Jaewoo L. <dl...@gm...> - 2012-12-26 08:51:42
|
Hi, I'm converting from javax to simple framework.
I have a question about that.
this is original xml source.
....
<tr>
<td>Resuscitation status</td>
<td>
<content ID="AD1">Do not resuscitate</content>
</td>
<td>Dr. Robert Dolin, Nov 07, 1999</td>
<td>
<linkHtml
href="AdvanceDirective.b50b7910-7ffb-4f4c-bbe4-177ed68cbbf3.pdf">Advance
directive</linkHtml>
</td>
</tr>
....
I saw the example "HackJobToGrabFloatingTextTest", but I am not sure
whether I have to implement like that example.
cuz I only need ONE node between element OR text.
*Q1.* Should I use Converter class in this case?
*Q2. *If i should use converter class like "HackJobToGrabFloatingTextTest",
is it possible to implement like original code?
and if yes, could you explain in more details?
Thank you so much for your help.
|
|
From: Dody G. <emp...@gm...> - 2012-12-24 14:33:59
|
I encounter the same exact problem as this posting http://stackoverflow.com/questions/5973028/simple-xml-element-declared-twice-error public class Channel { @Element(required = false, name = "link") @Namespace public String link; } will generate Element 'link' is already used with @org.simpleframework.xml.Element(data=false, name=link, required=false, type=void) on field 'link' if it encounters <link> and <atom:link>. I don't care about the atom:link. Is there anyway to scope the link property to just care about the default namespace? -- nomadlife.org |
|
From: Wolfgang F. <wf...@bi...> - 2012-12-20 06:17:45
|
Niall's suggestion does the trick. I have posted the solution on Stackoverflow (see link above). -- View this message in context: http://old.nabble.com/Two-Phase-support-for-CycleStrategy--tp34802791p34818203.html Sent from the Simple XML Serialization mailing list archive at Nabble.com. |
|
From: Niall G. - Y. <Nia...@yi...> - 2012-12-18 22:45:24
|
Should be fairly easy to do with something like the CycleStrategy. Just create MyCycleStrategy and where there is an exception with "Invalid reference" just return null and remember the reference. When you have picked up all the ids and the values then do a second pass. In the second pass assign the value to the first occurrence of either the ref or the id. Then all following references should be given the same value. This should work. -----Original Message----- From: Wolfgang Fahl [mailto:wf...@bi...] Sent: Tuesday, 18 December 2012 11:51 PM To: sim...@li... Subject: Re: [Simple-support] Two-Phase support for CycleStrategy? There is a question on Stackoverflow now documenting how far I got so far: http://stackoverflow.com/questions/13933314/simple-xml-reference-resolving -- View this message in context: http://old.nabble.com/Two-Phase-support-for-CycleStrategy--tp34802791p34810190.html Sent from the Simple XML Serialization mailing list archive at Nabble.com. ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Wolfgang F. <wf...@bi...> - 2012-12-18 12:50:52
|
There is a question on Stackoverflow now documenting how far I got so far: http://stackoverflow.com/questions/13933314/simple-xml-reference-resolving -- View this message in context: http://old.nabble.com/Two-Phase-support-for-CycleStrategy--tp34802791p34810190.html Sent from the Simple XML Serialization mailing list archive at Nabble.com. |
|
From: Lukas L. <luk...@gm...> - 2012-12-17 15:43:27
|
Hi everyone,
I've got a 3-dimensional array of double to represent a matrix with values
depending on 3 parameters ( double[][][] matrix; ). Now I would like to
save this to XML using @ElementArray. Unfortunately it doesn't work
properly and I'll get an xml-code like this:
<matrix3D _abbreviation="COP">
<_dimension>3</_dimension>
<_matrix length="2">
<double[] length="4">2.14, -1.0, -1.0, 2.14, -1.0, -1.0, 2.14, -1.0,
-1.0, 2.14, -1.0, -1.0</double[]>
<double[] length="4">-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 2.73,
-1.0, -1.0, 2.73, -1.0</double[]>
</_matrix>
</matrix3D>
so the last double is not splittet properly. The -1.0 values are all right.
With a double[][] it works fine.
For me the only way that works is to convert the double[][][] into an array
of an object, which holds a 2 dimensional array of double ( double[][]
matrix2D; ), but that is kind of pedestrian ;)
Does anyone have an other idea?
Thanks a lot in advance,
Lukas
|
|
From: Wolfgang F. <wf...@bi...> - 2012-12-17 08:57:51
|
Dear Niall, thank you for the answer. After a few hours of trying i had a break yesterday night to think the solution over. I am having trouble accessing the unmarshalled data. The code below does not work as expected (Two Path Strategy). The issue is that there is no direct access to readInstance in the Strategy Interface - also the Visitor would not allow to access things. So the Value is not read when I need it to put it in to the lookup map. I do not want to rewrite the whole CycleStrategy and I doubt whether it would work as expected. This morning I tried the equivalent JaxB approach and it worked like a charm (see ModelElementMarshallerListener). All i had todo was unmarshalling twice. The first unmarshall picks up all objects by id the second unmarshall uses them to lookup references. So personally I think it would be great if setListener would be available on the Persister in the standard javax.xml.bind way. This would make life simple. The only drawback would be to actually have a "ref" attribute in the base class but this is o.k. for me since I use Implementations and Interfaces (see my other question about using Guice on stackoverflow http://stackoverflow.com/questions/13899475/interface-handling-in-simple-xml-framework-with-guice and the ref attribute could be hidden (as it is in the JaxB version of the problem). /** * intercept the unmarshalling (JaxB) */ public static class ModelElementMarshallerListener extends javax.xml.bind.Unmarshaller.Listener { public Map<String,ModelElementJaxbDao> lookup=new HashMap<String,ModelElementJaxbDao>(); @Override public void afterUnmarshal(java.lang.Object target, java.lang.Object parent) { if (target instanceof ModelElementJaxbDao) { ModelElementJaxbDao me=(ModelElementJaxbDao) target; if (me.getId()!=null) { System.err.println("id: "+me.getId()); lookup.put(me.getId(), me); } if (me.getRef()!=null) { if (lookup.containsKey(me.getRef())) { ModelElementJaxbDao meRef=lookup.get(me.getRef()); me.copyFrom(meRef); System.err.println("ref: "+me.getRef()+"->"+me.getId()); me.setRef(null); } else { System.err.println("ref: "+me.getRef()+"?"); } } } } /** * Callback method invoked after unmarshalling XML data into target. */ @Override public void beforeUnmarshal(java.lang.Object target, java.lang.Object parent) { } } // ModelElementMarshallerListener /** * Two Path Strategy * * @author wf * */ public static class TwoPathStrategy implements Strategy { /** * show debug information * * @param title * @param key * @param value */ public void showDebug(String title, String key, Value value) { String id = "?"; Object v=value; while ((v instanceof Value) && ((Value)v).isReference()) { v=((Value)v).getValue(); } if (v == null) { id = "null"; } else { if (v instanceof ModelElement) { ModelElement me = (ModelElement) v; id = me.getId(); } } System.err.println(title + ":" + key + "->" + v.getClass().getSimpleName() + ":" + value.getType().getSimpleName() + ":" + value.isReference() + ":" + id); } public Map<String, Value> lookup = new HashMap<String, Value>(); private final CycleStrategy strategy; public TwoPathStrategy() { // strategy = new AnnotationStrategy(); strategy=new CycleStrategy("id", "refXYZ"); // strategy=new TreeStrategy(); } @Override public Value read(Type type, NodeMap<InputNode> node, Map map) throws Exception { Node refNode = node.remove("ref"); Node keyNode = node.get("id"); Value value = strategy.read(type, node, map); if (refNode != null) { String key = refNode.getValue(); if (lookup.containsKey(key)) { value = lookup.get(key); showDebug("ref", key, value); } else { System.err.println("ref: " + key + "?"); } } if (keyNode != null) { String key = keyNode.getValue(); if (lookup.containsKey(key)) { value = lookup.get(key); showDebug("id (lookup)", key, value); } else if (value != null) { showDebug("id", key, value); lookup.put(key, value); } } return value; } @Override public boolean write(Type type, Object value, NodeMap<OutputNode> node, Map map) throws Exception { return strategy.write(type, value, node, map); } } Yours Wolfgang Am 17.12.12 08:51, schrieb Niall Gallagher: > It would be up to you, there are a number of ways you could do it. Look at the current CycleStrategy to see how it manages references. I think it would be tricky to do but possible. > > --- On Sun, 16/12/12, Wolfgang Fahl <wf...@bi...> wrote: > >> From: Wolfgang Fahl <wf...@bi...> >> Subject: [Simple-support] Two-Phase support for CycleStrategy? >> To: sim...@li... >> Received: Sunday, 16 December, 2012, 5:16 AM >> Dear Niall and other readers, >> >> as an old forum thread points out: >> http://old.nabble.com/Invalid-reference-td33813232.html#a33813232 >> >> ther error: >> >> Invalid reference '39F1829A0306' found >> org.simpleframework.xml.strategy.CycleException: Invalid >> reference >> '39F1829A0306' found >> >> is due to the fact that ref's can only point to already >> defined ids. >> >> Since I can not guarantee this in the XML files I need to >> read in I have >> thought about a two phase solution: >> In the first phase instead of throwing Cycle Exceptions all >> cases where >> the derereference can't be done are collected. >> In the second phase the dereferencing is done when all >> references are >> available. >> >> What would be the best way to achieve this two phase >> approach? >> >> Yours >> Wolfgang >> >> -- >> >> BITPlan - smart solutions >> Wolfgang Fahl >> Pater-Delp-Str. 1, D-47877 Willich Schiefbahn >> Tel. +49 2154 811-480, Fax +49 2154 811-481 >> Web: http://www.bitplan.de >> BITPlan GmbH, Willich - HRB 6820 Krefeld, Steuer-Nr.: >> 10258040548, Geschäftsführer: Wolfgang Fahl >> >> >> ------------------------------------------------------------------------------ >> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. >> Free Trial >> Remotely access PCs and mobile devices and provide instant >> support >> Improve your efficiency, and focus on delivering more >> value-add services >> Discover what IT Professionals Know. Rescue delivers >> http://p.sf.net/sfu/logmein_12329d2d >> _______________________________________________ >> Simple-support mailing list >> Sim...@li... >> https://lists.sourceforge.net/lists/listinfo/simple-support >> -- BITPlan - smart solutions Wolfgang Fahl Pater-Delp-Str. 1, D-47877 Willich Schiefbahn Tel. +49 2154 811-480, Fax +49 2154 811-481 Web: http://www.bitplan.de BITPlan GmbH, Willich - HRB 6820 Krefeld, Steuer-Nr.: 10258040548, Geschäftsführer: Wolfgang Fahl |
|
From: Niall G. <gal...@ya...> - 2012-12-17 07:51:58
|
It would be up to you, there are a number of ways you could do it. Look at the current CycleStrategy to see how it manages references. I think it would be tricky to do but possible. --- On Sun, 16/12/12, Wolfgang Fahl <wf...@bi...> wrote: > From: Wolfgang Fahl <wf...@bi...> > Subject: [Simple-support] Two-Phase support for CycleStrategy? > To: sim...@li... > Received: Sunday, 16 December, 2012, 5:16 AM > Dear Niall and other readers, > > as an old forum thread points out: > http://old.nabble.com/Invalid-reference-td33813232.html#a33813232 > > ther error: > > Invalid reference '39F1829A0306' found > org.simpleframework.xml.strategy.CycleException: Invalid > reference > '39F1829A0306' found > > is due to the fact that ref's can only point to already > defined ids. > > Since I can not guarantee this in the XML files I need to > read in I have > thought about a two phase solution: > In the first phase instead of throwing Cycle Exceptions all > cases where > the derereference can't be done are collected. > In the second phase the dereferencing is done when all > references are > available. > > What would be the best way to achieve this two phase > approach? > > Yours > Wolfgang > > -- > > BITPlan - smart solutions > Wolfgang Fahl > Pater-Delp-Str. 1, D-47877 Willich Schiefbahn > Tel. +49 2154 811-480, Fax +49 2154 811-481 > Web: http://www.bitplan.de > BITPlan GmbH, Willich - HRB 6820 Krefeld, Steuer-Nr.: > 10258040548, Geschäftsführer: Wolfgang Fahl > > > ------------------------------------------------------------------------------ > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. > Free Trial > Remotely access PCs and mobile devices and provide instant > support > Improve your efficiency, and focus on delivering more > value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > |
|
From: Wolfgang F. <wf...@bi...> - 2012-12-16 13:17:08
|
Dear Niall and other readers, as an old forum thread points out: http://old.nabble.com/Invalid-reference-td33813232.html#a33813232 ther error: Invalid reference '39F1829A0306' found org.simpleframework.xml.strategy.CycleException: Invalid reference '39F1829A0306' found is due to the fact that ref's can only point to already defined ids. Since I can not guarantee this in the XML files I need to read in I have thought about a two phase solution: In the first phase instead of throwing Cycle Exceptions all cases where the derereference can't be done are collected. In the second phase the dereferencing is done when all references are available. What would be the best way to achieve this two phase approach? Yours Wolfgang -- BITPlan - smart solutions Wolfgang Fahl Pater-Delp-Str. 1, D-47877 Willich Schiefbahn Tel. +49 2154 811-480, Fax +49 2154 811-481 Web: http://www.bitplan.de BITPlan GmbH, Willich - HRB 6820 Krefeld, Steuer-Nr.: 10258040548, Geschäftsführer: Wolfgang Fahl |
|
From: Dennis B. <bij...@gm...> - 2012-12-06 10:51:32
|
Dear moonlightcheese,
The script still works, just tested on Ubuntu precise.
You may need to change the path to sed in the first line of the script.
> > #!/bin/sed -f
Change the path to where sed is on your system, or call the script with
sed (e.g. /usr/bin/sed -f ../jaxb2simple.sed [filename] > simple/[filename]).
I am not aware of other tools to generate simple-xml java from xsd either.
I get inquiries about my SED script once in a while.
Kind regards,
Dennis
* moonlightcheese <moo...@gm...> [700101 01:00]:
> did you actually test this? running:
> ../jaxb2simple.sed [filename] > simple/[filename]
> from 'generated' dir on Ubuntu Linux generates:
> : No such file or directorye
> this doesn't work at all. seems like sed is failing? no clue.
> (i know this thread is old, but there are no tools at all built for this
> purpose that i could find. you would think someone would have written
> something for Simple by now that generates classes from .xsd files, but it
> hasn't happened yet.)
|
|
From: Niall G. <gal...@ya...> - 2012-12-06 10:13:01
|
Hi,
I have answered where I could, I am not familiar with some of the more obscure JAXB annotations.
> 1. Translation
> missing.
>
>
>
>
> @XmlType(name
> = "",
> propOrder = {
>
> "lala"
>
>
> })
>
This looks like its a mix of two Simple annotations
@Root
@Order(elements="lala")
>
> 2. Translation
> missing.
>
>
> @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
>
>
> @XmlSchemaType(name
> = "NMTOKEN")
>
@Convert(CollapsedStringConverter.class)
Here you will need a special Strategy implementation called AnnotationStrategy. See the tutorial or javadoc for more info.
>
> 3. Translation missing + need to get rid of
> JAXBElement.
>
>
>
>
> @XmlElementDecl(namespace
> = "",
> name = "SerialNumber",
> scope = TCompatibility.class)
>
>
> public
> JAXBElement<TCompatibilityExpression>
> createTCompatibilitySerialNumber(TCompatibilityExpression
> value) {
>
> return
> new
> JAXBElement<TCompatibilityExpression>(_TCompatibilitySerialNumber_QNAME,
> TCompatibilityExpression.class,
> TCompatibility.class,
> value);
>
> }
>
Not sure about this, but namespaces are @Namespace(prefix="xx", reference="http://blah.blah")
> 4. Translation missing.
>
>
>
> @XmlSeeAlso({
>
>
>
> TArrayTypeNamed.class
>
>
> })
>
This contributes nothing from what I know, just ignore it.
>
> 5. Translation missing.
>
> @XmlElements({
>
>
> @Element(required=false,name
> = "PatternGroup",
> type = TPatternGroup.class),
>
>
> @Element(required=false,name
> = "Pattern",
> type = TPattern.class)
>
>
> })
>
@ElementUnion({
@Element(name="PatternGroup", type=TPatternGroup.class),
@Element(name="Pattern, type=TPattern.class)
})
>
> 6. Translation missing + need to get rid of
> JAXBElement.
>
>
>
>
> @XmlElementRefs({
>
>
> @XmlElementRef(name
> = "lala",
> type = JAXBElement.class),
>
>
> @XmlElementRef(name
> = "lulu",
> type = JAXBElement.class),
>
>
> @XmlElementRef(name
> = "haha",
> type = JAXBElement.class),
>
>
> @XmlElementRef(name
> = "mmmh",
> type = JAXBElement.class)
>
>
> })
>
> protected
> List<JAXBElement<TCompatibilityExpression>>
> deviceXXX;
>
Again look at @ElementUnion
>
> 7. Translation missing.
>
>
>
>
> @XmlValue
>
>
> protected
> String value;
>
@Text i think
>
>
> 8. Translation missing.
>
>
>
> @XmlElements({
>
>
> @Element(required=false,name
> = "Variable",
> type = TVariable.class),
>
>
> @Element(required=false,name
> = "MethodIn",
> type = TMethodIn.class),
>
>
> @XmlElement(name
> = "File",
> type = TFile.class),
>
>
> @Element(required=false,name
> = "EventOut",
> type = TEventOut.class)
>
>
> })
>
> protected
> List<Object> variableOrEventOutOrMethodIn;
>
@ElementUnion I think
>
>
> 9. Translation missing.
>
>
>
>
> @XmlSchemaType(name
> = "positiveInteger")
>
>
> protected
> BigInteger binFixPointPos;
>
@Element i guess.
I am not overly familiar with the SED script. However I think it should be possible to convert just about anything JAXB can do to Simple.
|
|
From: Niall G. <gal...@ya...> - 2012-12-06 10:04:50
|
I need the full stack trace here to help with this.
--- On Wed, 28/11/12, Lecomte, J-Francois <JFL...@rh...> wrote:
> From: Lecomte, J-Francois <JFL...@rh...>
> Subject: [Simple-support] How can I serialize an unmodifiable list?
> To: "sim...@li..." <sim...@li...>
> Received: Wednesday, 28 November, 2012, 5:02 PM
>
>
>
>
>
>
>
>
> I get a
> « NoSuchMethodException » when I try
> to serialize a list that is wrapped by
> Collections.unmodifiableList(…) or a list obtained by
> Arrays.asList(…). The same applies to UnmodifiableList
> from Google’s Guava library.
>
>
> Here is
> a snippet that exposes the problem:
>
>
> public
> class
> Main
> {
>
> public
> static
> void
> main(final
> String[] args) throws
> Exception
>
> {
>
> final
> ArrayList<Integer> arrayList =
> new
> ArrayList<Integer>(Arrays.asList(1, 2, 3,
> 4));
>
>
>
> testLoadSave(new
> ObjectToPersist(arrayList)); // Will be successful
>
>
> testLoadSave(new
> ObjectToPersist(Collections.unmodifiableList(arrayList)));
> // Will throw a NoSuchMethodException
>
> testLoadSave(new
> ObjectToPersist(Arrays.asList(5, 6, 7,
> 8)));
>
> }
>
>
>
> private
> static
> void
> testLoadSave(final
> ObjectToPersist objectToPersist) throws
> Exception
>
> {
>
> final
> Serializer serializer =
> new
> Persister();
>
>
>
> final
> ByteArrayOutputStream out =
> new
> ByteArrayOutputStream();
>
> serializer.write(objectToPersist,
> out);
>
>
>
> final
> ByteArrayInputStream in =
> new
> ByteArrayInputStream(out.toByteArray());
>
> final
> ObjectToPersist objectRead = serializer.read(ObjectToPersist.class,
> in);
>
>
>
> System.out.println(objectRead);
>
> }
>
>
>
> public
> static
> class
> ObjectToPersist
>
> {
>
> @ElementList(name
> =
> "myList",
> entry =
> "element")
>
> private
> final
> List<Integer>
> _myList;
>
>
>
> public
> ObjectToPersist(
>
> @ElementList(name
> =
> "myList",
> entry =
> "element")
> final
> List<Integer> myList)
>
> {
>
> _myList
> = myList;
>
> }
>
>
>
> public
> List<Integer> getMyList()
>
> {
>
> return
> _myList;
>
> }
>
>
>
> @Override
>
> public
> String toString()
>
> {
>
> final
> StringBuilder builder =
> new
> StringBuilder();
>
> builder.append("ObjectToPersist@");
>
> builder.append(hashCode());
>
> builder.append("[_myList=");
>
> builder.append(_myList);
>
> builder.append("]");
>
> return
> builder.toString();
>
> }
>
> }
> }
>
>
>
>
> I
> don’t really care about the exact type of the list
> stored in my object, but I would like to keep it
> unmodifiable. So far I fixed the problem by modifying
> “ObjectToPersist” class this way:
>
>
>
> public
> ObjectToPersist(
>
> @ElementList(name
> =
> "myList",
> entry =
> "element")
> final
> List<Integer> myList)
>
> {
>
> _myList
> =
> new
> ArrayList<Integer>(myList);
>
> }
>
> public
> List<Integer> getMyList()
>
> {
>
> return
> Collections.unmodifiableList(_myList);
>
> }
>
>
>
>
> But
> this implies creating a new ArrayList all the time. I would
> prefer something like this:
>
>
>
> public
> ObjectToPersist(
>
> @ElementList(name
> =
> "myList",
> entry =
> "element")
> final
> List<Integer> myList)
>
> {
>
> if
> (myList is already immutable)
>
> _myList
> = myList;
>
> else
>
> _myList
> =
> new
> ArrayList<Integer>(myList);
>
> }
>
> public
> List<Integer> getMyList()
>
> {
>
> return
> _myList;
>
> }
>
>
> Using
> ImmutableList from Google’s Guava library, I could do
> just this (ImmutableList.copyOf(…)), but it
> won’t serialize… I was wondering if there was a
> way to support those immutable collections with
> SimpleXML…
>
>
> Thanks!
> JFL
>
>
>
>
> -----Inline Attachment Follows-----
>
> ------------------------------------------------------------------------------
> LogMeIn Rescue: Anywhere, Anytime Remote support for IT.
> Free Trial
> Remotely access PCs and mobile devices and provide instant
> support
> Improve your efficiency, and focus on delivering more
> value-add services
> Discover what IT Professionals Know. Rescue delivers
> http://p.sf.net/sfu/logmein_12329d2d
> -----Inline Attachment Follows-----
>
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
|
|
From: Niall G. <gal...@ya...> - 2012-12-06 10:03:30
|
Try 2.6.9 it has a number of improvements. On Android Simple should be using XmlPull, this has a similar performance profile to StAX only its more lightweight. You should also try to use the Proguard obfuscation, it improves the performance. ttps://niallg@simple.svn.sourceforge.net/svnroot/simple/trunk/download/stream/proguard.pro If you still notice bad performance or inconsistent times you will need to profile, perhaps there is some I/O bottle neck. Try serialize to a byte array output stream or a StringWriter and check out the times. --- On Mon, 19/11/12, stephen toner <ste...@gm...> wrote: > From: stephen toner <ste...@gm...> > Subject: [Simple-support] android performance > To: sim...@li... > Received: Monday, 19 November, 2012, 1:22 AM > Hi,I'm having some difficulty > deserializing some xml on Android - (it's about 100KB) > and I've found that whilst occasionally it deserializes > in a second or so - it very often takes 15-20 seconds. I > was wondering if anyone else has seen this issue (I'm > using the 2.6.7). > I was trying digging around - and as far as I can see > on Android internally it only uses DOM? Is this correct? > Should I be also adding the STax jars to my > project?ThanksStephen > > -----Inline Attachment Follows----- > > ------------------------------------------------------------------------------ > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. > Free Trial > Remotely access PCs and mobile devices and provide instant > support > Improve your efficiency, and focus on delivering more > value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > -----Inline Attachment Follows----- > > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > |
|
From: Oliver V. <Oli...@si...> - 2012-12-06 10:01:17
|
Dear Simple-Team, currently we are migrating from JAXB to Simple-XML framework. Following steps have been performed so far: - generate Java-classes from XSD via XJC - convert JAXB-annotations to Simple-Annotations via following SED script: http://old.nabble.com/xjc-created-jaxb-source-from-XML-schema-to-simpleframework-td32442003.html The issue is that this script does not convert all of the JAXB-annotations. Therefore I tried to convert the JAXB-annotations manually with the help of these articles: http://jeremyblythe.blogspot.nl/2009/11/converting-from-jaxb-to-simple-xml.html http://blog.bdoughan.com/2010/10/how-does-jaxb-compare-to-simple.html http://negabinary.blogspot.de/2012/08/xml-serialization-in-android.html But still - some unresolved conversions are left over. Can anyone help me to resolve these items? 1. Translation missing. @XmlType(name = "", propOrder = { "lala" }) 2. Translation missing. @XmlJavaTypeAdapter(CollapsedStringAdapter.class) @XmlSchemaType(name = "NMTOKEN") 3. Translation missing + need to get rid of JAXBElement. @XmlElementDecl(namespace = "", name = "SerialNumber", scope = TCompatibility.class) public JAXBElement<TCompatibilityExpression> createTCompatibilitySerialNumber(TCompatibilityExpression value) { return new JAXBElement<TCompatibilityExpression>( _TCompatibilitySerialNumber_QNAME, TCompatibilityExpression.class, TCompatibility.class, value); } 4. Translation missing. @XmlSeeAlso({ TArrayTypeNamed.class }) 5. Translation missing. @XmlElements({ @Element(required=false,name = "PatternGroup", type = TPatternGroup.class), @Element(required=false,name = "Pattern", type = TPattern.class) }) 6. Translation missing + need to get rid of JAXBElement. @XmlElementRefs({ @XmlElementRef(name = "lala", type = JAXBElement.class), @XmlElementRef(name = "lulu", type = JAXBElement.class), @XmlElementRef(name = "haha", type = JAXBElement.class), @XmlElementRef(name = "mmmh", type = JAXBElement.class) }) protected List<JAXBElement<TCompatibilityExpression>> deviceXXX; 7. Translation missing. @XmlValue protected String value; 8. Translation missing. @XmlElements({ @Element(required=false,name = "Variable", type = TVariable.class ), @Element(required=false,name = "MethodIn", type = TMethodIn.class ), @XmlElement(name = "File", type = TFile.class), @Element(required=false,name = "EventOut", type = TEventOut.class) }) protected List<Object> variableOrEventOutOrMethodIn; 9. Translation missing. @XmlSchemaType(name = "positiveInteger") protected BigInteger binFixPointPos; SICK AG - Sitz: Waldkirch i. Br. - Handelsregister: Freiburg i. Br. HRB 280355 Vorstand: Dr. Robert Bauer (Vorsitzender) - Reinhard Bösl - Dr. Martin Krämer - Markus Paschmann - Markus Vatter Aufsichtsrat: Gisela Sick (Ehrenvorsitzende) - Klaus M. Bukenberger (Vorsitzender) |
|
From: Niall G. <gal...@ya...> - 2012-12-06 09:49:38
|
That looks reasonable to me, I think you should read the tutorial http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php and make a decision from there. Also take a look at the test cases, here you will see real world examples of the use of the framework. Any test beginning with "Union" will be using element unions. See https://simple.svn.sourceforge.net/svnroot/simple/trunk/download/stream/src/test/java/org/simpleframework/xml/core/ --- On Thu, 6/12/12, Jochen van Waasen <Jo...@va...> wrote: > From: Jochen van Waasen <Jo...@va...> > Subject: Re: [Simple-support] @ElementList > To: "Niall Gallagher - Yieldbroker" <Nia...@yi...>, sim...@li... > Received: Thursday, 6 December, 2012, 12:34 AM > > > > > > Hi Niall, > > > > I need PLObject to be an interface. > > > > How would I use the implementations and annotate them as > normal? > > I would use ElementUnion as mentioned below and annote > the e.g. > PLNumber.class? > > > > How would that look like? > > import > java.math.BigDecimal; > import > java.math.BigInteger; > > import > org.simpleframework.xml.Root; > > @Root > public class PLNumber > implements PLObject { > > > public static final int INTEGER > = 0; > > public static final int REAL = > 1; > > > > private int type = -1; > > > > private BigDecimal decimalValue > = null; > > private BigInteger integerValue > = null; > > > > public PLNumber(String value){ > > > > super(); > > > try{ > > BigInteger integerValue = new BigInteger(value); > > this.integerValue = integerValue; > > > > this.type = INTEGER; > > }catch(Exception longException){ > > > > try { > > > BigDecimal decimalValue = new BigDecimal(value); > > > this.decimalValue = decimalValue; > > > > this.type = REAL; > > > }catch(Exception doubleException) { > > > > throw > new IllegalArgumentException("Given input " > + value + " neither > represents a double or int value."); > > } > > } > > } > > > > > public int intValue() { > > > return > this.integerValue.intValue(); > > } > > > public long longValue() { > > > > return > this.integerValue.longValue(); > > } > > > public float floatValue() { > > > > return > this.decimalValue.floatValue(); > > } > > > public double doubleValue() { > > > > return > this.decimalValue.doubleValue(); > > } > > > > public boolean isInteger(){ > > > > return this.type == > INTEGER; > > } > > > public boolean isReal(){ > > > > return this.type == REAL; > > } > > } > > > > > > Thanks for you support > > Jochen > > > > On 05.12.2012 22:49 , Niall Gallagher - Yieldbroker > wrote: > > With a converter you would not use an > @ElementUnion, one Converter should be used to handle all > the different types for PLObject. Why do you not just use > implementations and annotate them as normal? At any rate a > converter should work for PLObject. > > -----Original Message----- > From: Jochen van Waasen [mailto:Jo...@va...] > > Sent: Thursday, 6 December 2012 7:22 AM > To: Niall Gallagher; sim...@li... > Subject: Re: [Simple-support] @ElementList > > Hi Niall, > > I still don’t understand how to solve my issue: > > My new PropertyList class looks like this. It now reflects > the DTD as the objects are mutual exclusive. > > import org.simpleframework.xml.Attribute; > import org.simpleframework.xml.Element; > import org.simpleframework.xml.ElementUnion; > import org.simpleframework.xml.Root; > > @Root(name = "plist") > public class PropertyList{ > > @ElementUnion({ > @Element(name = "dict", required = > false, type = PLDict.class), > @Element(name = "array", required = > false, type = PLArray.class), > @Element(name = "real", required = > false, type = PLNumber.class), > @Element(name = "integer", required > = false, type = PLNumber.class), > @Element(name = "string", required > = false, type = PLString.class), > @Element(name = "data", required = > false, type = PLData.class), > @Element(name = "date", required = > false, type = PLDate.class), > @Element(name = "true", required = > false, type = PLBoolean.class), > @Element(name = "false", required = > false, type = > PLBoolean.class) > }) > private PLObject plObject; > > @Attribute(required = true) > private String version; > > public PropertyList(){ > > super(); > } > > public String getVersion(){ > > return this.version; > } > > public void setVersion(String version){ > > this.version = version; > } > > public PLObject getPLObject() { > > return plObject; > } > > > > public void setPLObject(PLObject plObject) { > > this.plObject = plObject; > } > } > > How can I define Converters for my classes? > > This does not work > @ElementUnion({ > @Element(name = "dict", required = > false, type = PLDict.class), > @Element(name = "array", required = > false, type = PLArray.class), > @Element(name = "real", required = > false, type = PLNumber.class), > @Element(name = "integer", required > = false, type = PLNumber.class), > @Element(name = "string", required > = false, type = PLString.class), > @Element(name = "data", required = > false, type = PLData.class), > @Element(name = "date", required = > false, type = PLDate.class), > @Element(name = "true", required = > false, type = PLBoolean.class), > @Element(name = "false", required = > false, type = > PLBoolean.class) > }) > @Convert(PLObjectConverter.class) > private PLObject plObject; > > and gives me the following error: > > Element annotation required for field 'plObject' > > Where do I have to annotate/define the converter when using > ElementUnion? > > Thanks > Jochen > > On 05.12.2012 09:31 , Niall Gallagher wrote: > > > Yes an @ElementUnion can match two different > classes, PlKey and PlObject need to be objects not > interfaces. If there are many implementations use > @ElementMapUnion to specify them. > > --- On Wed, 5/12/12, jo...@va...<jo...@va...> > wrote: > > > > From: jo...@va...<jo...@va...> > Subject: [Simple-support] @ElementList > To: sim...@li... > Received: Wednesday, 5 December, 2012, 12:21 AM Hi, > > I have this set of custom classes: > PLBigDecimal, PLBoolean, PLData, PLDate, PLNumber, PLString: > these all implement the interface PLObject PLKey (does not > implement > interface PLObject). > > @ElementMap(name = "dict", > key = "key", keyType = PLKey.class, > required = false, inline = false) private > Map<PLKey, > PLObject> plDictionary; > > The XML looks like this: > <?xml version="1.0" > encoding="UTF-8"?> > <plist version="1.0"> > <date>2012-11-30T10:14:00Z</date> > <dict> > > <key>key01</key><string>value01</string> > > <key>key02</key><string>value02</string> > > <key>key03</key><string>value03</string> > </dict> > <real>150.0</real> > <integer>500</integer> > <string>myPLString</string> > <true/> > <false/> > </plist> > > How can I parse the<dict> structure. > My current (see above) annotation gives me this error: > Cannot instantiate interface PLObject for interface PLObject > > How can I use this Map<PLKey, PLObject> so that it > can hold any > combination of PLKey and my PLObject interface (PLString, > PLBigDecimal, …)? > Can this be done at all with simpleXML? > > Any help on the map topic is appreciated! > > The second thing: > @Element(name = "true", required = false) > @Convert(PLBooleanConverter.class) > private PLBoolean plTrue; > > @Element(name = "false", required = > false) > @Convert(PLBooleanConverter.class) > private PLBoolean plFalse; > > Is it possible to bind two xml elements to one object? > The above works but I am looking for something like (map two > xml tags > to one object): > @ElementUnion({ > @Element(name = "false", required = false), > @Element(name = "true", required = > false) > }) > @Convert(PLBooleanConverter.class) > private PLBoolean plBoolean; > > Thanks > Jochen > > PS: Implementation for my root xml element, The ElementList > is not > working for the same reason (interface cannot be > instantiated) > > @Root(name = "plist") > public class PropertyList{ > > @ElementMap(name = "dict", > key = > "key", keyType = PLKey.class, > required = false, inline = false) > private Map<PLKey, PLObject> plDictionary; > > @ElementList(name = "array", required = > false) > private List<PLObject> plArray; > > @Element(name = "real", required = false) > @Convert(PLNumberConverter.class) > private PLNumber plReal; > > @Element(name = "integer", required = > false) > @Convert(PLNumberConverter.class) > private PLNumber plInteger; > > @Element(name = "string", required = > false) > @Convert(PLStringConverter.class) > private PLString plString; > > @Element(name = "data", required = false) > @Convert(PLDataConverter.class) > private PLData plData; > > @Element(name = "date", required = false) > @Convert(PLDateConverter.class) > private PLDate plDate; > > @Element(name = "true", required = false) > @Convert(PLBooleanConverter.class) > private PLBoolean plTrue; > > @Element(name = "false", required = > false) > @Convert(PLBooleanConverter.class) > private PLBoolean plFalse; > > @Attribute(required = true) > private String version; > > public PropertyList(){ > > super(); > } > } > > > -----Inline Attachment Follows----- > > --------------------------------------------------------------------- > --------- LogMeIn Rescue: Anywhere, Anytime Remote support > for IT. > Free Trial > Remotely access PCs and mobile devices and provide instant > support > Improve your efficiency, and focus on delivering more > value-add > services Discover what IT Professionals Know. Rescue > delivers > http://p.sf.net/sfu/logmein_12329d2d > -----Inline Attachment Follows----- > > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > > > > > > > > ------------------------------------------------------------------------------ > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. > Free Trial Remotely access PCs and mobile devices and > provide instant support Improve your efficiency, and focus > on delivering more value-add services Discover what IT > Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > > > > > > -----Inline Attachment Follows----- > > ------------------------------------------------------------------------------ > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. > Free Trial > Remotely access PCs and mobile devices and provide instant > support > Improve your efficiency, and focus on delivering more > value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > -----Inline Attachment Follows----- > > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > |
|
From: Jochen v. W. <Jo...@va...> - 2012-12-06 08:34:28
|
Hi Niall,
I need PLObject to be an interface.
How would I use the implementations and annotate them as normal?
I would use ElementUnion as mentioned below and annote the e.g.
PLNumber.class?
How would that look like?
import java.math.BigDecimal;
import java.math.BigInteger;
import org.simpleframework.xml.Root;
@Root
public class PLNumber implements PLObject {
public static final int INTEGER = 0;
public static final int REAL = 1;
private int type = -1;
private BigDecimal decimalValue = null;
private BigInteger integerValue = null;
public PLNumber(String value){
super();
try{
BigInteger integerValue
= new BigInteger(value);
this.integerValue =
integerValue;
this.type = INTEGER;
}catch(Exception longException){
try {
BigDecimal decimalValue = new
BigDecimal(value);
this.decimalValue = decimalValue;
this.type = REAL;
}catch(Exception doubleException) {
throw new
IllegalArgumentException("Given input " + value + " neither represents a
double or int value.");
}
}
}
public int intValue() {
return this.integerValue.intValue();
}
public long longValue() {
return this.integerValue.longValue();
}
public float floatValue() {
return this.decimalValue.floatValue();
}
public double doubleValue() {
return this.decimalValue.doubleValue();
}
public boolean isInteger(){
return this.type == INTEGER;
}
public boolean isReal(){
return this.type == REAL;
}
}
Thanks for you support
Jochen
On 05.12.2012 22:49 , Niall Gallagher - Yieldbroker wrote:
> With a converter you would not use an @ElementUnion, one Converter should be used to handle all the different types for PLObject. Why do you not just use implementations and annotate them as normal? At any rate a converter should work for PLObject.
>
> -----Original Message-----
> From: Jochen van Waasen [mailto:Jo...@va...]
> Sent: Thursday, 6 December 2012 7:22 AM
> To: Niall Gallagher; sim...@li...
> Subject: Re: [Simple-support] @ElementList
>
> Hi Niall,
>
> I still don’t understand how to solve my issue:
>
> My new PropertyList class looks like this. It now reflects the DTD as the objects are mutual exclusive.
>
> import org.simpleframework.xml.Attribute;
> import org.simpleframework.xml.Element;
> import org.simpleframework.xml.ElementUnion;
> import org.simpleframework.xml.Root;
>
> @Root(name = "plist")
> public class PropertyList{
>
> @ElementUnion({
> @Element(name = "dict", required = false, type = PLDict.class),
> @Element(name = "array", required = false, type = PLArray.class),
> @Element(name = "real", required = false, type = PLNumber.class),
> @Element(name = "integer", required = false, type = PLNumber.class),
> @Element(name = "string", required = false, type = PLString.class),
> @Element(name = "data", required = false, type = PLData.class),
> @Element(name = "date", required = false, type = PLDate.class),
> @Element(name = "true", required = false, type = PLBoolean.class),
> @Element(name = "false", required = false, type =
> PLBoolean.class)
> })
> private PLObject plObject;
>
> @Attribute(required = true)
> private String version;
>
> public PropertyList(){
>
> super();
> }
>
> public String getVersion(){
>
> return this.version;
> }
>
> public void setVersion(String version){
>
> this.version = version;
> }
>
> public PLObject getPLObject() {
>
> return plObject;
> }
>
>
>
> public void setPLObject(PLObject plObject) {
>
> this.plObject = plObject;
> }
> }
>
> How can I define Converters for my classes?
>
> This does not work
> @ElementUnion({
> @Element(name = "dict", required = false, type = PLDict.class),
> @Element(name = "array", required = false, type = PLArray.class),
> @Element(name = "real", required = false, type = PLNumber.class),
> @Element(name = "integer", required = false, type = PLNumber.class),
> @Element(name = "string", required = false, type = PLString.class),
> @Element(name = "data", required = false, type = PLData.class),
> @Element(name = "date", required = false, type = PLDate.class),
> @Element(name = "true", required = false, type = PLBoolean.class),
> @Element(name = "false", required = false, type =
> PLBoolean.class)
> })
> @Convert(PLObjectConverter.class)
> private PLObject plObject;
>
> and gives me the following error:
>
> Element annotation required for field 'plObject'
>
> Where do I have to annotate/define the converter when using ElementUnion?
>
> Thanks
> Jochen
>
> On 05.12.2012 09:31 , Niall Gallagher wrote:
>> Yes an @ElementUnion can match two different classes, PlKey and PlObject need to be objects not interfaces. If there are many implementations use @ElementMapUnion to specify them.
>>
>> --- On Wed, 5/12/12, jo...@va...<jo...@va...> wrote:
>>
>>> From: jo...@va...<jo...@va...>
>>> Subject: [Simple-support] @ElementList
>>> To: sim...@li...
>>> Received: Wednesday, 5 December, 2012, 12:21 AM Hi,
>>>
>>> I have this set of custom classes:
>>> PLBigDecimal, PLBoolean, PLData, PLDate, PLNumber, PLString:
>>> these all implement the interface PLObject PLKey (does not implement
>>> interface PLObject).
>>>
>>> @ElementMap(name = "dict",
>>> key = "key", keyType = PLKey.class,
>>> required = false, inline = false) private Map<PLKey,
>>> PLObject> plDictionary;
>>>
>>> The XML looks like this:
>>> <?xml version="1.0"
>>> encoding="UTF-8"?>
>>> <plist version="1.0">
>>> <date>2012-11-30T10:14:00Z</date>
>>> <dict>
>>>
>>> <key>key01</key><string>value01</string>
>>>
>>> <key>key02</key><string>value02</string>
>>>
>>> <key>key03</key><string>value03</string>
>>> </dict>
>>> <real>150.0</real>
>>> <integer>500</integer>
>>> <string>myPLString</string>
>>> <true/>
>>> <false/>
>>> </plist>
>>>
>>> How can I parse the<dict> structure.
>>> My current (see above) annotation gives me this error:
>>> Cannot instantiate interface PLObject for interface PLObject
>>>
>>> How can I use this Map<PLKey, PLObject> so that it can hold any
>>> combination of PLKey and my PLObject interface (PLString,
>>> PLBigDecimal, …)?
>>> Can this be done at all with simpleXML?
>>>
>>> Any help on the map topic is appreciated!
>>>
>>> The second thing:
>>> @Element(name = "true", required = false)
>>> @Convert(PLBooleanConverter.class)
>>> private PLBoolean plTrue;
>>>
>>> @Element(name = "false", required =
>>> false)
>>> @Convert(PLBooleanConverter.class)
>>> private PLBoolean plFalse;
>>>
>>> Is it possible to bind two xml elements to one object?
>>> The above works but I am looking for something like (map two xml tags
>>> to one object):
>>> @ElementUnion({
>>> @Element(name = "false", required = false),
>>> @Element(name = "true", required =
>>> false)
>>> })
>>> @Convert(PLBooleanConverter.class)
>>> private PLBoolean plBoolean;
>>>
>>> Thanks
>>> Jochen
>>>
>>> PS: Implementation for my root xml element, The ElementList is not
>>> working for the same reason (interface cannot be
>>> instantiated)
>>>
>>> @Root(name = "plist")
>>> public class PropertyList{
>>>
>>> @ElementMap(name = "dict",
>>> key =
>>> "key", keyType = PLKey.class,
>>> required = false, inline = false)
>>> private Map<PLKey, PLObject> plDictionary;
>>>
>>> @ElementList(name = "array", required =
>>> false)
>>> private List<PLObject> plArray;
>>>
>>> @Element(name = "real", required = false)
>>> @Convert(PLNumberConverter.class)
>>> private PLNumber plReal;
>>>
>>> @Element(name = "integer", required =
>>> false)
>>> @Convert(PLNumberConverter.class)
>>> private PLNumber plInteger;
>>>
>>> @Element(name = "string", required =
>>> false)
>>> @Convert(PLStringConverter.class)
>>> private PLString plString;
>>>
>>> @Element(name = "data", required = false)
>>> @Convert(PLDataConverter.class)
>>> private PLData plData;
>>>
>>> @Element(name = "date", required = false)
>>> @Convert(PLDateConverter.class)
>>> private PLDate plDate;
>>>
>>> @Element(name = "true", required = false)
>>> @Convert(PLBooleanConverter.class)
>>> private PLBoolean plTrue;
>>>
>>> @Element(name = "false", required =
>>> false)
>>> @Convert(PLBooleanConverter.class)
>>> private PLBoolean plFalse;
>>>
>>> @Attribute(required = true)
>>> private String version;
>>>
>>> public PropertyList(){
>>>
>>> super();
>>> }
>>> }
>>>
>>>
>>> -----Inline Attachment Follows-----
>>>
>>> ---------------------------------------------------------------------
>>> --------- LogMeIn Rescue: Anywhere, Anytime Remote support for IT.
>>> Free Trial
>>> Remotely access PCs and mobile devices and provide instant support
>>> Improve your efficiency, and focus on delivering more value-add
>>> services Discover what IT Professionals Know. Rescue delivers
>>> http://p.sf.net/sfu/logmein_12329d2d
>>> -----Inline Attachment Follows-----
>>>
>>> _______________________________________________
>>> Simple-support mailing list
>>> Sim...@li...
>>> https://lists.sourceforge.net/lists/listinfo/simple-support
>>>
> ------------------------------------------------------------------------------
> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Niall G. - Y. <Nia...@yi...> - 2012-12-05 21:49:30
|
With a converter you would not use an @ElementUnion, one Converter should be used to handle all the different types for PLObject. Why do you not just use implementations and annotate them as normal? At any rate a converter should work for PLObject.
-----Original Message-----
From: Jochen van Waasen [mailto:Jo...@va...]
Sent: Thursday, 6 December 2012 7:22 AM
To: Niall Gallagher; sim...@li...
Subject: Re: [Simple-support] @ElementList
Hi Niall,
I still don’t understand how to solve my issue:
My new PropertyList class looks like this. It now reflects the DTD as the objects are mutual exclusive.
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementUnion;
import org.simpleframework.xml.Root;
@Root(name = "plist")
public class PropertyList{
@ElementUnion({
@Element(name = "dict", required = false, type = PLDict.class),
@Element(name = "array", required = false, type = PLArray.class),
@Element(name = "real", required = false, type = PLNumber.class),
@Element(name = "integer", required = false, type = PLNumber.class),
@Element(name = "string", required = false, type = PLString.class),
@Element(name = "data", required = false, type = PLData.class),
@Element(name = "date", required = false, type = PLDate.class),
@Element(name = "true", required = false, type = PLBoolean.class),
@Element(name = "false", required = false, type =
PLBoolean.class)
})
private PLObject plObject;
@Attribute(required = true)
private String version;
public PropertyList(){
super();
}
public String getVersion(){
return this.version;
}
public void setVersion(String version){
this.version = version;
}
public PLObject getPLObject() {
return plObject;
}
public void setPLObject(PLObject plObject) {
this.plObject = plObject;
}
}
How can I define Converters for my classes?
This does not work
@ElementUnion({
@Element(name = "dict", required = false, type = PLDict.class),
@Element(name = "array", required = false, type = PLArray.class),
@Element(name = "real", required = false, type = PLNumber.class),
@Element(name = "integer", required = false, type = PLNumber.class),
@Element(name = "string", required = false, type = PLString.class),
@Element(name = "data", required = false, type = PLData.class),
@Element(name = "date", required = false, type = PLDate.class),
@Element(name = "true", required = false, type = PLBoolean.class),
@Element(name = "false", required = false, type =
PLBoolean.class)
})
@Convert(PLObjectConverter.class)
private PLObject plObject;
and gives me the following error:
Element annotation required for field 'plObject'
Where do I have to annotate/define the converter when using ElementUnion?
Thanks
Jochen
On 05.12.2012 09:31 , Niall Gallagher wrote:
> Yes an @ElementUnion can match two different classes, PlKey and PlObject need to be objects not interfaces. If there are many implementations use @ElementMapUnion to specify them.
>
> --- On Wed, 5/12/12, jo...@va...<jo...@va...> wrote:
>
>> From: jo...@va...<jo...@va...>
>> Subject: [Simple-support] @ElementList
>> To: sim...@li...
>> Received: Wednesday, 5 December, 2012, 12:21 AM Hi,
>>
>> I have this set of custom classes:
>> PLBigDecimal, PLBoolean, PLData, PLDate, PLNumber, PLString:
>> these all implement the interface PLObject PLKey (does not implement
>> interface PLObject).
>>
>> @ElementMap(name = "dict",
>> key = "key", keyType = PLKey.class,
>> required = false, inline = false) private Map<PLKey,
>> PLObject> plDictionary;
>>
>> The XML looks like this:
>> <?xml version="1.0"
>> encoding="UTF-8"?>
>> <plist version="1.0">
>> <date>2012-11-30T10:14:00Z</date>
>> <dict>
>>
>> <key>key01</key><string>value01</string>
>>
>> <key>key02</key><string>value02</string>
>>
>> <key>key03</key><string>value03</string>
>> </dict>
>> <real>150.0</real>
>> <integer>500</integer>
>> <string>myPLString</string>
>> <true/>
>> <false/>
>> </plist>
>>
>> How can I parse the<dict> structure.
>> My current (see above) annotation gives me this error:
>> Cannot instantiate interface PLObject for interface PLObject
>>
>> How can I use this Map<PLKey, PLObject> so that it can hold any
>> combination of PLKey and my PLObject interface (PLString,
>> PLBigDecimal, …)?
>> Can this be done at all with simpleXML?
>>
>> Any help on the map topic is appreciated!
>>
>> The second thing:
>> @Element(name = "true", required = false)
>> @Convert(PLBooleanConverter.class)
>> private PLBoolean plTrue;
>>
>> @Element(name = "false", required =
>> false)
>> @Convert(PLBooleanConverter.class)
>> private PLBoolean plFalse;
>>
>> Is it possible to bind two xml elements to one object?
>> The above works but I am looking for something like (map two xml tags
>> to one object):
>> @ElementUnion({
>> @Element(name = "false", required = false),
>> @Element(name = "true", required =
>> false)
>> })
>> @Convert(PLBooleanConverter.class)
>> private PLBoolean plBoolean;
>>
>> Thanks
>> Jochen
>>
>> PS: Implementation for my root xml element, The ElementList is not
>> working for the same reason (interface cannot be
>> instantiated)
>>
>> @Root(name = "plist")
>> public class PropertyList{
>>
>> @ElementMap(name = "dict",
>> key =
>> "key", keyType = PLKey.class,
>> required = false, inline = false)
>> private Map<PLKey, PLObject> plDictionary;
>>
>> @ElementList(name = "array", required =
>> false)
>> private List<PLObject> plArray;
>>
>> @Element(name = "real", required = false)
>> @Convert(PLNumberConverter.class)
>> private PLNumber plReal;
>>
>> @Element(name = "integer", required =
>> false)
>> @Convert(PLNumberConverter.class)
>> private PLNumber plInteger;
>>
>> @Element(name = "string", required =
>> false)
>> @Convert(PLStringConverter.class)
>> private PLString plString;
>>
>> @Element(name = "data", required = false)
>> @Convert(PLDataConverter.class)
>> private PLData plData;
>>
>> @Element(name = "date", required = false)
>> @Convert(PLDateConverter.class)
>> private PLDate plDate;
>>
>> @Element(name = "true", required = false)
>> @Convert(PLBooleanConverter.class)
>> private PLBoolean plTrue;
>>
>> @Element(name = "false", required =
>> false)
>> @Convert(PLBooleanConverter.class)
>> private PLBoolean plFalse;
>>
>> @Attribute(required = true)
>> private String version;
>>
>> public PropertyList(){
>>
>> super();
>> }
>> }
>>
>>
>> -----Inline Attachment Follows-----
>>
>> ---------------------------------------------------------------------
>> --------- LogMeIn Rescue: Anywhere, Anytime Remote support for IT.
>> Free Trial
>> Remotely access PCs and mobile devices and provide instant support
>> Improve your efficiency, and focus on delivering more value-add
>> services Discover what IT Professionals Know. Rescue delivers
>> http://p.sf.net/sfu/logmein_12329d2d
>> -----Inline Attachment Follows-----
>>
>> _______________________________________________
>> Simple-support mailing list
>> Sim...@li...
>> https://lists.sourceforge.net/lists/listinfo/simple-support
>>
>
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Jochen v. W. <Jo...@va...> - 2012-12-05 20:21:45
|
Hi Niall,
I still don’t understand how to solve my issue:
My new PropertyList class looks like this. It now reflects the DTD as
the objects are mutual exclusive.
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementUnion;
import org.simpleframework.xml.Root;
@Root(name = "plist")
public class PropertyList{
@ElementUnion({
@Element(name = "dict", required = false, type =
PLDict.class),
@Element(name = "array", required = false, type =
PLArray.class),
@Element(name = "real", required = false, type =
PLNumber.class),
@Element(name = "integer", required = false, type =
PLNumber.class),
@Element(name = "string", required = false, type =
PLString.class),
@Element(name = "data", required = false, type =
PLData.class),
@Element(name = "date", required = false, type =
PLDate.class),
@Element(name = "true", required = false, type =
PLBoolean.class),
@Element(name = "false", required = false, type =
PLBoolean.class)
})
private PLObject plObject;
@Attribute(required = true)
private String version;
public PropertyList(){
super();
}
public String getVersion(){
return this.version;
}
public void setVersion(String version){
this.version = version;
}
public PLObject getPLObject() {
return plObject;
}
public void setPLObject(PLObject plObject) {
this.plObject = plObject;
}
}
How can I define Converters for my classes?
This does not work
@ElementUnion({
@Element(name = "dict", required = false, type =
PLDict.class),
@Element(name = "array", required = false, type =
PLArray.class),
@Element(name = "real", required = false, type =
PLNumber.class),
@Element(name = "integer", required = false, type =
PLNumber.class),
@Element(name = "string", required = false, type =
PLString.class),
@Element(name = "data", required = false, type =
PLData.class),
@Element(name = "date", required = false, type =
PLDate.class),
@Element(name = "true", required = false, type =
PLBoolean.class),
@Element(name = "false", required = false, type =
PLBoolean.class)
})
@Convert(PLObjectConverter.class)
private PLObject plObject;
and gives me the following error:
Element annotation required for field 'plObject'
Where do I have to annotate/define the converter when using ElementUnion?
Thanks
Jochen
On 05.12.2012 09:31 , Niall Gallagher wrote:
> Yes an @ElementUnion can match two different classes, PlKey and PlObject need to be objects not interfaces. If there are many implementations use @ElementMapUnion to specify them.
>
> --- On Wed, 5/12/12, jo...@va...<jo...@va...> wrote:
>
>> From: jo...@va...<jo...@va...>
>> Subject: [Simple-support] @ElementList
>> To: sim...@li...
>> Received: Wednesday, 5 December, 2012, 12:21 AM
>> Hi,
>>
>> I have this set of custom classes:
>> PLBigDecimal, PLBoolean, PLData, PLDate, PLNumber, PLString:
>> these all implement the interface PLObject
>> PLKey (does not implement interface PLObject).
>>
>> @ElementMap(name = "dict",
>> key = "key", keyType = PLKey.class,
>> required = false, inline = false)
>> private Map<PLKey, PLObject> plDictionary;
>>
>> The XML looks like this:
>> <?xml version="1.0"
>> encoding="UTF-8"?>
>> <plist version="1.0">
>> <date>2012-11-30T10:14:00Z</date>
>> <dict>
>>
>> <key>key01</key><string>value01</string>
>>
>> <key>key02</key><string>value02</string>
>>
>> <key>key03</key><string>value03</string>
>> </dict>
>> <real>150.0</real>
>> <integer>500</integer>
>> <string>myPLString</string>
>> <true/>
>> <false/>
>> </plist>
>>
>> How can I parse the<dict> structure.
>> My current (see above) annotation gives me this error:
>> Cannot instantiate interface PLObject for interface
>> PLObject
>>
>> How can I use this Map<PLKey, PLObject> so that it can
>> hold any combination of PLKey and my PLObject interface
>> (PLString, PLBigDecimal, …)?
>> Can this be done at all with simpleXML?
>>
>> Any help on the map topic is appreciated!
>>
>> The second thing:
>> @Element(name = "true", required = false)
>> @Convert(PLBooleanConverter.class)
>> private PLBoolean plTrue;
>>
>> @Element(name = "false", required =
>> false)
>> @Convert(PLBooleanConverter.class)
>> private PLBoolean plFalse;
>>
>> Is it possible to bind two xml elements to one object?
>> The above works but I am looking for something like (map two
>> xml tags to one object):
>> @ElementUnion({
>> @Element(name = "false", required =
>> false),
>> @Element(name = "true", required =
>> false)
>> })
>> @Convert(PLBooleanConverter.class)
>> private PLBoolean plBoolean;
>>
>> Thanks
>> Jochen
>>
>> PS: Implementation for my root xml element, The ElementList
>> is not working for the same reason (interface cannot be
>> instantiated)
>>
>> @Root(name = "plist")
>> public class PropertyList{
>>
>> @ElementMap(name = "dict",
>> key =
>> "key", keyType = PLKey.class,
>> required = false,
>> inline = false)
>> private Map<PLKey, PLObject> plDictionary;
>>
>> @ElementList(name = "array", required =
>> false)
>> private List<PLObject> plArray;
>>
>> @Element(name = "real", required = false)
>> @Convert(PLNumberConverter.class)
>> private PLNumber plReal;
>>
>> @Element(name = "integer", required =
>> false)
>> @Convert(PLNumberConverter.class)
>> private PLNumber plInteger;
>>
>> @Element(name = "string", required =
>> false)
>> @Convert(PLStringConverter.class)
>> private PLString plString;
>>
>> @Element(name = "data", required = false)
>> @Convert(PLDataConverter.class)
>> private PLData plData;
>>
>> @Element(name = "date", required = false)
>> @Convert(PLDateConverter.class)
>> private PLDate plDate;
>>
>> @Element(name = "true", required = false)
>> @Convert(PLBooleanConverter.class)
>> private PLBoolean plTrue;
>>
>> @Element(name = "false", required =
>> false)
>> @Convert(PLBooleanConverter.class)
>> private PLBoolean plFalse;
>>
>> @Attribute(required = true)
>> private String version;
>>
>> public PropertyList(){
>>
>> super();
>> }
>> }
>>
>>
>> -----Inline Attachment Follows-----
>>
>> ------------------------------------------------------------------------------
>> LogMeIn Rescue: Anywhere, Anytime Remote support for IT.
>> Free Trial
>> Remotely access PCs and mobile devices and provide instant
>> support
>> Improve your efficiency, and focus on delivering more
>> value-add services
>> Discover what IT Professionals Know. Rescue delivers
>> http://p.sf.net/sfu/logmein_12329d2d
>> -----Inline Attachment Follows-----
>>
>> _______________________________________________
>> Simple-support mailing list
>> Sim...@li...
>> https://lists.sourceforge.net/lists/listinfo/simple-support
>>
>
|
|
From: <jo...@va...> - 2012-12-05 08:22:04
|
Hi,
I have this set of custom classes:
PLBigDecimal, PLBoolean, PLData, PLDate, PLNumber, PLString: these all implement the interface PLObject
PLKey (does not implement interface PLObject).
@ElementMap(name = "dict",
key = "key", keyType = PLKey.class,
required = false, inline = false)
private Map<PLKey, PLObject> plDictionary;
The XML looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<date>2012-11-30T10:14:00Z</date>
<dict>
<key>key01</key><string>value01</string>
<key>key02</key><string>value02</string>
<key>key03</key><string>value03</string>
</dict>
<real>150.0</real>
<integer>500</integer>
<string>myPLString</string>
<true/>
<false/>
</plist>
How can I parse the <dict> structure.
My current (see above) annotation gives me this error:
Cannot instantiate interface PLObject for interface PLObject
How can I use this Map<PLKey, PLObject> so that it can hold any combination of PLKey and my PLObject interface (PLString, PLBigDecimal, …)?
Can this be done at all with simpleXML?
Any help on the map topic is appreciated!
The second thing:
@Element(name = "true", required = false)
@Convert(PLBooleanConverter.class)
private PLBoolean plTrue;
@Element(name = "false", required = false)
@Convert(PLBooleanConverter.class)
private PLBoolean plFalse;
Is it possible to bind two xml elements to one object?
The above works but I am looking for something like (map two xml tags to one object):
@ElementUnion({
@Element(name = "false", required = false),
@Element(name = "true", required = false)
})
@Convert(PLBooleanConverter.class)
private PLBoolean plBoolean;
Thanks
Jochen
PS: Implementation for my root xml element, The ElementList is not working for the same reason (interface cannot be instantiated)
@Root(name = "plist")
public class PropertyList{
@ElementMap(name = "dict",
key = "key", keyType = PLKey.class,
required = false, inline = false)
private Map<PLKey, PLObject> plDictionary;
@ElementList(name = "array", required = false)
private List<PLObject> plArray;
@Element(name = "real", required = false)
@Convert(PLNumberConverter.class)
private PLNumber plReal;
@Element(name = "integer", required = false)
@Convert(PLNumberConverter.class)
private PLNumber plInteger;
@Element(name = "string", required = false)
@Convert(PLStringConverter.class)
private PLString plString;
@Element(name = "data", required = false)
@Convert(PLDataConverter.class)
private PLData plData;
@Element(name = "date", required = false)
@Convert(PLDateConverter.class)
private PLDate plDate;
@Element(name = "true", required = false)
@Convert(PLBooleanConverter.class)
private PLBoolean plTrue;
@Element(name = "false", required = false)
@Convert(PLBooleanConverter.class)
private PLBoolean plFalse;
@Attribute(required = true)
private String version;
public PropertyList(){
super();
}
}
|
|
From: Jochen v. W. <Jo...@va...> - 2012-11-30 19:15:43
|
Hi,
I have this set of custom classes:
PLBigDecimal, PLBoolean, PLData, PLDate, PLNumber, PLString: these all
implement the interface PLObject
PLKey (does not implement interface PLObject).
@ElementMap(name = "dict",
key = "key", keyType = PLKey.*class*,
required = *false*, inline = *false*)
*private*Map<PLKey, PLObject> plDictionary;
The XML looks like this:
<?_xml_ version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<date>2012-11-30T10:14:00Z</date>
_<dict>_
<key>key01</key><string>value01</string>
<key>key02</key><string>value02</string>
<key>key03</key><string>value03</string>
_</dict>_
<real>150.0</real>
<integer>500</integer>
<string>myPLString</string>
<true/>
<false/>
_</plist>_
How can I parse the <dict> structure.
My current (see above) annotation gives me this error:
Cannot instantiate interface PLObject for interface PLObject
How can I use this Map<PLKey, PLObject> so that it can hold any
combination of PLKey and my PLObject interface (PLString, PLBigDecimal,
...)?
Can this be done at all with simpleXML?
Any help on the map topic is appreciated!
The second thing:
@Element(name = "true", required = *false*)
@Convert(PLBooleanConverter.*class*)
*private*PLBoolean _plTrue_;
@Element(name = "false", required = *false*)
@Convert(PLBooleanConverter.*class*)
*private*PLBoolean _plFalse_;
Is it possible to bind two xml elements to one object?
The above works but I am looking for something like (map two xml tags to
one object):
@ElementUnion({
@Element(name = "false", required = *false*),
@Element(name = "true", required = *false*)
})
@Convert(PLBooleanConverter.*class*)
*private*PLBoolean _plBoolean_;
Thanks
Jochen
PS: Implementation for my root xml element, The ElementList is not
working for the same reason (interface cannot be instantiated)
@Root(name = "plist")
*public**class*PropertyList{
@ElementMap(name = "dict",
key = "key", keyType = PLKey.*class*,
required = *false*, inline = *false*)
*private*Map<PLKey, PLObject> plDictionary;
@ElementList(name = "array", required = *false*)
*private*List<PLObject> plArray;
@Element(name = "real", required = *false*)
@Convert(PLNumberConverter.*class*)
*private*PLNumber plReal;
@Element(name = "integer", required = *false*)
@Convert(PLNumberConverter.*class*)
*private*PLNumber plInteger;
@Element(name = "string", required = *false*)
@Convert(PLStringConverter.*class*)
*private*PLString plString;
@Element(name = "data", required = *false*)
@Convert(PLDataConverter.*class*)
*private*PLData plData;
@Element(name = "date", required = *false*)
@Convert(PLDateConverter.*class*)
*private*PLDate plDate;
@Element(name = "true", required = *false*)
@Convert(PLBooleanConverter.*class*)
*private*PLBoolean _plTrue_;
@Element(name = "false", required = *false*)
@Convert(PLBooleanConverter.*class*)
*private*PLBoolean _plFalse_;
@Attribute(required = *true*)
*private*String version;
*public*PropertyList(){
*super*();
}
}
|
|
From: Niall G. - Y. <Nia...@yi...> - 2012-11-29 22:39:17
|
Subscriber != subscriber
From: Chris Jefferies [mailto:ch...@gm...]
Sent: Friday, 30 November 2012 7:46 AM
To: sim...@li...
Subject: [Simple-support] @ElementList issue
simpleframework ElementException: Element subscriber does not have a match in class com.xyz.dazzler3.model.SubscribersList at line 1
I'm invoking this with:
SubscribersList response = serializer.read(SubscribersList.class, new StringReader(XMLString));
...where XMLString is the xml I'm reading.
I'm using @ElementList to define the List of Subscribers and I have a class to define each individual subscriber. Seems it should be "simple", but I'm not seeing what is wrong.
I have tried variations on the entry attribute, but nothing seems to work.
Anyone see my glaring error?
simple-xml-2.6.7.jar in my libs dir.
Thanks for any help/tips,
Chris.
The Subscribers object (note plural):
package com. xyz.dazzler3.model;
import java.util.List;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;
@Root(name="subscribers")
public class SubscribersList {
@ElementList(entry="Subscriber", inline=true)
private List<Subscriber> list;
public List<Subscriber> getList() {
return list;
}
public void setList(List<Subscriber> list) {
this.list = list;
}
}
The Subscriber Object:
package com. xyz.dazzler3.model;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;
@Root(name="subscriber")
public class Subscriber {
@Element(name="id")
private String id;
@Element(name="fname")
private String fname;
@Element(name="lname"
private String lname;
@Element(name="phone")
private String phone;
@Element(name="countryISO")
private String countryISO;
@Element(name="mac", required=false)
private String mac;
@Element(name="evid")
private String evid;
public String getId() {
return id;
}
public void setId(String id) {
this.id<http://this.id> = id;
}
public String getFname() {
return fname;
}
public void setFname(String fname) {
this.fname = fname;
}
public String getLname() {
return lname;
}
public void setLname(String lname) {
this.lname = lname;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getCountryISO() {
return countryISO;
}
public void setCountryISO(String countryISO) {
this.countryISO = countryISO;
}
public String getMac() {
return mac;
}
public void setMac(String mac) {
this.mac = mac;
}
public String getEvid() {
return evid;
}
public void setEvid(String evid) {
this.evid = evid;
}
}
Sample XML:
<?xml version="1.0" encoding="utf-8"?>
<subscribers>
<subscriber>
<id>1234567890</id>
<fname>Roberto</fname>
<lname>Jackson</lname>
<phone>510-419-2204</phone>
<countryISO>USA</countryISO>
<mac></mac>
<evid>1234567890</evid>
</subscriber>
<subscriber>
<id>4567890123</id>
<fname>Paul</fname>
<lname>Fults</lname>
<phone>201-433-5674</phone>
<countryISO>USA</countryISO>
<mac></mac>
<evid>4567890123</evid>
</subscriber>
</subscribers>
|