simple-support Mailing List for Simple (Page 7)
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. - Y. <Nia...@yi...> - 2013-03-24 22:50:19
|
Hi,
If the tags have the same name then you should not use @ElementListUnion, use @ElementList instead.
Niall
From: Shyam Sankaran [mailto:sh...@ou...]
Sent: Saturday, 23 March 2013 6:01 PM
To: sim...@li...
Subject: [Simple-support] ElementListUnion - Duplicate annotation exception .
Hi,
I tried deseiarilizing a list object. Since I will know the type of the list only at run time , I declared it using ElementListUnion as :
Customer.java
@ElementListUnion({ @ElementList(inline = false, type = Thing.class),
@ElementList(inline = false, type = AnotherThing.class) })
List<Object> things ;
My Response xml is :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customer>
<address>
<no>122</no>
<street>chennai</street>
</address>
<id>122</id>
<name>James Bond</name>
<things>
<thing>
<val>185</val>
</thing>
<thing>
<val>162</val>
</thing>
</things>
</customer>
But Iam getting the following exception.
03-21 18:56:31.940: E/AndroidRuntime(2289): Caused by:
org.simpleframework.xml.core.PersistenceException: Duplicate annotation
of name 'things' on
@org.simpleframework.xml.ElementListUnion(value=[@org.simpleframework.xml.ElementList(data=false,
empty=true, entry=, inline=false, name=, required=true, type=class
com.data.Thing), @org.simpleframework.xml.ElementList(data=false,
empty=true, entry=, inline=false, name=, required=true, type=class
com.data.AnotherThing)]) on field 'things' java.util.List
com.data.Customer.things
When I remove one ElementList it works fine .
eg. :
@ElementListUnion({ @ElementList(inline = false, type = Thing.class),
})
List<Object> things ;
is working fine.
Am I missing something here. Please Help. I have been on this for more than 3 days now.
Regards,
Shyam S
|
|
From: Shyam S. <sh...@ou...> - 2013-03-23 07:00:52
|
Hi,
I tried deseiarilizing a list object. Since I will know the type of the list only at run time , I declared it using ElementListUnion as :
Customer.java
@ElementListUnion({ @ElementList(inline = false, type = Thing.class), @ElementList(inline = false, type = AnotherThing.class) }) List<Object> things ;
My Response xml is :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><customer> <address> <no>122</no> <street>chennai</street> </address> <id>122</id> <name>James Bond</name> <things> <thing> <val>185</val> </thing> <thing> <val>162</val> </thing> </things></customer>
But Iam getting the following exception.
03-21 18:56:31.940: E/AndroidRuntime(2289): Caused by:org.simpleframework.xml.core.PersistenceException: Duplicate annotationof name 'things' on...@or....ElementListUnion(value=[@org.simpleframework.xml.ElementList(data=false,empty=true, entry=, inline=false, name=, required=true, type=classcom.data.Thing), @org.simpleframework.xml.ElementList(data=false,empty=true, entry=, inline=false, name=, required=true, type=classcom.data.AnotherThing)]) on field 'things' java.util.Listcom.data.Customer.things
When I remove one ElementList it works fine .eg. :
@ElementListUnion({ @ElementList(inline = false, type = Thing.class), })List<Object> things ;
is working fine.
Am I missing something here. Please Help. I have been on this for more than 3 days now.
Regards,Shyam S |
|
From: Niall G. - Y. <Nia...@yi...> - 2013-03-19 22:43:28
|
Yes this should be in the current release 2.7
-----Original Message-----
From: Timo Rumland [mailto:tim...@di...]
Sent: Wednesday, 20 March 2013 7:51 AM
To: sim...@li...
Subject: Re: [Simple-support] How to handle an empty XML element, when using a Converter via "@Convert"
Hello Niall,
> Looks like a bug to me, ill take a closer look at it. If it's a bug
> ill
release a fix for it shortly.
> Sounds like a good idea
any progress on this? It would be really helpful in my current project. It would be great if a "Converter" is allowed to return null (or a "Value"
instance with its "value" property to be null).
Thanks a lot!
Best Regards,
Timo
-----Ursprüngliche Nachricht-----
Von: Niall Gallagher [mailto:gal...@ya...]
Gesendet: Mittwoch, 27. Februar 2013 11:21
An: sim...@li...; Timo Rumland
Betreff: Re: [Simple-support] How to handle an empty XML element, when using a Converter via "@Convert"
Sounds like a good idea
--- On Tue, 26/2/13, Timo Rumland <tim...@di...> wrote:
> From: Timo Rumland <tim...@di...>
> Subject: Re: [Simple-support] How to handle an empty XML element, when
using a Converter via "@Convert"
> To: sim...@li...
> Received: Tuesday, 26 February, 2013, 11:43 PM Hello Niall,
>
> > Looks like a bug to me, ill take a closer look at it.
> If it's a bug ill
> release a fix for it shortly.
>
> thanks a lot for your answer!
>
> Now in my opinion, a Converter should be allowed to return null (or a
> "Value" instance with its "value" property to be null).
>
> I could imagine, that there are circumstances, where a special value
> in a XML tag must be converted to "null" in the target/deserialized
> object. So allowing a converter to convert to null would enhance the
> flexibility (you could write a converter which converts
> <time>null</null> to Java's 'null' in the deserialized object).
>
>
> Best Regards,
> Timo
>
>
> -----Ursprüngliche Nachricht-----
> Von: Niall Gallagher - Yieldbroker
> [mailto:Nia...@yi...]
>
> Gesendet: Dienstag, 26. Februar 2013 23:21
> An: Timo Rumland; sim...@li...
> Betreff: RE: [Simple-support] How to handle an empty XML element, when
> using a Converter via "@Convert"
>
> Looks like a bug to me, ill take a closer look at it. If it's a bug
> ill release a fix for it shortly.
>
> -----Original Message-----
> From: Timo Rumland [mailto:tim...@di...]
>
> Sent: Wednesday, 27 February 2013 4:42 AM
> To: sim...@li...
> Subject: [Simple-support] How to handle an empty XML element, when
> using a Converter via "@Convert"
>
> Hello,
>
> I have the following situation: I'm using the @Convert annotation with
> my own converter implementation on a class field named "time".
>
> When I now try to deserialize XML, which contains that "time" element
> but is empty like this:
>
> ----
> <time></time>
> ----
>
> my converter will be called and the SimpleXML framework throws an
> exception:
>
> ----
> [...]
> Caused by: java.lang.NullPointerException at
> org.simpleframework.xml.convert.Reference.getType(Reference.java:70)
> ----
>
> This is because my Converter implementation returns "null", when the
> XML element is empty. As the javadoc for "Converter.read" tells, it is
> not allowed to return "null".
>
> But now my question is, how should I handle the situation, where I use
> a Converter which is "confronted" with an empty XML element?
>
> Looking at the Method
>
>
> "org.simpleframework.xml.convert.AnnotationStrategy.read(Type,
> NodeMap<InputNode>, Value)"
>
> We can see the following code snipped:
>
> ----
> if(converter != null) {
> Object data = converter.read(parent);
>
> if(value != null) {
> value.setValue(data);
> }
> return new Reference(value, data);
> }
> ----
>
> This means, that if there is a @Converter defined, it gets called in
> any case, even if the value of that XML element is empty/null.
> But at the same
> time, Converter.read(...) should not return "null".
>
> I think the "AnnotationStrategy" class should handle this situation,
> checking for an empty XML element, so the converter gets not called in
> that case.
>
>
> So, what is the correct way to handle such a situation, or is it a
> "drawback" (maybe even a bug) of the "AnnotationStrategy"
> class?
>
>
> Thanks a lot for your help!
>
>
> Best Regards,
> Timo
>
>
> ----------------------------------------------------------------------
> ------
> --
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics Download AppDynamics Lite
> for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
>
> ----------------------------------------------------------------------
> -------- Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics Download AppDynamics Lite
> for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Timo R. <tim...@di...> - 2013-03-19 21:04:41
|
Hello Niall,
> Looks like a bug to me, ill take a closer look at it. If it's a bug ill
release a fix for it shortly.
> Sounds like a good idea
any progress on this? It would be really helpful in my current project. It
would be great if a "Converter" is allowed to return null (or a "Value"
instance with its "value" property to be null).
Thanks a lot!
Best Regards,
Timo
-----Ursprüngliche Nachricht-----
Von: Niall Gallagher [mailto:gal...@ya...]
Gesendet: Mittwoch, 27. Februar 2013 11:21
An: sim...@li...; Timo Rumland
Betreff: Re: [Simple-support] How to handle an empty XML element, when using
a Converter via "@Convert"
Sounds like a good idea
--- On Tue, 26/2/13, Timo Rumland <tim...@di...> wrote:
> From: Timo Rumland <tim...@di...>
> Subject: Re: [Simple-support] How to handle an empty XML element, when
using a Converter via "@Convert"
> To: sim...@li...
> Received: Tuesday, 26 February, 2013, 11:43 PM Hello Niall,
>
> > Looks like a bug to me, ill take a closer look at it.
> If it's a bug ill
> release a fix for it shortly.
>
> thanks a lot for your answer!
>
> Now in my opinion, a Converter should be allowed to return null (or a
> "Value" instance with its "value" property to be null).
>
> I could imagine, that there are circumstances, where a special value
> in a XML tag must be converted to "null" in the target/deserialized
> object. So allowing a converter to convert to null would enhance the
> flexibility (you could write a converter which converts
> <time>null</null> to Java's 'null' in the deserialized object).
>
>
> Best Regards,
> Timo
>
>
> -----Ursprüngliche Nachricht-----
> Von: Niall Gallagher - Yieldbroker
> [mailto:Nia...@yi...]
>
> Gesendet: Dienstag, 26. Februar 2013 23:21
> An: Timo Rumland; sim...@li...
> Betreff: RE: [Simple-support] How to handle an empty XML element, when
> using a Converter via "@Convert"
>
> Looks like a bug to me, ill take a closer look at it. If it's a bug
> ill release a fix for it shortly.
>
> -----Original Message-----
> From: Timo Rumland [mailto:tim...@di...]
>
> Sent: Wednesday, 27 February 2013 4:42 AM
> To: sim...@li...
> Subject: [Simple-support] How to handle an empty XML element, when
> using a Converter via "@Convert"
>
> Hello,
>
> I have the following situation: I'm using the @Convert annotation with
> my own converter implementation on a class field named "time".
>
> When I now try to deserialize XML, which contains that "time" element
> but is empty like this:
>
> ----
> <time></time>
> ----
>
> my converter will be called and the SimpleXML framework throws an
> exception:
>
> ----
> [...]
> Caused by: java.lang.NullPointerException at
> org.simpleframework.xml.convert.Reference.getType(Reference.java:70)
> ----
>
> This is because my Converter implementation returns "null", when the
> XML element is empty. As the javadoc for "Converter.read" tells, it is
> not allowed to return "null".
>
> But now my question is, how should I handle the situation, where I use
> a Converter which is "confronted" with an empty XML element?
>
> Looking at the Method
>
>
> "org.simpleframework.xml.convert.AnnotationStrategy.read(Type,
> NodeMap<InputNode>, Value)"
>
> We can see the following code snipped:
>
> ----
> if(converter != null) {
> Object data = converter.read(parent);
>
> if(value != null) {
> value.setValue(data);
> }
> return new Reference(value, data);
> }
> ----
>
> This means, that if there is a @Converter defined, it gets called in
> any case, even if the value of that XML element is empty/null.
> But at the same
> time, Converter.read(...) should not return "null".
>
> I think the "AnnotationStrategy" class should handle this situation,
> checking for an empty XML element, so the converter gets not called in
> that case.
>
>
> So, what is the correct way to handle such a situation, or is it a
> "drawback" (maybe even a bug) of the "AnnotationStrategy"
> class?
>
>
> Thanks a lot for your help!
>
>
> Best Regards,
> Timo
>
>
> ----------------------------------------------------------------------
> ------
> --
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics Download AppDynamics Lite
> for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
>
> ----------------------------------------------------------------------
> -------- Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics Download AppDynamics Lite
> for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
|
|
From: Niall G. <gal...@ya...> - 2013-03-17 09:14:13
|
It works without annotations, much like java serialization, if you do not wish to have something serialized use the Java transient keyword. There is no metadata file support though. --- On Sat, 16/3/13, Miguel Ángel Martínez Fernández <mig...@gm...> wrote: From: Miguel Ángel Martínez Fernández <mig...@gm...> Subject: [Simple-support] Using a xml MetaData file instead of annotations To: sim...@li... Received: Saturday, 16 March, 2013, 6:57 AM Hi! Is it any way of using simpleframework xml without using annotations? An example: JDO provides annotations and also the usage of package.jdo files. Does it exist in simpleframework xml? Thanks in advance,Miguel Ángel -----Inline Attachment Follows----- ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://p.sf.net/sfu/appdyn_d2d_mar -----Inline Attachment Follows----- _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Miguel Á. M. F. <mig...@gm...> - 2013-03-16 13:58:17
|
Hi! Is it any way of using simpleframework xml without using annotations? An example: JDO provides annotations and also the usage of package.jdo files. Does it exist in simpleframework xml? Thanks in advance, Miguel Ángel |
|
From: Dawid W. <daw...@gm...> - 2013-03-16 00:09:44
|
Answering myself having peeked at the code: yes, CycleStrategy (or
rather ReadGraph) consume identifiers. I've hacked around by passing a
custom VisitorStrategy delegating to CycleStrategy and cloning the id
attribute inside visitor's read callback to another, shadow attribute.
Works like a charm.
Dawid
On Sat, Mar 16, 2013 at 12:51 AM, Dawid Weiss <daw...@gm...> wrote:
> Hi Niall, everyone,
>
> This caught me by surprise. I use CycleStrategy to deserialize a graph
> of objects (some of which are backrefs to single declarations). So,
> something like this:
>
> <client id="foo">
> </client>
>
> <client id="bar">
> </client>
>
> I would like to capture Client's ID attribute if it was provided explicitly:
>
> public static class Client {
> @Attribute(required = false)
> public String id;
> }
>
> This doesn't seem to work though (always null). I could use two
> separate identifiers but this will be confusing to whoever is editing
> those files... Thoughts?
>
> Dawid
|
|
From: Dawid W. <daw...@gm...> - 2013-03-15 23:51:57
|
Hi Niall, everyone,
This caught me by surprise. I use CycleStrategy to deserialize a graph
of objects (some of which are backrefs to single declarations). So,
something like this:
<client id="foo">
</client>
<client id="bar">
</client>
I would like to capture Client's ID attribute if it was provided explicitly:
public static class Client {
@Attribute(required = false)
public String id;
}
This doesn't seem to work though (always null). I could use two
separate identifiers but this will be confusing to whoever is editing
those files... Thoughts?
Dawid
|
|
From: Max S. <ma...@se...> - 2013-03-14 12:22:27
|
Hi there,
I was creating a Javadoc documentation of my current project. I then
noticed, that the Simple annotations do not appear in the Javadoc docs.
I then searched if there is any setting that I can tweak to have Javadoc
include the annotations...
Sadly the only way is that the annotation definitions itselves have to
be marked with "@Documented". Example:
--- File "org/simpleframework/xml/Root.java" ---
[...]
@Documented
@Retention(RetentionPolicy.RUNTIME)
public @interface Root {
[...]
--- File "org/simpleframework/xml/Root.java" ---
After I compiled Simple with this change the Javadoc created the
following output:
--- Some Javadoc output ---
[...]
@Root(name="rootElementName")
public class myRootClass
extends BasicMessage
[...]
--- Some Javadoc output ---
So, could you please consider to mark all notations in your official
version with that annotation? Or is there any reason not to do so?
Best regards
Max Senft
|
|
From: Jason <bu...@ya...> - 2013-03-14 05:36:42
|
http://www.cmmquarterly.com/fjjdrl/ozemn |
|
From: Max S. <ma...@se...> - 2013-03-12 19:48:04
|
Hi again,
I checked my other idea, but it doesn't work, since you don't know the
element names in advance. So this seems to be the only way to do what
you need.
Regards
Max Senft
schrieb Max Senft:
> Hi,
>
> I repost to the mailing list, so everybody gets the result. What you
> need - at least it works - is a Converter for your Parent class:
> public class ParentConverter implements Converter<Parent> {
> @Override
> public Parent read(InputNode arg0) throws Exception {
> Parent newParent = new Parent();
>
> InputNode curNode;
> while ((curNode = arg0.getNext()) != null) {
> newParent.children.put(curNode.getName(), curNode.getValue());
> }
>
> return newParent;
> }
>
> @Override
> public void write(OutputNode arg0, Parent arg1) throws Exception {
> for (Entry<String, String> curEntry : arg1.children.entrySet()) {
> OutputNode newNode = arg0.getChild(curEntry.getKey());
> newNode.setValue(curEntry.getValue());
> newNode.commit();
> }
> }
> }
> So that this will be used to serialize/deserialize your Parent object,
> you need to do the following (actually add the
> "@Convert(ParentConverter.class)" annotation):
> @Convert(ParentConverter.class)
> public class Parent {
> public HashMap<String,String> children = new HashMap<>();
> }
> Simple will only use the Convert annotation, if you create your
> Persister object by passing an AnnotationStrategy:
> Strategy strategy = new AnnotationStrategy();
> Serializer serializer = new Persister(strategy);
> But attention: Using this converter will ignore any other annotations
> you did in your class, so you actually have to implement the full
> reading and writing in the converter!
>
> I just got another idea. Let me check this ...
>
> Best regards
> Max
> -------- Original-Nachricht --------
> Betreff: Re: [Simple-support] ElementMap with unknown child elements
> Von: Alex Boyd <ale...@ou...>
> An: Max Senft <ma...@se...>
> Datum: 12.03.2013 20:00
>> Yup that is exactly what I want.
>>
>> I think it is possible, but I haven't been able to get the behavior I
>> want.
>>
>> Alex Boyd
>>
>> ------------------------------------------------------------------------
>> Date: Tue, 12 Mar 2013 19:45:53 +0100
>> From: ma...@se...
>> To: sim...@li...
>> Subject: Re: [Simple-support] ElementMap with unknown child elements
>>
>> Hi Alex,
>>
>> I'm not quite sure if I understood your problem: You need the element
>> <Child1>Value1</Child1> to be inserted into the HashMap with "Child1"
>> as key and "Value1" as value?
>>
>> Best regards
>> Max
>>
>>
>> schrieb Alex Boyd:
>>
>> Hey All,
>>
>> Given the XML :
>>
>> <Parent>
>>
>> <Child1>Value1</Child1>
>>
>> <Child2>Value2</Child2>
>>
>> <Child3>Value3</Child3>
>>
>> </Parent>
>>
>> How would I serialize / deserialize so that I have a Java Object like below. I don't know the name of the child elements, I just want to get key-value pairs from the children, with key being the element name, and value being the text element inside the xml.
>>
>> class Parent
>>
>> {
>>
>> public HashMap<String,String> children;
>>
>> }
>>
>> I have tried multiple different combinations of ElementMap and ElementList but couldn't seem to get it to work the way I wanted.
>>
>> Thanks in advance,
>>
>> Alex Boyd
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
>> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
>> endpoint security space. For insight on selecting the right partner to
>> tackle endpoint security challenges, access the full report.
>> http://p.sf.net/sfu/symantec-dev2dev
>>
>>
>>
>> _______________________________________________
>> Simple-support mailing list
>> Sim...@li... <mailto:Sim...@li...>
>> https://lists.sourceforge.net/lists/listinfo/simple-support
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Everyone hates slow websites. So do we. Make your web apps faster
>> with AppDynamics Download AppDynamics Lite for free today:
>> http://p.sf.net/sfu/appdyn_d2d_mar
>> _______________________________________________ Simple-support
>> mailing list Sim...@li...
>> https://lists.sourceforge.net/lists/listinfo/simple-support
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_mar
>
>
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Max S. <ma...@se...> - 2013-03-12 19:28:18
|
Hi,
I repost to the mailing list, so everybody gets the result. What you
need - at least it works - is a Converter for your Parent class:
public class ParentConverter implements Converter<Parent> {
@Override
public Parent read(InputNode arg0) throws Exception {
Parent newParent = new Parent();
InputNode curNode;
while ((curNode = arg0.getNext()) != null) {
newParent.children.put(curNode.getName(), curNode.getValue());
}
return newParent;
}
@Override
public void write(OutputNode arg0, Parent arg1) throws Exception {
for (Entry<String, String> curEntry : arg1.children.entrySet()) {
OutputNode newNode = arg0.getChild(curEntry.getKey());
newNode.setValue(curEntry.getValue());
newNode.commit();
}
}
}
So that this will be used to serialize/deserialize your Parent object,
you need to do the following (actually add the
"@Convert(ParentConverter.class)" annotation):
@Convert(ParentConverter.class)
public class Parent {
public HashMap<String,String> children = new HashMap<>();
}
Simple will only use the Convert annotation, if you create your
Persister object by passing an AnnotationStrategy:
Strategy strategy = new AnnotationStrategy();
Serializer serializer = new Persister(strategy);
But attention: Using this converter will ignore any other annotations
you did in your class, so you actually have to implement the full
reading and writing in the converter!
I just got another idea. Let me check this ...
Best regards
Max
-------- Original-Nachricht --------
Betreff: Re: [Simple-support] ElementMap with unknown child elements
Von: Alex Boyd <ale...@ou...>
An: Max Senft <ma...@se...>
Datum: 12.03.2013 20:00
> Yup that is exactly what I want.
>
> I think it is possible, but I haven't been able to get the behavior I
> want.
>
> Alex Boyd
>
> ------------------------------------------------------------------------
> Date: Tue, 12 Mar 2013 19:45:53 +0100
> From: ma...@se...
> To: sim...@li...
> Subject: Re: [Simple-support] ElementMap with unknown child elements
>
> Hi Alex,
>
> I'm not quite sure if I understood your problem: You need the element
> <Child1>Value1</Child1> to be inserted into the HashMap with "Child1"
> as key and "Value1" as value?
>
> Best regards
> Max
>
>
> schrieb Alex Boyd:
>
> Hey All,
>
> Given the XML :
>
> <Parent>
>
> <Child1>Value1</Child1>
>
> <Child2>Value2</Child2>
>
> <Child3>Value3</Child3>
>
> </Parent>
>
> How would I serialize / deserialize so that I have a Java Object like below. I don't know the name of the child elements, I just want to get key-value pairs from the children, with key being the element name, and value being the text element inside the xml.
>
> class Parent
>
> {
>
> public HashMap<String,String> children;
>
> }
>
> I have tried multiple different combinations of ElementMap and ElementList but couldn't seem to get it to work the way I wanted.
>
> Thanks in advance,
>
> Alex Boyd
>
>
>
> ------------------------------------------------------------------------------
> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
> endpoint security space. For insight on selecting the right partner to
> tackle endpoint security challenges, access the full report.
> http://p.sf.net/sfu/symantec-dev2dev
>
>
>
> _______________________________________________
> Simple-support mailing list
> Sim...@li... <mailto:Sim...@li...>
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we. Make your web apps faster with
> AppDynamics Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_mar
> _______________________________________________ Simple-support mailing
> list Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Max S. <ma...@se...> - 2013-03-12 18:46:06
|
Hi Alex,
I'm not quite sure if I understood your problem: You need the element
<Child1>Value1</Child1> to be inserted into the HashMap with "Child1" as
key and "Value1" as value?
Best regards
Max
schrieb Alex Boyd:
> Hey All,
> Given the XML :
> <Parent>
>
> <Child1>Value1</Child1>
>
> <Child2>Value2</Child2>
>
> <Child3>Value3</Child3>
>
> </Parent>
> How would I serialize / deserialize so that I have a Java Object like below. I don't know the name of the child elements, I just want to get key-value pairs from the children, with key being the element name, and value being the text element inside the xml.
> class Parent
> {
>
> public HashMap<String,String> children;
>
> }
> I have tried multiple different combinations of ElementMap and ElementList but couldn't seem to get it to work the way I wanted.
> Thanks in advance,
> Alex Boyd
>
>
> ------------------------------------------------------------------------------
> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
> endpoint security space. For insight on selecting the right partner to
> tackle endpoint security challenges, access the full report.
> http://p.sf.net/sfu/symantec-dev2dev
>
>
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Alex B. <ale...@ou...> - 2013-03-12 14:56:20
|
Hey All,
Given the XML :<Parent>
<Child1>Value1</Child1><Child2>Value2</Child2><Child3>Value3</Child3></Parent>
How would I serialize / deserialize so that I have a Java Object like below. I don't know the name of the child elements, I just want to get key-value pairs from the children, with key being the element name, and value being the text element inside the xml.
class Parent{public HashMap<String,String> children;}
I have tried multiple different combinations of ElementMap and ElementList but couldn't seem to get it to work the way I wanted.
Thanks in advance,
Alex Boyd |
|
From: Max S. <ma...@se...> - 2013-03-01 20:57:51
|
Hi, yeah, but this is again such a big work around what is IMHO overkill ... my proposed changes are really small and do not change any other behaviour of Simple ... Regards Max -------- Original-Nachricht -------- Betreff: Re: [Simple-support] Extend Format and Formatter classes Von: Niall Gallagher - Yieldbroker <Nia...@yi...> An: Max Senft <ma...@se...>, sim...@li... <sim...@li...> Datum: 27.02.2013 22:47 > > I have a think about it, however you could easily do this at a stream > level by creating your own java.io.Writer implementation to capture > and modify tokens before writing to the resulting stream. This would > act like a stream editor. > > > > > > *From:*Max Senft [mailto:ma...@se...] > *Sent:* Wednesday, 27 February 2013 5:31 PM > *To:* sim...@li... > *Subject:* Re: [Simple-support] Extend Format and Formatter classes > > > > Hi! > > I know that. The "empty element tag" is part of the XML specification, > so it *should* be understood by any application. > > In my case (as well as at > http://stackoverflow.com/questions/14443749/prevent-inclusion-of-empty-tag-for-an-empty-elementlist-in-an-elementlistunion) > the problem is, that the code of the communication partner cannot be > changed. It does not understand this "empty element tag"! > > Since my changes hide the changes, a standard usage of it will not be > noticed by anyone. But the ones looking for that feature will find it at > a appropriate place (the Format object). > > Best regards > Max Senft > > > -------- Ursprüngliche Nachricht -------- > Von: Niall Gallagher <gal...@ya... > <mailto:gal...@ya...>> > Datum: > An: sim...@li...,Max > <mailto:sim...@li...,Max> Senft > <ma...@se... <mailto:ma...@se...>> > Betreff: Re: [Simple-support] Extend Format and Formatter classes > > > In XML there is no difference between <x></x> and </x>, what is the > technical benefit of using this? > > --- On Fri, 22/2/13, Max Senft <ma...@se... > <mailto:ma...@se...>> wrote: > > > From: Max Senft <ma...@se... <mailto:ma...@se...>> > > Subject: Re: [Simple-support] Extend Format and Formatter classes > > To: sim...@li... > <mailto:sim...@li...> > > Received: Friday, 22 February, 2013, 1:21 AM > > Hi again! > > > > I added my solution to StackOverflow which includes a huge > > and quite complex set of classes to be able to use the > > Converter interface for my special purposes AND a proposal > > for source code changes of Simple. > > > > I now did the proposed changes to a current checkout of the > > SVN source code. I have attached the diff files showing the > > changes I've made to Format.java and Formatter.java. > > > > Please have a look at it. I would appreciate an inclusion of > > my changes to the trunk! Is there a way to commit such > > changes in another way? Something like a commit request or > > something like that? > > > > Best regards > > Max Senft > > > > Am 21.02.2013 22:05, schrieb Max Senft: > > > Hi there! > > > > > > I posted a question at Stackoverflow: > > > http://stackoverflow.com/q/14955902/2086717 > > > It affects the usage of empty element tags of the > > produced XML data. > > > > > > The proposed answer using an own Converter is somewhat > > complex and > > > absolutely unnecessary for such a simple matter. PLUS > > the fact complex > > > class architectures cannot be done "user-friendly" by > > converters since > > > there seems no way to get out of the user-defined > > converter back to the > > > ones Simple integrates to automatically output the > > class hierarchies. > > > > > > I looked through the source of Simple and think that it > > should be VERY > > > easy to enhance the Formatter and Format classes to > > enable this feature. > > > What is the suggested way to present an implementation > > to you? Or are > > > you uninterested in user implementation proposals? > > > > > > Best regards > > > Max Senft > > > > > > > > > > > > ------------------------------------------------------------------------------ > > > Everyone hates slow websites. So do we. > > > Make your web apps faster with AppDynamics > > > Download AppDynamics Lite for free today: > > > http://p.sf.net/sfu/appdyn_d2d_feb > > > _______________________________________________ > > > Simple-support mailing list > > > Sim...@li... > <mailto:Sim...@li...> > > > https://lists.sourceforge.net/lists/listinfo/simple-support > > > > -----Inline Attachment Follows----- > > > > > ------------------------------------------------------------------------------ > > Everyone hates slow websites. So do we. > > Make your web apps faster with AppDynamics > > Download AppDynamics Lite for free today: > > http://p.sf.net/sfu/appdyn_d2d_feb > > -----Inline Attachment Follows----- > > > > _______________________________________________ > > Simple-support mailing list > > Sim...@li... > <mailto:Sim...@li...> > > https://lists.sourceforge.net/lists/listinfo/simple-support > > > |
|
From: Niall G. - Y. <Nia...@yi...> - 2013-02-27 21:49:36
|
I have a think about it, however you could easily do this at a stream level by creating your own java.io.Writer implementation to capture and modify tokens before writing to the resulting stream. This would act like a stream editor. From: Max Senft [mailto:ma...@se...] Sent: Wednesday, 27 February 2013 5:31 PM To: sim...@li... Subject: Re: [Simple-support] Extend Format and Formatter classes Hi! I know that. The "empty element tag" is part of the XML specification, so it *should* be understood by any application. In my case (as well as at http://stackoverflow.com/questions/14443749/prevent-inclusion-of-empty-tag-for-an-empty-elementlist-in-an-elementlistunion) the problem is, that the code of the communication partner cannot be changed. It does not understand this "empty element tag"! Since my changes hide the changes, a standard usage of it will not be noticed by anyone. But the ones looking for that feature will find it at a appropriate place (the Format object). Best regards Max Senft -------- Ursprüngliche Nachricht -------- Von: Niall Gallagher <gal...@ya...<mailto:gal...@ya...>> Datum: An: sim...@li...,Max<mailto:sim...@li...,Max> Senft <ma...@se...<mailto:ma...@se...>> Betreff: Re: [Simple-support] Extend Format and Formatter classes In XML there is no difference between <x></x> and </x>, what is the technical benefit of using this? --- On Fri, 22/2/13, Max Senft <ma...@se...<mailto:ma...@se...>> wrote: > From: Max Senft <ma...@se...<mailto:ma...@se...>> > Subject: Re: [Simple-support] Extend Format and Formatter classes > To: sim...@li...<mailto:sim...@li...> > Received: Friday, 22 February, 2013, 1:21 AM > Hi again! > > I added my solution to StackOverflow which includes a huge > and quite complex set of classes to be able to use the > Converter interface for my special purposes AND a proposal > for source code changes of Simple. > > I now did the proposed changes to a current checkout of the > SVN source code. I have attached the diff files showing the > changes I've made to Format.java and Formatter.java. > > Please have a look at it. I would appreciate an inclusion of > my changes to the trunk! Is there a way to commit such > changes in another way? Something like a commit request or > something like that? > > Best regards > Max Senft > > Am 21.02.2013 22:05, schrieb Max Senft: > > Hi there! > > > > I posted a question at Stackoverflow: > > http://stackoverflow.com/q/14955902/2086717 > > It affects the usage of empty element tags of the > produced XML data. > > > > The proposed answer using an own Converter is somewhat > complex and > > absolutely unnecessary for such a simple matter. PLUS > the fact complex > > class architectures cannot be done "user-friendly" by > converters since > > there seems no way to get out of the user-defined > converter back to the > > ones Simple integrates to automatically output the > class hierarchies. > > > > I looked through the source of Simple and think that it > should be VERY > > easy to enhance the Formatter and Format classes to > enable this feature. > > What is the suggested way to present an implementation > to you? Or are > > you uninterested in user implementation proposals? > > > > Best regards > > Max Senft > > > > > > > ------------------------------------------------------------------------------ > > Everyone hates slow websites. So do we. > > Make your web apps faster with AppDynamics > > Download AppDynamics Lite for free today: > > http://p.sf.net/sfu/appdyn_d2d_feb > > _______________________________________________ > > Simple-support mailing list > > Sim...@li...<mailto:Sim...@li...> > > https://lists.sourceforge.net/lists/listinfo/simple-support > > -----Inline Attachment Follows----- > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_feb > -----Inline Attachment Follows----- > > _______________________________________________ > Simple-support mailing list > Sim...@li...<mailto:Sim...@li...> > https://lists.sourceforge.net/lists/listinfo/simple-support > |
|
From: Niall G. <gal...@ya...> - 2013-02-27 10:22:16
|
Sounds like a good idea
--- On Tue, 26/2/13, Timo Rumland <tim...@di...> wrote:
> From: Timo Rumland <tim...@di...>
> Subject: Re: [Simple-support] How to handle an empty XML element, when using a Converter via "@Convert"
> To: sim...@li...
> Received: Tuesday, 26 February, 2013, 11:43 PM
> Hello Niall,
>
> > Looks like a bug to me, ill take a closer look at it.
> If it's a bug ill
> release a fix for it shortly.
>
> thanks a lot for your answer!
>
> Now in my opinion, a Converter should be allowed to return
> null (or a
> "Value" instance with its "value" property to be null).
>
> I could imagine, that there are circumstances, where a
> special value in a
> XML tag must be converted to "null" in the
> target/deserialized object. So
> allowing a converter to convert to null would enhance the
> flexibility (you
> could write a converter which converts
> <time>null</null> to Java's 'null' in
> the deserialized object).
>
>
> Best Regards,
> Timo
>
>
> -----Ursprüngliche Nachricht-----
> Von: Niall Gallagher - Yieldbroker [mailto:Nia...@yi...]
>
> Gesendet: Dienstag, 26. Februar 2013 23:21
> An: Timo Rumland; sim...@li...
> Betreff: RE: [Simple-support] How to handle an empty XML
> element, when using
> a Converter via "@Convert"
>
> Looks like a bug to me, ill take a closer look at it. If
> it's a bug ill
> release a fix for it shortly.
>
> -----Original Message-----
> From: Timo Rumland [mailto:tim...@di...]
>
> Sent: Wednesday, 27 February 2013 4:42 AM
> To: sim...@li...
> Subject: [Simple-support] How to handle an empty XML
> element, when using a
> Converter via "@Convert"
>
> Hello,
>
> I have the following situation: I'm using the @Convert
> annotation with my
> own converter implementation on a class field named "time".
>
> When I now try to deserialize XML, which contains that
> "time" element but is
> empty like this:
>
> ----
> <time></time>
> ----
>
> my converter will be called and the SimpleXML framework
> throws an exception:
>
> ----
> [...]
> Caused by: java.lang.NullPointerException at
> org.simpleframework.xml.convert.Reference.getType(Reference.java:70)
> ----
>
> This is because my Converter implementation returns "null",
> when the XML
> element is empty. As the javadoc for "Converter.read" tells,
> it is not
> allowed to return "null".
>
> But now my question is, how should I handle the situation,
> where I use a
> Converter which is "confronted" with an empty XML element?
>
> Looking at the Method
>
>
> "org.simpleframework.xml.convert.AnnotationStrategy.read(Type,
> NodeMap<InputNode>, Value)"
>
> We can see the following code snipped:
>
> ----
> if(converter != null) {
> Object data = converter.read(parent);
>
> if(value != null) {
> value.setValue(data);
> }
> return new Reference(value, data);
> }
> ----
>
> This means, that if there is a @Converter defined, it gets
> called in any
> case, even if the value of that XML element is empty/null.
> But at the same
> time, Converter.read(...) should not return "null".
>
> I think the "AnnotationStrategy" class should handle this
> situation,
> checking for an empty XML element, so the converter gets not
> called in that
> case.
>
>
> So, what is the correct way to handle such a situation, or
> is it a
> "drawback" (maybe even a bug) of the "AnnotationStrategy"
> class?
>
>
> Thanks a lot for your help!
>
>
> Best Regards,
> Timo
>
>
> ----------------------------------------------------------------------------
> --
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics Download
> AppDynamics Lite for
> free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_feb
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
|
|
From: Timo R. <tim...@di...> - 2013-02-27 07:44:40
|
Hello Niall,
> Looks like a bug to me, ill take a closer look at it. If it's a bug ill
release a fix for it shortly.
thanks a lot for your answer!
Now in my opinion, a Converter should be allowed to return null (or a
"Value" instance with its "value" property to be null).
I could imagine, that there are circumstances, where a special value in a
XML tag must be converted to "null" in the target/deserialized object. So
allowing a converter to convert to null would enhance the flexibility (you
could write a converter which converts <time>null</null> to Java's 'null' in
the deserialized object).
Best Regards,
Timo
-----Ursprüngliche Nachricht-----
Von: Niall Gallagher - Yieldbroker [mailto:Nia...@yi...]
Gesendet: Dienstag, 26. Februar 2013 23:21
An: Timo Rumland; sim...@li...
Betreff: RE: [Simple-support] How to handle an empty XML element, when using
a Converter via "@Convert"
Looks like a bug to me, ill take a closer look at it. If it's a bug ill
release a fix for it shortly.
-----Original Message-----
From: Timo Rumland [mailto:tim...@di...]
Sent: Wednesday, 27 February 2013 4:42 AM
To: sim...@li...
Subject: [Simple-support] How to handle an empty XML element, when using a
Converter via "@Convert"
Hello,
I have the following situation: I'm using the @Convert annotation with my
own converter implementation on a class field named "time".
When I now try to deserialize XML, which contains that "time" element but is
empty like this:
----
<time></time>
----
my converter will be called and the SimpleXML framework throws an exception:
----
[...]
Caused by: java.lang.NullPointerException at
org.simpleframework.xml.convert.Reference.getType(Reference.java:70)
----
This is because my Converter implementation returns "null", when the XML
element is empty. As the javadoc for "Converter.read" tells, it is not
allowed to return "null".
But now my question is, how should I handle the situation, where I use a
Converter which is "confronted" with an empty XML element?
Looking at the Method
"org.simpleframework.xml.convert.AnnotationStrategy.read(Type,
NodeMap<InputNode>, Value)"
We can see the following code snipped:
----
if(converter != null) {
Object data = converter.read(parent);
if(value != null) {
value.setValue(data);
}
return new Reference(value, data);
}
----
This means, that if there is a @Converter defined, it gets called in any
case, even if the value of that XML element is empty/null. But at the same
time, Converter.read(...) should not return "null".
I think the "AnnotationStrategy" class should handle this situation,
checking for an empty XML element, so the converter gets not called in that
case.
So, what is the correct way to handle such a situation, or is it a
"drawback" (maybe even a bug) of the "AnnotationStrategy" class?
Thanks a lot for your help!
Best Regards,
Timo
----------------------------------------------------------------------------
--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics Download AppDynamics Lite for
free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Max S. <ma...@se...> - 2013-02-27 06:32:03
|
Hi! I know that. The "empty element tag" is part of the XML specification, so it *should* be understood by any application. In my case (as well as at http://stackoverflow.com/questions/14443749/prevent-inclusion-of-empty-tag-for-an-empty-elementlist-in-an-elementlistunion) the problem is, that the code of the communication partner cannot be changed. It does not understand this "empty element tag"! Since my changes hide the changes, a standard usage of it will not be noticed by anyone. But the ones looking for that feature will find it at a appropriate place (the Format object). Best regards Max Senft -------- Ursprüngliche Nachricht -------- Von: Niall Gallagher <gal...@ya...> Datum: An: sim...@li...,Max Senft <ma...@se...> Betreff: Re: [Simple-support] Extend Format and Formatter classes In XML there is no difference between <x></x> and </x>, what is the technical benefit of using this? --- On Fri, 22/2/13, Max Senft <ma...@se...> wrote: > From: Max Senft <ma...@se...> > Subject: Re: [Simple-support] Extend Format and Formatter classes > To: sim...@li... > Received: Friday, 22 February, 2013, 1:21 AM > Hi again! > > I added my solution to StackOverflow which includes a huge > and quite complex set of classes to be able to use the > Converter interface for my special purposes AND a proposal > for source code changes of Simple. > > I now did the proposed changes to a current checkout of the > SVN source code. I have attached the diff files showing the > changes I've made to Format.java and Formatter.java. > > Please have a look at it. I would appreciate an inclusion of > my changes to the trunk! Is there a way to commit such > changes in another way? Something like a commit request or > something like that? > > Best regards > Max Senft > > Am 21.02.2013 22:05, schrieb Max Senft: > > Hi there! > > > > I posted a question at Stackoverflow: > > http://stackoverflow.com/q/14955902/2086717 > > It affects the usage of empty element tags of the > produced XML data. > > > > The proposed answer using an own Converter is somewhat > complex and > > absolutely unnecessary for such a simple matter. PLUS > the fact complex > > class architectures cannot be done "user-friendly" by > converters since > > there seems no way to get out of the user-defined > converter back to the > > ones Simple integrates to automatically output the > class hierarchies. > > > > I looked through the source of Simple and think that it > should be VERY > > easy to enhance the Formatter and Format classes to > enable this feature. > > What is the suggested way to present an implementation > to you? Or are > > you uninterested in user implementation proposals? > > > > Best regards > > Max Senft > > > > > > > ------------------------------------------------------------------------------ > > Everyone hates slow websites. So do we. > > Make your web apps faster with AppDynamics > > Download AppDynamics Lite for free today: > > http://p.sf.net/sfu/appdyn_d2d_feb > > _______________________________________________ > > Simple-support mailing list > > Sim...@li... > > https://lists.sourceforge.net/lists/listinfo/simple-support > > -----Inline Attachment Follows----- > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_feb > -----Inline Attachment Follows----- > > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > |
|
From: Niall G. - Y. <Nia...@yi...> - 2013-02-26 22:22:39
|
Looks like a bug to me, ill take a closer look at it. If it's a bug ill release a fix for it shortly.
-----Original Message-----
From: Timo Rumland [mailto:tim...@di...]
Sent: Wednesday, 27 February 2013 4:42 AM
To: sim...@li...
Subject: [Simple-support] How to handle an empty XML element, when using a Converter via "@Convert"
Hello,
I have the following situation: I'm using the @Convert annotation with my own converter implementation on a class field named "time".
When I now try to deserialize XML, which contains that "time" element but is empty like this:
----
<time></time>
----
my converter will be called and the SimpleXML framework throws an exception:
----
[...]
Caused by: java.lang.NullPointerException at org.simpleframework.xml.convert.Reference.getType(Reference.java:70)
----
This is because my Converter implementation returns "null", when the XML element is empty. As the javadoc for "Converter.read" tells, it is not allowed to return "null".
But now my question is, how should I handle the situation, where I use a Converter which is "confronted" with an empty XML element?
Looking at the Method
"org.simpleframework.xml.convert.AnnotationStrategy.read(Type,
NodeMap<InputNode>, Value)"
We can see the following code snipped:
----
if(converter != null) {
Object data = converter.read(parent);
if(value != null) {
value.setValue(data);
}
return new Reference(value, data);
}
----
This means, that if there is a @Converter defined, it gets called in any case, even if the value of that XML element is empty/null. But at the same time, Converter.read(...) should not return "null".
I think the "AnnotationStrategy" class should handle this situation, checking for an empty XML element, so the converter gets not called in that case.
So, what is the correct way to handle such a situation, or is it a "drawback" (maybe even a bug) of the "AnnotationStrategy" class?
Thanks a lot for your help!
Best Regards,
Timo
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Timo R. <tim...@di...> - 2013-02-26 17:58:05
|
Hello,
I have the following situation: I'm using the @Convert annotation with my
own converter implementation on a class field named "time".
When I now try to deserialize XML, which contains that "time" element but is
empty like this:
----
<time></time>
----
my converter will be called and the SimpleXML framework throws an exception:
----
[...]
Caused by: java.lang.NullPointerException
at org.simpleframework.xml.convert.Reference.getType(Reference.java:70)
----
This is because my Converter implementation returns "null", when the XML
element is empty. As the javadoc for "Converter.read" tells, it is not
allowed to return "null".
But now my question is, how should I handle the situation, where I use a
Converter which is "confronted" with an empty XML element?
Looking at the Method
"org.simpleframework.xml.convert.AnnotationStrategy.read(Type,
NodeMap<InputNode>, Value)"
We can see the following code snipped:
----
if(converter != null) {
Object data = converter.read(parent);
if(value != null) {
value.setValue(data);
}
return new Reference(value, data);
}
----
This means, that if there is a @Converter defined, it gets called in any
case, even if the value of that XML element is empty/null. But at the same
time, Converter.read(...) should not return "null".
I think the "AnnotationStrategy" class should handle this situation,
checking for an empty XML element, so the converter gets not called in that
case.
So, what is the correct way to handle such a situation, or is it a
"drawback" (maybe even a bug) of the "AnnotationStrategy" class?
Thanks a lot for your help!
Best Regards,
Timo
|
|
From: Niall G. <gal...@ya...> - 2013-02-22 09:28:45
|
In XML there is no difference between <x></x> and </x>, what is the technical benefit of using this? --- On Fri, 22/2/13, Max Senft <ma...@se...> wrote: > From: Max Senft <ma...@se...> > Subject: Re: [Simple-support] Extend Format and Formatter classes > To: sim...@li... > Received: Friday, 22 February, 2013, 1:21 AM > Hi again! > > I added my solution to StackOverflow which includes a huge > and quite complex set of classes to be able to use the > Converter interface for my special purposes AND a proposal > for source code changes of Simple. > > I now did the proposed changes to a current checkout of the > SVN source code. I have attached the diff files showing the > changes I've made to Format.java and Formatter.java. > > Please have a look at it. I would appreciate an inclusion of > my changes to the trunk! Is there a way to commit such > changes in another way? Something like a commit request or > something like that? > > Best regards > Max Senft > > Am 21.02.2013 22:05, schrieb Max Senft: > > Hi there! > > > > I posted a question at Stackoverflow: > > http://stackoverflow.com/q/14955902/2086717 > > It affects the usage of empty element tags of the > produced XML data. > > > > The proposed answer using an own Converter is somewhat > complex and > > absolutely unnecessary for such a simple matter. PLUS > the fact complex > > class architectures cannot be done "user-friendly" by > converters since > > there seems no way to get out of the user-defined > converter back to the > > ones Simple integrates to automatically output the > class hierarchies. > > > > I looked through the source of Simple and think that it > should be VERY > > easy to enhance the Formatter and Format classes to > enable this feature. > > What is the suggested way to present an implementation > to you? Or are > > you uninterested in user implementation proposals? > > > > Best regards > > Max Senft > > > > > > > ------------------------------------------------------------------------------ > > Everyone hates slow websites. So do we. > > Make your web apps faster with AppDynamics > > Download AppDynamics Lite for free today: > > http://p.sf.net/sfu/appdyn_d2d_feb > > _______________________________________________ > > Simple-support mailing list > > Sim...@li... > > https://lists.sourceforge.net/lists/listinfo/simple-support > > -----Inline Attachment Follows----- > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_feb > -----Inline Attachment Follows----- > > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > |
|
From: Max S. <ma...@se...> - 2013-02-22 09:21:36
|
Hi again! I added my solution to StackOverflow which includes a huge and quite complex set of classes to be able to use the Converter interface for my special purposes AND a proposal for source code changes of Simple. I now did the proposed changes to a current checkout of the SVN source code. I have attached the diff files showing the changes I've made to Format.java and Formatter.java. Please have a look at it. I would appreciate an inclusion of my changes to the trunk! Is there a way to commit such changes in another way? Something like a commit request or something like that? Best regards Max Senft Am 21.02.2013 22:05, schrieb Max Senft: > Hi there! > > I posted a question at Stackoverflow: > http://stackoverflow.com/q/14955902/2086717 > It affects the usage of empty element tags of the produced XML data. > > The proposed answer using an own Converter is somewhat complex and > absolutely unnecessary for such a simple matter. PLUS the fact > complex > class architectures cannot be done "user-friendly" by converters > since > there seems no way to get out of the user-defined converter back to > the > ones Simple integrates to automatically output the class hierarchies. > > I looked through the source of Simple and think that it should be > VERY > easy to enhance the Formatter and Format classes to enable this > feature. > What is the suggested way to present an implementation to you? Or are > you uninterested in user implementation proposals? > > Best regards > Max Senft > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_feb > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Max S. <ma...@se...> - 2013-02-21 21:22:51
|
Hi there! I posted a question at Stackoverflow: http://stackoverflow.com/q/14955902/2086717 It affects the usage of empty element tags of the produced XML data. The proposed answer using an own Converter is somewhat complex and absolutely unnecessary for such a simple matter. PLUS the fact complex class architectures cannot be done "user-friendly" by converters since there seems no way to get out of the user-defined converter back to the ones Simple integrates to automatically output the class hierarchies. I looked through the source of Simple and think that it should be VERY easy to enhance the Formatter and Format classes to enable this feature. What is the suggested way to present an implementation to you? Or are you uninterested in user implementation proposals? Best regards Max Senft |
|
From: Max S. <max...@gm...> - 2013-02-21 20:34:31
|
Hi there! I posted a question at Stackoverflow: http://stackoverflow.com/q/14955902/2086717 It affects the usage of empty element tags of the produced XML data. The proposed answer using an own Converter is somewhat complex and absolutely unnecessary for such a simple matter. PLUS the fact complex class architectures cannot be done "user-friendly" by converters since there seems no way to get out of the user-defined converter back to the ones Simple integrates to automatically output the class hierarchies. I looked through the source of Simple and think that it should be VERY easy to enhance the Formatter and Format classes to enable this feature. What is the suggested way to present an implementation to you? Or are you uninterested in user implementation proposals? Best regards Max Senft |