simple-support Mailing List for Simple (Page 16)
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: Andrew S. <and...@ti...> - 2012-06-28 16:16:04
|
Hi Niall,
That's strange, since I'm using Simple 2.6.4. (By the way, it's
required=false, not required=true that I had to include.)
Thanks,
Andrew
On Thu, Jun 28, 2012 at 9:24 AM, Niall Gallagher
<gal...@ya...>wrote:
> Hi Andrew,
>
> This is only true for much older versions of Simple, for newer versions
> required=true would not be needed in the annotation.
>
> Niall
>
>
> --- On *Wed, 27/6/12, Andrew Spinner <and...@ti...>* wrote:
>
>
> From: Andrew Spinner <and...@ti...>
> Subject: Re: [Simple-support] Constructor injection problems
> To:
> Cc: sim...@li...
> Received: Wednesday, 27 June, 2012, 12:21 PM
>
>
> Hi Simon, Niall,
>
> Thanks for your suggestions. I've tracked it down to null values being
> passed to the constructor. Although my fields were annotated with
> @Element(required = false), I hadn't realised that my constructor arguments
> also had to be annotated with required=false, and this turned out to be the
> problem. Perhaps this could be made clearer in the documentation (although
> other people may not naturally make this error).
>
> Thanks for your help!
>
> Andrew
>
>
> On Wed, Jun 27, 2012 at 1:19 PM, Niall Gallagher <
> gal...@ya... <http://mc/compose?to=...@ya...>
> > wrote:
>
> Is your class an inner class, if so is it static? If it is inner and not
> static it can be be instantiated. If this is not the problem, send me a
> test case proving the problem, ill see what the problem is here.
>
> On a side note, I really doubt there is a bug here, constructor injection
> has been very heavily tested in recent releases. Make sure u are using the
> most recent release.
>
> --- On *Mon, 25/6/12, Andrew Spinner <and...@ti...<http://mc/compose?to=...@ti...>
> >* wrote:
>
>
> From: Andrew Spinner <and...@ti...<http://mc/compose?to=...@ti...>
> >
> Subject: [Simple-support] Constructor injection problems
> To: sim...@li...<http://mc/compose?to=...@li...>
> Received: Monday, 25 June, 2012, 9:27 AM
>
>
> Hello, and thanks for this lightweight framework,
>
> I'm having some problems with constructor injection for my immutable class.
>
> My instance variables are all final, and are all serialised by Simple.
> However, I don't need all the fields to be deserialised - some of the
> fields are derived, being based on mathematical calculations of the other
> fields. These derived variables are set in the constructor, based on the
> parameters passed to the constructor.
>
> It doesn't make logical sense to pass values of these derived variables
> into the constructor, because they're not needed, and will be discarded.
> However, I've got to do so, or I'll get a ConstructorException, saying "no
> constructor accepts all read only values."
>
> This isn't my production code, just an example:
>
> public class calc
> {
> @Element(name="number")
> private final int number;
> @Element(name="numberSquared")
> private final int numberSquared;
>
> //extra constructor I have to provide
> public Calc(@Element(name="number") int number,
> @Element(name="numberSquared") int numberSquared)
> {
> this(number); //ignores numberSquared parameter, letting chained
> constructor calculate value for itself
> }
>
> //usual constructor
> Calc(int number)
> {
> this.number = number;
> numberSquared = number * number; //ignoring parameter and calculating
> value for itself
> }
>
> Unfortunately, even when I create this extra constructor, I still get a
> PersistenceException: "Constructor not matched for class." As far as I can
> see, I've annotated the constructor correctly, providing a parameter for
> every possible field.
>
> Short of me providing my actual code, is there anything I could look at
> that might fix it?
>
> As a suggestion, it might be useful for PersistenceException to provided
> more specific information about how the constructor isn't matching.
>
> Thanks,
>
> Andrew
>
> -----Inline Attachment Follows-----
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>
> -----Inline Attachment Follows-----
>
> _______________________________________________
> Simple-support mailing list
> Sim...@li...<http://mc/compose?to=...@li...>
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
>
>
>
> -----Inline Attachment Follows-----
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>
> -----Inline Attachment Follows-----
>
> _______________________________________________
> Simple-support mailing list
> Sim...@li...<http://mc/compose?to=...@li...>
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
>
|
|
From: Niall G. <gal...@ya...> - 2012-06-28 08:24:24
|
Hi Andrew,
This is only true for much older versions of Simple, for newer versions required=true would not be needed in the annotation.
Niall
--- On Wed, 27/6/12, Andrew Spinner <and...@ti...> wrote:
From: Andrew Spinner <and...@ti...>
Subject: Re: [Simple-support] Constructor injection problems
To:
Cc: sim...@li...
Received: Wednesday, 27 June, 2012, 12:21 PM
Hi Simon, Niall,
Thanks for your suggestions. I've tracked it down to null values being
passed to the constructor. Although my fields were annotated with
@Element(required = false), I hadn't realised that my constructor
arguments also had to be annotated with required=false, and this turned
out to be the problem. Perhaps this could be made clearer in the
documentation (although other people may not naturally make this error).
Thanks for your help!
Andrew
On Wed, Jun 27, 2012 at 1:19 PM, Niall Gallagher <gal...@ya...> wrote:
Is your class an inner class, if so is it static? If it is inner and not static it can be be instantiated. If this is not the problem, send me a test case proving the problem, ill see what the problem is here.
On a side note, I really doubt there is a bug here, constructor injection has been very heavily tested in recent releases. Make sure u are using the most recent release.
--- On Mon, 25/6/12, Andrew Spinner <and...@ti...> wrote:
From: Andrew Spinner <and...@ti...>
Subject: [Simple-support] Constructor injection problems
To: sim...@li...
Received: Monday, 25 June, 2012, 9:27 AM
Hello, and thanks for this
lightweight framework,
I'm having some problems with constructor injection for my immutable class.
My instance variables are all final, and are all serialised by Simple. However, I don't need all the fields to be deserialised - some of the fields are derived, being based on mathematical calculations of the other fields. These derived variables are set in the constructor, based on the parameters passed to the constructor.
It doesn't make logical sense to pass values of these derived variables into the constructor, because they're not needed, and will be discarded. However, I've got to do so, or I'll get a ConstructorException, saying "no constructor accepts all read only values."
This isn't my production code, just an example:
public class calc
{
@Element(name="number")
private final int number;
@Element(name="numberSquared")
private final int numberSquared;
//extra constructor I have to provide
public Calc(@Element(name="number") int number, @Element(name="numberSquared") int numberSquared)
{
this(number); //ignores numberSquared parameter, letting chained constructor calculate value for itself
}
//usual constructor
Calc(int number)
{
this.number = number;
numberSquared = number * number; //ignoring parameter and calculating value for itself
}
Unfortunately, even when I create this extra constructor, I still get a PersistenceException: "Constructor not matched for class." As far as I can see, I've annotated the constructor correctly, providing a parameter for every possible field.
Short of me providing my actual code, is there anything I could look at that might fix it?
As a suggestion, it might be useful for PersistenceException to provided more specific information about how the constructor isn't matching.
Thanks,
Andrew
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Andrew S. <and...@ti...> - 2012-06-27 19:21:23
|
Hi Simon, Niall,
Thanks for your suggestions. I've tracked it down to null values being
passed to the constructor. Although my fields were annotated with
@Element(required = false), I hadn't realised that my constructor arguments
also had to be annotated with required=false, and this turned out to be the
problem. Perhaps this could be made clearer in the documentation (although
other people may not naturally make this error).
Thanks for your help!
Andrew
> On Wed, Jun 27, 2012 at 1:19 PM, Niall Gallagher <
> gal...@ya...> wrote:
>
>> Is your class an inner class, if so is it static? If it is inner and not
>> static it can be be instantiated. If this is not the problem, send me a
>> test case proving the problem, ill see what the problem is here.
>>
>> On a side note, I really doubt there is a bug here, constructor injection
>> has been very heavily tested in recent releases. Make sure u are using the
>> most recent release.
>>
>> --- On *Mon, 25/6/12, Andrew Spinner <and...@ti...>*wrote:
>>
>>
>> From: Andrew Spinner <and...@ti...>
>> Subject: [Simple-support] Constructor injection problems
>> To: sim...@li...
>> Received: Monday, 25 June, 2012, 9:27 AM
>>
>>
>> Hello, and thanks for this lightweight framework,
>>
>> I'm having some problems with constructor injection for my immutable
>> class.
>>
>> My instance variables are all final, and are all serialised by Simple.
>> However, I don't need all the fields to be deserialised - some of the
>> fields are derived, being based on mathematical calculations of the other
>> fields. These derived variables are set in the constructor, based on the
>> parameters passed to the constructor.
>>
>> It doesn't make logical sense to pass values of these derived variables
>> into the constructor, because they're not needed, and will be discarded.
>> However, I've got to do so, or I'll get a ConstructorException, saying "no
>> constructor accepts all read only values."
>>
>> This isn't my production code, just an example:
>>
>> public class calc
>> {
>> @Element(name="number")
>> private final int number;
>> @Element(name="numberSquared")
>> private final int numberSquared;
>>
>> //extra constructor I have to provide
>> public Calc(@Element(name="number") int number,
>> @Element(name="numberSquared") int numberSquared)
>> {
>> this(number); //ignores numberSquared parameter, letting chained
>> constructor calculate value for itself
>> }
>>
>> //usual constructor
>> Calc(int number)
>> {
>> this.number = number;
>> numberSquared = number * number; //ignoring parameter and calculating
>> value for itself
>> }
>>
>> Unfortunately, even when I create this extra constructor, I still get a
>> PersistenceException: "Constructor not matched for class." As far as I can
>> see, I've annotated the constructor correctly, providing a parameter for
>> every possible field.
>>
>> Short of me providing my actual code, is there anything I could look at
>> that might fix it?
>>
>> As a suggestion, it might be useful for PersistenceException to provided
>> more specific information about how the constructor isn't matching.
>>
>> Thanks,
>>
>> Andrew
>>
>> -----Inline Attachment Follows-----
>>
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>
>> -----Inline Attachment Follows-----
>>
>> _______________________________________________
>> Simple-support mailing list
>> Sim...@li...<http://mc/compose?to=...@li...>
>> https://lists.sourceforge.net/lists/listinfo/simple-support
>>
>>
>
|
|
From: Niall G. <gal...@ya...> - 2012-06-27 12:32:06
|
The problem here is whether
<column></column> represents "" or is it null there is noreal way to tell from parsing the XML document? You could do this
class Column {@Textprivate String value;}
Then the XML would be the same, but you should get null.
--- On Mon, 25/6/12, Jorge Cercas <jms...@gm...> wrote:
From: Jorge Cercas <jms...@gm...>
Subject: [Simple-support] Fwd: ElementList that includes null values
To: sim...@li...
Received: Monday, 25 June, 2012, 5:45 PM
Hi,
I am using an @ElementList annotation, but the resulting ArrayList does not include the empty elements found in the XML - I am "loosing" elements (empty elements).
It also seems that I cannot use the @ElementArray since there is no way of telling it that the elements are inline.
The partial XML:
<line id="001">
<column>aaa</column>
<column>bbb</column>
<column></column>
</line>
<line id="002">
<column>111</column>
<column></column>
<column>333</column>
</line>
The partial class:
@Root(name="line")
class Document {
@ElementList(entry="column", inline="true")
private ArrayList<String> columns;
public Document(
@ElementList(entry="column", inline="true") ArrayList<String> columns
) {
this.columns = columns;
}
}
Is there anyway to get the resulting ArrayList to include the empty </column> elements?
Thanks and Kind Regards,
Bokie
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Niall G. <gal...@ya...> - 2012-06-27 12:20:06
|
Is your class an inner class, if so is it static? If it is inner and not static it can be be instantiated. If this is not the problem, send me a test case proving the problem, ill see what the problem is here.
On a side note, I really doubt there is a bug here, constructor injection has been very heavily tested in recent releases. Make sure u are using the most recent release.
--- On Mon, 25/6/12, Andrew Spinner <and...@ti...> wrote:
From: Andrew Spinner <and...@ti...>
Subject: [Simple-support] Constructor injection problems
To: sim...@li...
Received: Monday, 25 June, 2012, 9:27 AM
Hello, and thanks for this lightweight framework,
I'm having some problems with constructor injection for my immutable class.
My instance variables are all final, and are all serialised by Simple. However, I don't need all the fields to be deserialised - some of the fields are derived, being based on mathematical calculations of the other fields. These derived variables are set in the constructor, based on the parameters passed to the constructor.
It doesn't make logical sense to pass values of these derived variables into the constructor, because they're not needed, and will be discarded. However, I've got to do so, or I'll get a ConstructorException, saying "no constructor accepts all read only values."
This isn't my production code, just an example:
public class calc
{
@Element(name="number")
private final int number;
@Element(name="numberSquared")
private final int numberSquared;
//extra constructor I have to provide
public Calc(@Element(name="number") int number, @Element(name="numberSquared") int numberSquared)
{
this(number); //ignores numberSquared parameter, letting chained constructor calculate value for itself
}
//usual constructor
Calc(int number)
{
this.number = number;
numberSquared = number * number; //ignoring parameter and calculating value for itself
}
Unfortunately, even when I create this extra constructor, I still get a PersistenceException: "Constructor not matched for class." As far as I can see, I've annotated the constructor correctly, providing a parameter for every possible field.
Short of me providing my actual code, is there anything I could look at that might fix it?
As a suggestion, it might be useful for PersistenceException to provided more specific information about how the constructor isn't matching.
Thanks,
Andrew
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Danny S. <d.s...@gm...> - 2012-06-26 13:28:09
|
Hello, How do I tell simpleXML to not deserialize elements that don't have values in them ? Regards, Danny |
|
From: Jorge C. <jms...@gm...> - 2012-06-26 00:46:00
|
Hi,
I am using an @ElementList annotation, but the resulting ArrayList does not
include the empty elements found in the XML - I am "loosing" elements
(empty elements).
It also seems that I cannot use the @ElementArray since there is no way of
telling it that the elements are inline.
The partial XML:
<line id="001">
<column>aaa</column>
<column>bbb</column>
<column></column>
</line>
<line id="002">
<column>111</column>
<column></column>
<column>333</column>
</line>
The partial class:
@Root(name="line")
class Document {
@ElementList(entry="column", inline="true")
private ArrayList<String> columns;
public Document(
@ElementList(entry="column", inline="true") ArrayList<String> columns
) {
this.columns = columns;
}
}
Is there anyway to get the resulting ArrayList to include the empty </column>
elements?
Thanks and Kind Regards,
Bokie
|
|
From: Simon B. <sim...@if...> - 2012-06-25 19:41:13
|
Ndrew,
Why do you serialize the derived fields like "numberSquared"? You could just
omit the annotations for these fields, then the serialization would not
contain the fields and the constructor could be as you wish.
Best Regards
Simon
Von: Andrew Spinner [mailto:and...@ti...]
Gesendet: Montag, 25. Juni 2012 18:28
An: sim...@li...
Betreff: [Simple-support] Constructor injection problems
Hello, and thanks for this lightweight framework,
I'm having some problems with constructor injection for my immutable class.
My instance variables are all final, and are all serialised by Simple.
However, I don't need all the fields to be deserialised - some of the fields
are derived, being based on mathematical calculations of the other fields.
These derived variables are set in the constructor, based on the parameters
passed to the constructor.
It doesn't make logical sense to pass values of these derived variables into
the constructor, because they're not needed, and will be discarded. However,
I've got to do so, or I'll get a ConstructorException, saying "no
constructor accepts all read only values."
This isn't my production code, just an example:
public class calc
{
@Element(name="number")
private final int number;
@Element(name="numberSquared")
private final int numberSquared;
//extra constructor I have to provide
public Calc(@Element(name="number") int number,
@Element(name="numberSquared") int numberSquared)
{
this(number); //ignores numberSquared parameter, letting chained constructor
calculate value for itself
}
//usual constructor
Calc(int number)
{
this.number = number;
numberSquared = number * number; //ignoring parameter and calculating value
for itself
}
Unfortunately, even when I create this extra constructor, I still get a
PersistenceException: "Constructor not matched for class." As far as I can
see, I've annotated the constructor correctly, providing a parameter for
every possible field.
Short of me providing my actual code, is there anything I could look at that
might fix it?
As a suggestion, it might be useful for PersistenceException to provided
more specific information about how the constructor isn't matching.
Thanks,
Andrew
|
|
From: Andrew S. <and...@ti...> - 2012-06-25 16:27:42
|
Hello, and thanks for this lightweight framework,
I'm having some problems with constructor injection for my immutable class.
My instance variables are all final, and are all serialised by Simple.
However, I don't need all the fields to be deserialised - some of the
fields are derived, being based on mathematical calculations of the other
fields. These derived variables are set in the constructor, based on the
parameters passed to the constructor.
It doesn't make logical sense to pass values of these derived variables
into the constructor, because they're not needed, and will be discarded.
However, I've got to do so, or I'll get a ConstructorException, saying "no
constructor accepts all read only values."
This isn't my production code, just an example:
public class calc
{
@Element(name="number")
private final int number;
@Element(name="numberSquared")
private final int numberSquared;
//extra constructor I have to provide
public Calc(@Element(name="number") int number,
@Element(name="numberSquared") int numberSquared)
{
this(number); //ignores numberSquared parameter, letting chained
constructor calculate value for itself
}
//usual constructor
Calc(int number)
{
this.number = number;
numberSquared = number * number; //ignoring parameter and calculating value
for itself
}
Unfortunately, even when I create this extra constructor, I still get a
PersistenceException: "Constructor not matched for class." As far as I can
see, I've annotated the constructor correctly, providing a parameter for
every possible field.
Short of me providing my actual code, is there anything I could look at
that might fix it?
As a suggestion, it might be useful for PersistenceException to provided
more specific information about how the constructor isn't matching.
Thanks,
Andrew
|
|
From: Niall G. <gal...@ya...> - 2012-06-19 12:53:50
|
It is possible, however right now all you can do is parse out the line=## values from the exceptions. This is something I would like to add in a future release. --- On Mon, 18/6/12, Mike Goodwin <mik...@ca...> wrote: From: Mike Goodwin <mik...@ca...> Subject: Re: [Simple-support] Handling deserialization exceptions To: "Niall Gallagher" <gal...@ya...> Cc: "Митя Балахонский" <dn...@gm...>, sim...@li... Received: Monday, 18 June, 2012, 8:09 AM Hi, On the subject of exception handling, - Is it possible to retrieve line numbers for the cause of the exception?- Is it possible to store line numbers on elements to relate problems with valid xml that deserialises but has application specific issues which are discovered after deserialisation? - Is it possible to add exception codes to the simple exceptions so that different issues can be handled in a user friendly way? Even better provide details that can be extracted from the exception. e.g. code 123==MISSING ATTRIBUTE, then perhaps after casting the exception extra fields could contain relevant information, e.g. attribute name Simple is great, but from my point of view, I would like to make an application that accepts user created xml and is able to report issues on its own terms without showing the simple error messages/stack traces directly. (in my case it is a build tool so user friendliness is not super critical, but this is still a deficiency) regards, Mike On Tue, Jun 12, 2012 at 10:48 AM, Niall Gallagher <gal...@ya...> wrote: check out Persister.read(MyClass.class, source, false), http://simple.sourceforge.net/download/stream/doc/javadoc/org/simpleframework/xml/core/Persister.html#read(java.lang.Class, java.io.InputStream, boolean) it allows you to read only what your interested in --- On Mon, 11/6/12, Митя Балахонский <dn...@gm...> wrote: From: Митя Балахонский <dn...@gm...> Subject: Re: [Simple-support] Handling deserialization exceptions To: "Niall Gallagher" <gal...@ya...> Cc: sim...@li... Received: Monday, 11 June, 2012, 9:59 PM Thanks Niall! In this simple example - yes, that would be a pretty straightforward way to achieve it.But in real life it is much more complex, not just 1 object with 2 fields, but tens and hundreds, and the server sometimes sends me an epic bullshit, I simply can't predict, where the exception can occur. And that's the case the exceptions were made for! You simply put "try" around the suspicious code, no matter how complex it is, and in the end you just have "Ok" or "Exception" that you can handle. If I do all the validation by hand, this would lead me to a clumsy unreadable error-prone code, that I wanted to avoid and that's why I've chosen your framework. It would be great if Simple Framework supported something like this: @Root(name="order") class Order { @Attribute(name="id", required=true) int id; @Element(name="name", required=false) String name; @HandleException public boolean handleException(Exception e) { Log.w(TAG, "Cannot parse Order, " + e); return false; // false because we don't want to insert it into the list // Or we can throw it again }} // Or, the non-intrusive way@ElementList(stopOnValidationErrors = false)List<Order> orders; Wouldn't that be too insolent of me to suggest a new feature? :) I'll try to add support for it and then show you the result.But if you think that's unreasonable, please let me know and prevent me from digging into the code :) Thanks in advance! 2012/6/12 Niall Gallagher <gal...@ya...> the order attribute must have required=false, take a look at the @Validate annotation, you can simply remove any orders that have a null id. --- On Mon, 11/6/12, Митя Балахонский <dn...@gm...> wrote: From: Митя Балахонский <dn...@gm...> Subject: [Simple-support] Handling deserialization exceptions To: sim...@li... Received: Monday, 11 June, 2012, 11:28 AM Hello, dear All I'm very happy that such a thing as Simple Framework exists, it helps me a lot :) But now I have an issue: I'm using XML for client-server data exchange, and server doesn't always send me valid data. For example: <response> <order id="123"> <name>Foo</name> </order> <order> <name>Bar</name> </order> <order id="456"> <name>Alice</name> </order> </response> I have a simple class for it: @Root(name="order") class Order { @Attribute(name="id", required=true) int id; @Element(name="name", required=false) String name; } @Root(name="response") class Response { @ElementList List<Order> orders; } And an @ElementList of Order in the Response class. It works perfectly until server sends me some order without the "id" attribute. In this case parsing fails and I have no way to receive other orders that were correctly formed, because framework exception fires and cancels all the parsing. Is there a proper way to handle it with Simple Framework? I'd like to have a list of orders, which were parsed correctly, and ignore incorrect ones. With my example that would be a list, containing Foo and Alice, maybe having some notifications that 1 order cannot be parsed because of the exception. Thanks in advance! -- Best regards, Dmitry Balakhonsky ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support -- Best regards, Dmitry Balakhonsky ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Mike G. <mik...@ca...> - 2012-06-18 15:09:46
|
Hi, On the subject of exception handling, - Is it possible to retrieve line numbers for the cause of the exception? - Is it possible to store line numbers on elements to relate problems with valid xml that deserialises but has application specific issues which are discovered after deserialisation? - Is it possible to add exception codes to the simple exceptions so that different issues can be handled in a user friendly way? Even better provide details that can be extracted from the exception. e.g. code 123==MISSING ATTRIBUTE, then perhaps after casting the exception extra fields could contain relevant information, e.g. attribute name Simple is great, but from my point of view, I would like to make an application that accepts user created xml and is able to report issues on its own terms without showing the simple error messages/stack traces directly. (in my case it is a build tool so user friendliness is not super critical, but this is still a deficiency) regards, Mike On Tue, Jun 12, 2012 at 10:48 AM, Niall Gallagher <gal...@ya... > wrote: > check out Persister.read(MyClass.class, source, false), http://simple.sourceforge.net/download/stream/doc/javadoc/org/simpleframework/xml/core/Persister.html#read(java.lang.Class, > java.io.InputStream, boolean) it allows you to read only what your > interested in > > > --- On *Mon, 11/6/12, Митя Балахонский <dn...@gm...>* wrote: > > > From: Митя Балахонский <dn...@gm...> > Subject: Re: [Simple-support] Handling deserialization exceptions > To: "Niall Gallagher" <gal...@ya...> > Cc: sim...@li... > Received: Monday, 11 June, 2012, 9:59 PM > > > Thanks Niall! > > In this simple example - yes, that would be a pretty straightforward way > to achieve it. > But in real life it is much more complex, not just 1 object with 2 fields, > but tens and hundreds, and the server sometimes sends me an epic bullshit, > I simply can't predict, where the exception can occur. > And that's the case the exceptions were made for! You simply put "try" > around the suspicious code, no matter how complex it is, and in the end you > just have "Ok" or "Exception" that you can handle. > If I do all the validation by hand, this would lead me to a clumsy > unreadable error-prone code, that I wanted to avoid and that's why I've > chosen your framework. > > It would be great if Simple Framework supported something like this: > > @Root(name="order") > class Order { > @Attribute(name="id", required=true) > int id; > @Element(name="name", required=false) > String name; > > @HandleException > public boolean handleException(Exception e) { > Log.w(TAG, "Cannot parse Order, " + e); > return false; // false because we don't want to insert it into the > list > // Or we can throw it again > } > } > > // Or, the non-intrusive way > @ElementList(stopOnValidationErrors = false) > List<Order> orders; > > Wouldn't that be too insolent of me to suggest a new feature? :) > > I'll try to add support for it and then show you the result. > But if you think that's unreasonable, please let me know and prevent me > from digging into the code :) > > Thanks in advance! > > 2012/6/12 Niall Gallagher <gal...@ya...<http://mc/compose?to=...@ya...> > > > > the order attribute must have required=false, take a look at the @Validate > annotation, you can simply remove any orders that have a null id. > > --- On *Mon, 11/6/12, Митя Балахонский <dn...@gm...<http://mc/compose?to=...@gm...> > >* wrote: > > > From: Митя Балахонский <dn...@gm...<http://mc/compose?to=...@gm...> > > > Subject: [Simple-support] Handling deserialization exceptions > To: sim...@li...<http://mc/compose?to=...@li...> > Received: Monday, 11 June, 2012, 11:28 AM > > Hello, dear All > > I'm very happy that such a thing as Simple Framework exists, it helps > me a lot :) > But now I have an issue: > I'm using XML for client-server data exchange, and server doesn't > always send me valid data. > For example: > > <response> > <order id="123"> > <name>Foo</name> > </order> > <order> > <name>Bar</name> > </order> > <order id="456"> > <name>Alice</name> > </order> > </response> > > I have a simple class for it: > > @Root(name="order") > class Order { > @Attribute(name="id", required=true) > int id; > @Element(name="name", required=false) > String name; > } > > @Root(name="response") > class Response { > @ElementList > List<Order> orders; > } > > And an @ElementList of Order in the Response class. > > It works perfectly until server sends me some order without the "id" > attribute. In this case parsing fails and I have no way to receive > other orders that were correctly formed, because framework exception > fires and cancels all the parsing. > Is there a proper way to handle it with Simple Framework? > I'd like to have a list of orders, which were parsed correctly, and > ignore incorrect ones. With my example that would be a list, containing > Foo and > Alice, maybe having some notifications that 1 order cannot be parsed > because of the exception. > > Thanks in advance! > > -- > Best regards, > Dmitry Balakhonsky > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Simple-support mailing list > Sim...@li...<http://au.mc1610.mail.yahoo.com/mc/compose?to=...@li...> > https://lists.sourceforge.net/lists/listinfo/simple-support > > > > > -- > Best regards, > Dmitry Balakhonsky > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > > |
|
From: Niall G. <gal...@ya...> - 2012-06-12 09:48:48
|
check out Persister.read(MyClass.class, source, false), http://simple.sourceforge.net/download/stream/doc/javadoc/org/simpleframework/xml/core/Persister.html#read(java.lang.Class, java.io.InputStream, boolean) it allows you to read only what your interested in --- On Mon, 11/6/12, Митя Балахонский <dn...@gm...> wrote: From: Митя Балахонский <dn...@gm...> Subject: Re: [Simple-support] Handling deserialization exceptions To: "Niall Gallagher" <gal...@ya...> Cc: sim...@li... Received: Monday, 11 June, 2012, 9:59 PM Thanks Niall! In this simple example - yes, that would be a pretty straightforward way to achieve it.But in real life it is much more complex, not just 1 object with 2 fields, but tens and hundreds, and the server sometimes sends me an epic bullshit, I simply can't predict, where the exception can occur. And that's the case the exceptions were made for! You simply put "try" around the suspicious code, no matter how complex it is, and in the end you just have "Ok" or "Exception" that you can handle. If I do all the validation by hand, this would lead me to a clumsy unreadable error-prone code, that I wanted to avoid and that's why I've chosen your framework. It would be great if Simple Framework supported something like this: @Root(name="order") class Order { @Attribute(name="id", required=true) int id; @Element(name="name", required=false) String name; @HandleException public boolean handleException(Exception e) { Log.w(TAG, "Cannot parse Order, " + e); return false; // false because we don't want to insert it into the list // Or we can throw it again }} // Or, the non-intrusive way@ElementList(stopOnValidationErrors = false)List<Order> orders; Wouldn't that be too insolent of me to suggest a new feature? :) I'll try to add support for it and then show you the result.But if you think that's unreasonable, please let me know and prevent me from digging into the code :) Thanks in advance! 2012/6/12 Niall Gallagher <gal...@ya...> the order attribute must have required=false, take a look at the @Validate annotation, you can simply remove any orders that have a null id. --- On Mon, 11/6/12, Митя Балахонский <dn...@gm...> wrote: From: Митя Балахонский <dn...@gm...> Subject: [Simple-support] Handling deserialization exceptions To: sim...@li... Received: Monday, 11 June, 2012, 11:28 AM Hello, dear All I'm very happy that such a thing as Simple Framework exists, it helps me a lot :) But now I have an issue: I'm using XML for client-server data exchange, and server doesn't always send me valid data. For example: <response> <order id="123"> <name>Foo</name> </order> <order> <name>Bar</name> </order> <order id="456"> <name>Alice</name> </order> </response> I have a simple class for it: @Root(name="order") class Order { @Attribute(name="id", required=true) int id; @Element(name="name", required=false) String name; } @Root(name="response") class Response { @ElementList List<Order> orders; } And an @ElementList of Order in the Response class. It works perfectly until server sends me some order without the "id" attribute. In this case parsing fails and I have no way to receive other orders that were correctly formed, because framework exception fires and cancels all the parsing. Is there a proper way to handle it with Simple Framework? I'd like to have a list of orders, which were parsed correctly, and ignore incorrect ones. With my example that would be a list, containing Foo and Alice, maybe having some notifications that 1 order cannot be parsed because of the exception. Thanks in advance! -- Best regards, Dmitry Balakhonsky ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support -- Best regards, Dmitry Balakhonsky |
|
From: Митя Б. <dn...@gm...> - 2012-06-12 04:59:18
|
Thanks Niall!
In this simple example - yes, that would be a pretty straightforward way to
achieve it.
But in real life it is much more complex, not just 1 object with 2 fields,
but tens and hundreds, and the server sometimes sends me an epic bullshit,
I simply can't predict, where the exception can occur.
And that's the case the exceptions were made for! You simply put "try"
around the suspicious code, no matter how complex it is, and in the end you
just have "Ok" or "Exception" that you can handle.
If I do all the validation by hand, this would lead me to a clumsy
unreadable error-prone code, that I wanted to avoid and that's why I've
chosen your framework.
It would be great if Simple Framework supported something like this:
@Root(name="order")
class Order {
@Attribute(name="id", required=true)
int id;
@Element(name="name", required=false)
String name;
@HandleException
public boolean handleException(Exception e) {
Log.w(TAG, "Cannot parse Order, " + e);
return false; // false because we don't want to insert it into the
list
// Or we can throw it again
}
}
// Or, the non-intrusive way
@ElementList(stopOnValidationErrors = false)
List<Order> orders;
Wouldn't that be too insolent of me to suggest a new feature? :)
I'll try to add support for it and then show you the result.
But if you think that's unreasonable, please let me know and prevent me
from digging into the code :)
Thanks in advance!
2012/6/12 Niall Gallagher <gal...@ya...>
> the order attribute must have required=false, take a look at the @Validate
> annotation, you can simply remove any orders that have a null id.
>
> --- On *Mon, 11/6/12, Митя Балахонский <dn...@gm...>* wrote:
>
>
> From: Митя Балахонский <dn...@gm...>
> Subject: [Simple-support] Handling deserialization exceptions
> To: sim...@li...
> Received: Monday, 11 June, 2012, 11:28 AM
>
> Hello, dear All
>
> I'm very happy that such a thing as Simple Framework exists, it helps
> me a lot :)
> But now I have an issue:
> I'm using XML for client-server data exchange, and server doesn't
> always send me valid data.
> For example:
>
> <response>
> <order id="123">
> <name>Foo</name>
> </order>
> <order>
> <name>Bar</name>
> </order>
> <order id="456">
> <name>Alice</name>
> </order>
> </response>
>
> I have a simple class for it:
>
> @Root(name="order")
> class Order {
> @Attribute(name="id", required=true)
> int id;
> @Element(name="name", required=false)
> String name;
> }
>
> @Root(name="response")
> class Response {
> @ElementList
> List<Order> orders;
> }
>
> And an @ElementList of Order in the Response class.
>
> It works perfectly until server sends me some order without the "id"
> attribute. In this case parsing fails and I have no way to receive
> other orders that were correctly formed, because framework exception
> fires and cancels all the parsing.
> Is there a proper way to handle it with Simple Framework?
> I'd like to have a list of orders, which were parsed correctly, and
> ignore incorrect ones. With my example that would be a list, containing
> Foo and
> Alice, maybe having some notifications that 1 order cannot be parsed
> because of the exception.
>
> Thanks in advance!
>
> --
> Best regards,
> Dmitry Balakhonsky
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Simple-support mailing list
> Sim...@li...<http://au.mc1610.mail.yahoo.com/mc/compose?to=...@li...>
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
>
--
Best regards,
Dmitry Balakhonsky
|
|
From: Niall G. <gal...@ya...> - 2012-06-11 23:05:56
|
the order attribute must have required=false, take a look at the @Validate annotation, you can simply remove any orders that have a null id.
--- On Mon, 11/6/12, Митя Балахонский <dn...@gm...> wrote:
From: Митя Балахонский <dn...@gm...>
Subject: [Simple-support] Handling deserialization exceptions
To: sim...@li...
Received: Monday, 11 June, 2012, 11:28 AM
Hello, dear All
I'm very happy that such a thing as Simple Framework exists, it helps
me a lot :)
But now I have an issue:
I'm using XML for client-server data exchange, and server doesn't
always send me valid data.
For example:
<response>
<order id="123">
<name>Foo</name>
</order>
<order>
<name>Bar</name>
</order>
<order id="456">
<name>Alice</name>
</order>
</response>
I have a simple class for it:
@Root(name="order")
class Order {
@Attribute(name="id", required=true)
int id;
@Element(name="name", required=false)
String name;
}
@Root(name="response")
class Response {
@ElementList
List<Order> orders;
}
And an @ElementList of Order in the Response class.
It works perfectly until server sends me some order without the "id"
attribute. In this case parsing fails and I have no way to receive
other orders that were correctly formed, because framework exception
fires and cancels all the parsing.
Is there a proper way to handle it with Simple Framework?
I'd like to have a list of orders, which were parsed correctly, and
ignore incorrect ones. With my example that would be a list, containing Foo and
Alice, maybe having some notifications that 1 order cannot be parsed
because of the exception.
Thanks in advance!
--
Best regards,
Dmitry Balakhonsky
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Митя Б. <dn...@gm...> - 2012-06-11 18:28:45
|
Hello, dear All
I'm very happy that such a thing as Simple Framework exists, it helps
me a lot :)
But now I have an issue:
I'm using XML for client-server data exchange, and server doesn't
always send me valid data.
For example:
<response>
<order id="123">
<name>Foo</name>
</order>
<order>
<name>Bar</name>
</order>
<order id="456">
<name>Alice</name>
</order>
</response>
I have a simple class for it:
@Root(name="order")
class Order {
@Attribute(name="id", required=true)
int id;
@Element(name="name", required=false)
String name;
}
@Root(name="response")
class Response {
@ElementList
List<Order> orders;
}
And an @ElementList of Order in the Response class.
It works perfectly until server sends me some order without the "id"
attribute. In this case parsing fails and I have no way to receive
other orders that were correctly formed, because framework exception
fires and cancels all the parsing.
Is there a proper way to handle it with Simple Framework?
I'd like to have a list of orders, which were parsed correctly, and
ignore incorrect ones. With my example that would be a list, containing Foo and
Alice, maybe having some notifications that 1 order cannot be parsed
because of the exception.
Thanks in advance!
--
Best regards,
Dmitry Balakhonsky
|
|
From: Niall G. <gal...@ya...> - 2012-06-03 00:37:04
|
Look for the type hierarchy of Transform using crtl-shift-H, it will be there somewhere.
--- On Sat, 2/6/12, Hong <h...@hz...> wrote:
From: Hong <h...@hz...>
Subject: Re: [Simple-support] A question about enum
To:
Cc: sim...@li...
Received: Saturday, 2 June, 2012, 3:07 AM
I could not find EnumTransform in test cases, so I searched
references of EnumTransform using Eclipse and found only one
reference in PackageMatcher.
I am using the default branch. Could that be a problem?
Hong
On 6/1/2012 11:59 PM, Niall Gallagher wrote:
Look through the
test cases, there is an example in there somewhere.
--- On Fri, 1/6/12, Hong <h...@hz...>
wrote:
From: Hong <h...@hz...>
Subject: Re: [Simple-support] A question about enum
To:
Cc: sim...@li...
Received: Friday, 1 June, 2012, 8:00 PM
Thanks for the tip. It is exactly what I was
looking for by tracing the calls, but failed to
reach it.
EnumTransform does not seem to be used for
serializing an enum variable in my code. I probably
have misunderstood how EnumTransform is used.
Hong
On 6/1/2012 10:24 PM, Niall Gallagher wrote:
Take
a look at EnumTransform, you can create a
transform for enums and register it with
the persister. It will handle
transformation of the enum values.
--- On Fri, 1/6/12, Hong <h...@hz...>
wrote:
From: Hong <h...@hz...>
Subject: [Simple-support] A question
about enum
To: sim...@li...
Received: Friday, 1 June, 2012, 10:02 AM
Hi
all,
I apologize if this rudimentary
question has been asked before.
I am trying to figure out how to
serialize enum values to something
different than their face values.
For example, for the following enum
enum Foo
{
MyFoo,
YourFoo
}
I want to serialize it to "My-Foo" and
"Your-Foo".
It seems that SimpleXML does not like
the following:
enum Foo
{
MyFoo{
public String toString() {
return "My-Foo";
}
},
YourFoo{
public String toString() {
return "Your-Foo";
}
};
}
Any tip will be greatly appreciated.
Hong
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all
the ways today's security and
threat landscape has changed and how
IT managers can respond. Discussions
will include endpoint security, mobile
security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's
security and
threat landscape has changed and how IT managers can
respond. Discussions
will include endpoint security, mobile security and
the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Niall G. <gal...@ya...> - 2012-06-02 03:59:52
|
Look through the test cases, there is an example in there somewhere.
--- On Fri, 1/6/12, Hong <h...@hz...> wrote:
From: Hong <h...@hz...>
Subject: Re: [Simple-support] A question about enum
To:
Cc: sim...@li...
Received: Friday, 1 June, 2012, 8:00 PM
Thanks for the tip. It is exactly what I was looking for by tracing
the calls, but failed to reach it.
EnumTransform does not seem to be used for serializing an enum
variable in my code. I probably have misunderstood how
EnumTransform is used.
Hong
On 6/1/2012 10:24 PM, Niall Gallagher wrote:
Take a look at
EnumTransform, you can create a transform for enums and
register it with the persister. It will handle
transformation of the enum values.
--- On Fri, 1/6/12, Hong <h...@hz...>
wrote:
From: Hong <h...@hz...>
Subject: [Simple-support] A question about enum
To: sim...@li...
Received: Friday, 1 June, 2012, 10:02 AM
Hi all,
I apologize if this rudimentary question has been
asked before.
I am trying to figure out how to serialize enum values
to something
different than their face values.
For example, for the following enum
enum Foo
{
MyFoo,
YourFoo
}
I want to serialize it to "My-Foo" and "Your-Foo".
It seems that SimpleXML does not like the following:
enum Foo
{
MyFoo{
public String toString() {
return "My-Foo";
}
},
YourFoo{
public String toString() {
return "Your-Foo";
}
};
}
Any tip will be greatly appreciated.
Hong
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's
security and
threat landscape has changed and how IT managers can
respond. Discussions
will include endpoint security, mobile security and
the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Niall G. <gal...@ya...> - 2012-06-02 02:24:19
|
Take a look at EnumTransform, you can create a transform for enums and register it with the persister. It will handle transformation of the enum values.
--- On Fri, 1/6/12, Hong <h...@hz...> wrote:
From: Hong <h...@hz...>
Subject: [Simple-support] A question about enum
To: sim...@li...
Received: Friday, 1 June, 2012, 10:02 AM
Hi all,
I apologize if this rudimentary question has been asked before.
I am trying to figure out how to serialize enum values to something
different than their face values.
For example, for the following enum
enum Foo
{
MyFoo,
YourFoo
}
I want to serialize it to "My-Foo" and "Your-Foo".
It seems that SimpleXML does not like the following:
enum Foo
{
MyFoo{
public String toString() {
return "My-Foo";
}
},
YourFoo{
public String toString() {
return "Your-Foo";
}
};
}
Any tip will be greatly appreciated.
Hong
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Hong <h...@hz...> - 2012-06-01 17:15:44
|
Hi all,
I apologize if this rudimentary question has been asked before.
I am trying to figure out how to serialize enum values to something
different than their face values.
For example, for the following enum
enum Foo
{
MyFoo,
YourFoo
}
I want to serialize it to "My-Foo" and "Your-Foo".
It seems that SimpleXML does not like the following:
enum Foo
{
MyFoo{
public String toString() {
return "My-Foo";
}
},
YourFoo{
public String toString() {
return "Your-Foo";
}
};
}
Any tip will be greatly appreciated.
Hong
|
|
From: Shobhit S. <sho...@gm...> - 2012-05-31 12:06:13
|
thanks for replying.
After changing the code, I was able to deserialize the xml. But I had to
change the attribute "class" to some other name say for eg "class1". I
think "class" is a keyword and cannot be used directly. With "class" as
attribute I am getting following errors :
------------------------------------------------------------------------------------------------------------------------------------
Exception in thread "main" java.lang.ClassNotFoundException: Action3
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.simpleframework.xml.strategy.Loader.load(Loader.java:50)
at
org.simpleframework.xml.strategy.TreeStrategy.readValue(TreeStrategy.java:163)
at org.simpleframework.xml.strategy.TreeStrategy.read(TreeStrategy.java:102)
at org.simpleframework.xml.core.Source.getOverride(Source.java:370)
at org.simpleframework.xml.core.Factory.getConversion(Factory.java:207)
at org.simpleframework.xml.core.Factory.getOverride(Factory.java:139)
at
org.simpleframework.xml.core.ObjectFactory.getInstance(ObjectFactory.java:63)
at org.simpleframework.xml.core.Composite.read(Composite.java:141)
at org.simpleframework.xml.core.Traverser.read(Traverser.java:92)
at
org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:190)
at
org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:167)
at
org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:124)
at org.simpleframework.xml.core.Composite.readVariable(Composite.java:687)
at org.simpleframework.xml.core.Composite.readInstance(Composite.java:635)
at org.simpleframework.xml.core.Composite.readUnion(Composite.java:610)
at org.simpleframework.xml.core.Composite.readElement(Composite.java:593)
at org.simpleframework.xml.core.Composite.readElements(Composite.java:506)
at org.simpleframework.xml.core.Composite.readSection(Composite.java:388)
at org.simpleframework.xml.core.Composite.read(Composite.java:367)
at org.simpleframework.xml.core.Composite.readDefault(Composite.java:262)
at org.simpleframework.xml.core.Composite.read(Composite.java:232)
at org.simpleframework.xml.core.Composite.read(Composite.java:202)
at org.simpleframework.xml.core.Composite.read(Composite.java:150)
at org.simpleframework.xml.core.Traverser.read(Traverser.java:92)
at org.simpleframework.xml.core.Persister.read(Persister.java:632)
at org.simpleframework.xml.core.Persister.read(Persister.java:613)
at org.simpleframework.xml.core.Persister.read(Persister.java:591)
at org.simpleframework.xml.core.Persister.read(Persister.java:550)
at org.simpleframework.xml.core.Persister.read(Persister.java:528)
at org.simpleframework.xml.core.Persister.read(Persister.java:433)
at org.emotio.tasker.datadef.Deserialize.main(Deserialize.java:26)
------------------------------------------------------------------------------------------------------------------------------------
Thus can anyone help me with how can I make read the attribute "class".
Also, my new code is given below. This code is working fine if I change the
attribute "class" to some other name and make respective changes.
test.xml
<datadef>
<maxversion class="Action3" v.="3"/>
<maxversion class="Action4" v.="4"/>
<maxversion class="Action5" v.="5"/>
</datadef>
Deserialize.java
import java.io.File;
import java.util.List;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
public class Deserialize {
@ElementList(inline=true)
public List<Maxversion> max_version;
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Serializer serializer = new Persister();
File source = new File("importFiles/test.xml");
Deserialize deserialize = serializer.read(Deserialize.class, source);
int count_version = deserialize.max_version.size();
int i = 0;
while(i < count_version)
{
System.out.println(deserialize.max_version.get(i).class1 + " " +
deserialize.max_version.get(i).version);
i++;
}
}
}
Maxversion.java
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Root;
@Root(name="maxversion")
public class Maxversion {
@Attribute(name="class", required=false)
public String class1;
@Attribute(name="v.", required=false)
public int version;
}
Awaiting for help.
thanks in advance.
regards,
--
Shobhit Sharda
MSc in SSE
RWTH Aachen University
Aachen
Germany
blog: http://shobhitsharda.wordpress.com
|
|
From: Niall G. <gal...@ya...> - 2012-05-31 08:43:34
|
You are using @ElementList when you need to use @Element, take a look at the tutorial or the examples page on the web site, it will explain how to use the framework.
--- On Wed, 30/5/12, Shobhit Sharda <sho...@gm...> wrote:
From: Shobhit Sharda <sho...@gm...>
Subject: [Simple-support] error while deserializing
To: sim...@li...
Received: Wednesday, 30 May, 2012, 5:56 AM
Hello everyone,
I am trying to deserialize the following xml
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<datadef>
<maxversion class="Action3" v.="3"/>
<maxversion class="Action4" v.="4"/>
<maxversion class="Action5" v.="5"/>
</datadef>
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Using the following code :
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Root;
@Root
public class maxversion {
@Attribute(name="class", required=false)
public String[] class1;
@Attribute(name="v.", required=false)
public int[] version;
}
import java.io.File;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
public class deserialize {
@ElementList(name="maxversion", required=false)
public maxversion max_version = new maxversion();
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Serializer serializer = new Persister();
File source = new File("file.xml");
deserialize deserialize = serializer.read(deserialize.class, source);
int count_max_version = deserialize.max_version.class1.length;
int i=0;
while(i<count_max_version)
{
System.out.println(deserialize.max_version.class1[i]);
System.out.println(deserialize.max_version.version[i]);
}
}
}
While executing class deserialize, I am getting following error :
Exception in thread "main"
org.simpleframework.xml.core.ElementException: Unable to determine
generic type for field 'max_version' public maxversion
deserialize.max_version
//followed by someother logs
I am not able to resolve the error. Can anyone help me out.
thanks in advance.
--
Shobhit Sharda
MSc in SSE
RWTH Aachen University
Aachen
Germany
blog: http://shobhitsharda.wordpress.com
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Shobhit S. <sho...@gm...> - 2012-05-30 12:57:31
|
Hello everyone,
I am trying to deserialize the following xml
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<datadef>
<maxversion class="Action3" v.="3"/>
<maxversion class="Action4" v.="4"/>
<maxversion class="Action5" v.="5"/>
</datadef>
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Using the following code :
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Root;
@Root
public class maxversion {
@Attribute(name="class", required=false)
public String[] class1;
@Attribute(name="v.", required=false)
public int[] version;
}
import java.io.File;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
public class deserialize {
@ElementList(name="maxversion", required=false)
public maxversion max_version = new maxversion();
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Serializer serializer = new Persister();
File source = new File("file.xml");
deserialize deserialize = serializer.read(deserialize.class, source);
int count_max_version = deserialize.max_version.class1.length;
int i=0;
while(i<count_max_version)
{
System.out.println(deserialize.max_version.class1[i]);
System.out.println(deserialize.max_version.version[i]);
}
}
}
While executing class deserialize, I am getting following error :
Exception in thread "main"
org.simpleframework.xml.core.ElementException: Unable to determine
generic type for field 'max_version' public maxversion
deserialize.max_version
//followed by someother logs
I am not able to resolve the error. Can anyone help me out.
thanks in advance.
--
Shobhit Sharda
MSc in SSE
RWTH Aachen University
Aachen
Germany
blog: http://shobhitsharda.wordpress.com
|
|
From: Niall G. <gal...@ya...> - 2012-05-29 09:59:05
|
Serialization is done depth first, so you will get some attributes during serialization, for example the setter bean methods will be invoked, however I am not sure you will be able to do what you want as these references will only exist within the context of the serializer. --- On Tue, 29/5/12, Eli Konky <eli...@gm...> wrote: From: Eli Konky <eli...@gm...> Subject: [Simple-support] Having simple set properties on an object during parsing? To: sim...@li... Received: Tuesday, 29 May, 2012, 1:10 AM Hi, Is there a way to make simple set properties on an object before all the document is parsed?I know about the commit feature, but the thing is that this is called on the object only after all its properties are read from the xml. this is a critical requirement in the project since the xml we get are quite big and we want to present data as soon as possible. ThanksEli -----Inline Attachment Follows----- ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ -----Inline Attachment Follows----- _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Eli K. <eli...@gm...> - 2012-05-29 08:10:19
|
Hi, Is there a way to make simple set properties on an object before all the document is parsed? I know about the commit feature, but the thing is that this is called on the object only after all its properties are read from the xml. this is a critical requirement in the project since the xml we get are quite big and we want to present data as soon as possible. Thanks Eli |
|
From: Simon B. <sim...@if...> - 2012-05-29 05:55:35
|
Hi Miguel,
Basically this does it:
@Root(name="Courses")
public class Courses {
@ElementList(entry="Course",type=com.simpleserializer.model.Course.class,
inline=true)
Collection<Course> getCourses() {
return new ArrayList<Course>(this.courses.values());
}
@ElementList(entry="Course",type=com.simpleserializer.model.Course.class,
inline=true)
void setCourses(final java.util.Collection<Course> courses) {
for(Course course: courses) {
this.put(course.getId(), course);
}
}
private final HashMap<String, Course> courses = new HashMap<String,
Course>();
public void put(final String courseId, final Course course) {
this.courses.put(course.getId(), course);
}
}
If you want to solve a similar problem, have a look to
http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#inli
ne
http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#java
bean
http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#over
ride
I'm sure the explanations and the examples will greatly help.
Best Regards
Simon
-----Ursprüngliche Nachricht-----
Von: Miguel Ángel Martínez Fernández [mailto:mig...@gm...]
Gesendet: Montag, 28. Mai 2012 23:28
An: Simon Brodt
Cc: sim...@li...
Betreff: Re: [Simple-support] Custom HashMap serialization/deserialization -
Help
Hi Simon,
Sorry but it didn't work. I get the following exception:
Can not construct inner class java.util.HashMap$Values
I have also added a ZIP file wth an extract of the project just in
case it may help.
Thanks again for your support!
Miguel Ángel
On Mon, May 28, 2012 at 8:53 PM, Simon Brodt <sim...@if...> wrote:
> Hi Miguel,
>
> Sorry, I was a little bit to fast. Didn't realize the Map:
>
> So new try:
>
> public class Courses {
>
@ElementList(entry=Course,type=com.simpleserializer.model.Course.class,
> inline=true)
> java.util.Collection<Course> getCourses(){
> return courses.values();
> }
>
> @ElementList(entry=Course,type=com.simpleserializer.model.Course.class,
> inline=true)
> void setCourses(java.util.Collection<Course> courses){
> for(Course course: courses){
> this.put(course);
> }
> }
>
> private HashMap<String, Course> courses = new
> HashMap<String, Course>();
>
> public void put(Course course)
> {
> this.courses.put(course.getId(), course);
> }
>
> }
>
>
>> Hi Simon!
>>
>> Thank you for your quick answer.
>>
>> Unfortunately it did not work. When I try this:
>>
>> // Retrieving courses from ddbb
>> Courses courses = CoursesDAO.get(token, connection);
>>
>> // Serialization to xml
>> String xml = Serializer.toXml(courses);
>>
>> It raises the following exception:
>>
>> java.util.HashMap cannot be cast to java.util.Collection
>>
>> The rest of the code below:
>>
>> Serializer.java:
>>
>> package com.simpleserializer.util;
>>
>> import java.io.StringWriter;
>>
>> import org.simpleframework.xml.core.Persister;
>>
>> public class Serializer {
>> public static String toXml(Object source) {
>> StringWriter response = new StringWriter();
>>
>> try {
>> new Persister().write(source, response);
>> } catch (Exception e) {
>> e1.printStackTrace();
>> }
>>
>> return response.toString();
>> }
>> }
>>
>>
>> On Mon, May 28, 2012 at 12:12 PM, Simon Brodt <sim...@if...>
>> wrote:
>>> Hi Miguel,
>>>
>>>
>>>
>>> Try the following:
>>>
>>>
>>>
>>> Course.java:
>>>
>>> package com.simpleserializer.model;
>>>
>>>
>>>
>>> import org.simpleframework.xml.Attribute;
>>>
>>>
>>>
>>> @Root(name=Course)
>>>
>>> public class Course {
>>>
>>> @Attribute private String id;
>>>
>>> @Attribute private String name;
>>>
>>>
>>>
>>> public Course(String id, String name) {
>>>
>>> this.setId(id);
>>>
>>> this.setName(name);
>>>
>>> }
>>>
>>>
>>>
>>> public String getId() {
>>>
>>> return this.id;
>>>
>>> }
>>>
>>>
>>>
>>> public void setId(String id) {
>>>
>>> this.id = id;
>>>
>>> }
>>>
>>>
>>>
>>> public String getName() {
>>>
>>> return this.name;
>>>
>>> }
>>>
>>>
>>>
>>> public void setName(String name) {
>>>
>>> this.name = name;
>>>
>>> }
>>>
>>> }
>>>
>>>
>>>
>>> Course2.java:
>>>
>>> package com.simpleserializer.model;
>>>
>>>
>>>
>>> import java.util.HashMap;
>>>
>>>
>>>
>>> @Root(name=Courses)
>>>
>>> public class Courses {
>>>
>>>
>>>
>>> @ElementList(entry=Course,type=
>>> com.simpleserializer.model.Course.class, inline=true)
>>>
>>> private HashMap<String, Course> courses = new
>>> HashMap<String, Course>();
>>>
>>>
>>>
>>> public void put(String courseId, Course course)
>>>
>>> {
>>>
>>> this.courses.put(courseId, course);
>>>
>>> }
>>>
>>> }
>>>
>>>
>>>
>>> Von: Miguel Ángel Martínez Fernández [mailto:mig...@gm...]
>>> Gesendet: Montag, 28. Mai 2012 01:35
>>> An: sim...@li...
>>> Betreff: [Simple-support] Custom HashMap serialization/deserialization -
>>> Help
>>>
>>>
>>>
>>> Hi,
>>>
>>>
>>>
>>> I am trying to serialize (and deserialize) two Java clases
>>> (Courses.java
>>> and Couse.Java) in order to get the following XML:
>>>
>>>
>>>
>>> <Courses>
>>>
>>> <Course id="course01" name="My first course"/>
>>>
>>> <Course id="course02" name="My second course"/>
>>>
>>> </Courses>
>>>
>>>
>>>
>>> Course.java:
>>>
>>> package com.simpleserializer.model;
>>>
>>>
>>>
>>> import org.simpleframework.xml.Attribute;
>>>
>>>
>>>
>>> public class Course {
>>>
>>> @Attribute private String id;
>>>
>>> @Attribute private String name;
>>>
>>>
>>>
>>> public Course(String id, String name) {
>>>
>>> this.setId(id);
>>>
>>> this.setName(name);
>>>
>>> }
>>>
>>>
>>>
>>> public String getId() {
>>>
>>> return this.id;
>>>
>>> }
>>>
>>>
>>>
>>> public void setId(String id) {
>>>
>>> this.id = id;
>>>
>>> }
>>>
>>>
>>>
>>> public String getName() {
>>>
>>> return this.name;
>>>
>>> }
>>>
>>>
>>>
>>> public void setName(String name) {
>>>
>>> this.name = name;
>>>
>>> }
>>>
>>> }
>>>
>>>
>>>
>>> Course2.java:
>>>
>>> package com.simpleserializer.model;
>>>
>>>
>>>
>>> import java.util.HashMap;
>>>
>>>
>>>
>>> public class Courses {
>>>
>>> private HashMap<String, Course> courses = new
>>> HashMap<String,
>>> Course>();
>>>
>>>
>>>
>>> public void put(String courseId, Course course)
>>>
>>> {
>>>
>>> this.courses.put(courseId, course);
>>>
>>> }
>>>
>>> }
>>>
>>>
>>>
>>> An example about how these clases are used is:
>>>
>>>
>>>
>>> Courses courses = new Courses();
>>>
>>>
>>>
>>> Course course1 = new Course("course01", "My first course");
>>>
>>> Course course2 = new Course("course02", "My second course");
>>>
>>>
>>>
>>> courses.put(course1.getId(), course1);
>>>
>>> courses.put(course2.getId(), course2);
>>>
>>>
>>>
>>>
>>>
>>> Could you please help me? I would really appreciate it!
>>>
>>>
>>>
>>> Thanks!
>>
>
>
|