simple-support Mailing List for Simple (Page 15)
Brought to you by:
niallg
You can subscribe to this list here.
| 2007 |
Jan
|
Feb
(2) |
Mar
(2) |
Apr
(13) |
May
(13) |
Jun
(27) |
Jul
(4) |
Aug
(14) |
Sep
(7) |
Oct
|
Nov
(6) |
Dec
(24) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
|
Feb
(21) |
Mar
(10) |
Apr
(15) |
May
(24) |
Jun
(24) |
Jul
(30) |
Aug
(5) |
Sep
(19) |
Oct
(27) |
Nov
(16) |
Dec
(24) |
| 2009 |
Jan
(34) |
Feb
(24) |
Mar
(35) |
Apr
(26) |
May
(8) |
Jun
(17) |
Jul
(28) |
Aug
(31) |
Sep
(36) |
Oct
(35) |
Nov
(20) |
Dec
(16) |
| 2010 |
Jan
(40) |
Feb
(21) |
Mar
(47) |
Apr
(45) |
May
(34) |
Jun
(68) |
Jul
(46) |
Aug
(39) |
Sep
(47) |
Oct
(20) |
Nov
(42) |
Dec
(13) |
| 2011 |
Jan
(41) |
Feb
(16) |
Mar
(32) |
Apr
(44) |
May
(28) |
Jun
(35) |
Jul
(37) |
Aug
(33) |
Sep
(60) |
Oct
(20) |
Nov
(35) |
Dec
(23) |
| 2012 |
Jan
(34) |
Feb
(23) |
Mar
(34) |
Apr
(21) |
May
(48) |
Jun
(24) |
Jul
(31) |
Aug
(39) |
Sep
(25) |
Oct
(10) |
Nov
(27) |
Dec
(28) |
| 2013 |
Jan
(32) |
Feb
(24) |
Mar
(24) |
Apr
(9) |
May
(4) |
Jun
(6) |
Jul
(2) |
Aug
(5) |
Sep
|
Oct
(5) |
Nov
(1) |
Dec
(12) |
| 2014 |
Jan
(14) |
Feb
(16) |
Mar
(5) |
Apr
(3) |
May
(2) |
Jun
(8) |
Jul
(2) |
Aug
|
Sep
(6) |
Oct
|
Nov
(6) |
Dec
|
| 2015 |
Jan
(3) |
Feb
(15) |
Mar
(7) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
(1) |
| 2016 |
Jan
|
Feb
(6) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2019 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Niall G. <gal...@ya...> - 2012-07-30 09:48:40
|
You could use a Converter, or you could just serialize one object i.e drop B.
--- On Fri, 27/7/12, Maxim Solodovnik <sol...@gm...> wrote:
From: Maxim Solodovnik <sol...@gm...>
Subject: [Simple-support] Availabily of object inlining
To: sim...@li...
Received: Friday, 27 July, 2012, 2:04 AM
Hello,
I have very specific question regarding object serialization:Our current code uses "hand writed" serialization/deserialization to/from XML.I would like to port it to use "Simple framework".
2 features I was unable to find in documentation/examples1) serializing of List<MyObject> (can be workarounded by creating additional class holding list as the only parameter)
2) inlining of property object: imaging we have@Rootclass A { @Element String prop; @Element B b;}
@Rootclass B { @Element String propB1; @Element String propB2;}
Serializing of A will produce:<a>
<prop></prop> <b> <propB1></propB1> <propB2></propB2> </b></a>
what I need is to get (to be compatible with previous versions)
<a> <prop></prop> <propB1></propB1> <propB2></propB2></a>
Is this possible somehow?
Maybe 1) above can be implemented without creating additional class?
Sorry for the long postThanks in advance
--
WBR
Maxim aka solomax
-----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: Maxim S. <sol...@gm...> - 2012-07-27 09:04:44
|
Hello,
I have very specific question regarding object serialization:
Our current code uses "hand writed" serialization/deserialization to/from
XML.
I would like to port it to use "Simple framework".
2 features I was unable to find in documentation/examples
1) serializing of List<MyObject> (can be workarounded by creating
additional class holding list as the only parameter)
2) inlining of property object:
imaging we have
@Root
class A {
@Element
String prop;
@Element
B b;
}
@Root
class B {
@Element
String propB1;
@Element
String propB2;
}
Serializing of A will produce:
<a>
<prop></prop>
<b>
<propB1></propB1>
<propB2></propB2>
</b>
</a>
what I need is to get (to be compatible with previous versions)
<a>
<prop></prop>
<propB1></propB1>
<propB2></propB2>
</a>
Is this possible somehow?
Maybe 1) above can be implemented without creating additional class?
Sorry for the long post
Thanks in advance
--
WBR
Maxim aka solomax
|
|
From: Simon B. <sim...@if...> - 2012-07-25 17:30:44
|
Hi Niall, The problem in Test2 seems to be solved when modifying the attached classes. At least things then work for me. Maybe one has do apply analogous changes to some other classes, i.e. those for arrays. Best Regards Simon -----Ursprüngliche Nachricht----- Von: Niall Gallagher [mailto:gal...@ya...] Gesendet: Sonntag, 22. Juli 2012 10:49 An: sim...@li...; Simon Brodt Betreff: Re: [Simple-support] Once again some test cases: Replace Hi Simon, I am not sure Test1 is actually an error, for instance how do you deserialize the final string if there is no method or constructor to accept it, I think whats needed here is required=false, or at least annotate the constructor argument so it can be accepted then just ignore it. With regards to Test2 I am not sure whats being tested. You serialize Test2 be deserialize Test1 however in no place is @Replace or @Resolve used to switch to Test1 anywhere. Is this case correct? If you think there is a real issue here that I am just not getting let me know, I appreciate the feedback. Thanks, Niall --- On Sat, 21/7/12, Simon Brodt <sim...@if...> wrote: > From: Simon Brodt <sim...@if...> > Subject: [Simple-support] Once again some test cases: Replace > To: sim...@li... > Received: Saturday, 21 July, 2012, 10:51 PM > Dear Niall, > > It seems like I discovered some problem with the Replace > annotation. Maybe > you could have a look on it. > > Best Regards > > Simon > > -----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: Simon B. <sim...@if...> - 2012-07-22 10:19:31
|
Hi Niall, Sorry, there was a typo in Test2. Of course it should try to deserialize an instance of Test2. However the problem is not the deserialization (though the eror happens there). The problem is that during the serialization the replace method is not called if an object is serialized as part of an ElementList. With respect to Test1: Yes this is definitely a bug. The point is that actually never an instance of Test1$Test1B is ever serialized but is always replaced by an instance of Test1. And for the deserialization, an instance of Test1$Test1B is never deserialized, but only instances of Test1 which are resolved to instances of Test1$Test1B. The exception would be kind of correct if it did occur during the deserialization of an instance of Test1$Test1B. However it occurs during the serialization. Please compare the constructors of Test1$Test1A and of Test1$Test1B. The main difference is, that Test$Test1A has no default constructor (Note that the constructor of Test1$Test1A is not annotated and just has dummy argument to achieve this). However serialization and deserialization are fine for Test1$Test1A but not for Test1$Test1B. Best Regards Simon -----Ursprüngliche Nachricht----- Von: Niall Gallagher [mailto:gal...@ya...] Gesendet: Sonntag, 22. Juli 2012 10:49 An: sim...@li...; Simon Brodt Betreff: Re: [Simple-support] Once again some test cases: Replace Hi Simon, I am not sure Test1 is actually an error, for instance how do you deserialize the final string if there is no method or constructor to accept it, I think whats needed here is required=false, or at least annotate the constructor argument so it can be accepted then just ignore it. With regards to Test2 I am not sure whats being tested. You serialize Test2 be deserialize Test1 however in no place is @Replace or @Resolve used to switch to Test1 anywhere. Is this case correct? If you think there is a real issue here that I am just not getting let me know, I appreciate the feedback. Thanks, Niall --- On Sat, 21/7/12, Simon Brodt <sim...@if...> wrote: > From: Simon Brodt <sim...@if...> > Subject: [Simple-support] Once again some test cases: Replace > To: sim...@li... > Received: Saturday, 21 July, 2012, 10:51 PM > Dear Niall, > > It seems like I discovered some problem with the Replace > annotation. Maybe > you could have a look on it. > > Best Regards > > Simon > > -----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-07-22 08:49:35
|
Hi Simon, I am not sure Test1 is actually an error, for instance how do you deserialize the final string if there is no method or constructor to accept it, I think whats needed here is required=false, or at least annotate the constructor argument so it can be accepted then just ignore it. With regards to Test2 I am not sure whats being tested. You serialize Test2 be deserialize Test1 however in no place is @Replace or @Resolve used to switch to Test1 anywhere. Is this case correct? If you think there is a real issue here that I am just not getting let me know, I appreciate the feedback. Thanks, Niall --- On Sat, 21/7/12, Simon Brodt <sim...@if...> wrote: > From: Simon Brodt <sim...@if...> > Subject: [Simple-support] Once again some test cases: Replace > To: sim...@li... > Received: Saturday, 21 July, 2012, 10:51 PM > Dear Niall, > > It seems like I discovered some problem with the Replace > annotation. Maybe > you could have a look on it. > > Best Regards > > Simon > > -----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: Simon B. <sim...@if...> - 2012-07-22 05:51:27
|
Dear Niall, It seems like I discovered some problem with the Replace annotation. Maybe you could have a look on it. Best Regards Simon |
|
From: Niall G. <gal...@ya...> - 2012-07-16 03:34:13
|
Can you send me on a patch with your fix or a test case, I think I know what your talking about here, but not 100% sure. --- On Sun, 15/7/12, Shevek <sh...@an...> wrote: > From: Shevek <sh...@an...> > Subject: Re: [Simple-support] RegistryStrategy causes NPE when Converter is used > To: "Niall Gallagher" <gal...@ya...> > Cc: sim...@li... > Received: Sunday, 15 July, 2012, 3:53 PM > This bug is still outstanding in > 2.6.4 - any chance of a fix in trunk? > > I have modified RegistryStrategy.read() to call lookup(type, > null) again > in 2.6.4 and now my code can parse arrays again. > > S. > > On Mon, 2012-05-07 at 00:19 -0700, Niall Gallagher wrote: > > Cool, thanks for the feedback, ill make sure this is > sorted out in the > > next release. > > > > --- On Sun, 6/5/12, Shevek <sh...@an...> > wrote: > > > > From: Shevek > <sh...@an...> > > Subject: Re: > [Simple-support] RegistryStrategy causes NPE when > > Converter is > used > > To: sim...@li... > > Received: Sunday, > 6 May, 2012, 9:35 PM > > > > On Sun, > 2012-05-06 at 20:24 -0700, Shevek wrote: > > > Test case is > a bit tangled, but I can provide it if the > > explanation > > > below isn't > sufficient: > > > > > > * Interface > Value has a method getType() which returns the > > type of the > > > value. > > > > > > * However > ArrayValue implements this to return the type of > > the element, > > > not the > array type. See TreeStrategy.read() lines circa 105, > > where > > > 'actual', > not 'expect' is passed to readArray(). > > > > > > * This > causes RegistryStrategy's read() method to call > > lookup() with an > > > element > type, and return a Converter when it is actually > > holding the > > > array node, > not the element node. > > > > > > * This > causes the Converter to fail, since it gets given the > > InputNode > > > for the > array itself, not the InputNode for the array > > element, and so > > > the > attributes expected are not present. > > > > > > Possible > solutions: > > > > > > 1) Pass > 'actual', not 'expect' to ArrayValue. This makes > > ArrayValue > > > satisfy the > contract of Value, but may break things which > > rely on > > > ArrayValue > being a special case. > > > > > > 2) During > deserialization, at the point where > > RegistryStrategy > calls > > > lookup(), > make it ignore Value.getType(), since that is > > invalid, and > > > rely on the > expected type if present. This may still have to > > use > > > > Value.getType() during serialization... > > > > Changing read() > to call lookup(type, null) fixes the bug. > > write() still > > calls > lookup(type, value) > > > > S. > > > > > > > ------------------------------------------------------------------------------ > > 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: Shevek <sh...@an...> - 2012-07-15 22:53:35
|
This bug is still outstanding in 2.6.4 - any chance of a fix in trunk? I have modified RegistryStrategy.read() to call lookup(type, null) again in 2.6.4 and now my code can parse arrays again. S. On Mon, 2012-05-07 at 00:19 -0700, Niall Gallagher wrote: > Cool, thanks for the feedback, ill make sure this is sorted out in the > next release. > > --- On Sun, 6/5/12, Shevek <sh...@an...> wrote: > > From: Shevek <sh...@an...> > Subject: Re: [Simple-support] RegistryStrategy causes NPE when > Converter is used > To: sim...@li... > Received: Sunday, 6 May, 2012, 9:35 PM > > On Sun, 2012-05-06 at 20:24 -0700, Shevek wrote: > > Test case is a bit tangled, but I can provide it if the > explanation > > below isn't sufficient: > > > > * Interface Value has a method getType() which returns the > type of the > > value. > > > > * However ArrayValue implements this to return the type of > the element, > > not the array type. See TreeStrategy.read() lines circa 105, > where > > 'actual', not 'expect' is passed to readArray(). > > > > * This causes RegistryStrategy's read() method to call > lookup() with an > > element type, and return a Converter when it is actually > holding the > > array node, not the element node. > > > > * This causes the Converter to fail, since it gets given the > InputNode > > for the array itself, not the InputNode for the array > element, and so > > the attributes expected are not present. > > > > Possible solutions: > > > > 1) Pass 'actual', not 'expect' to ArrayValue. This makes > ArrayValue > > satisfy the contract of Value, but may break things which > rely on > > ArrayValue being a special case. > > > > 2) During deserialization, at the point where > RegistryStrategy calls > > lookup(), make it ignore Value.getType(), since that is > invalid, and > > rely on the expected type if present. This may still have to > use > > Value.getType() during serialization... > > Changing read() to call lookup(type, null) fixes the bug. > write() still > calls lookup(type, value) > > S. > > > ------------------------------------------------------------------------------ > 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-07-13 07:04:21
|
Hi João, If you are talking about binding using namespaces then this can already be done. Not out of the box but there is an implementation in one of the test cases for this and it works fine. Check out this http://simple.svn.sourceforge.net/svnroot/simple/trunk/download/stream/src/test/java/org/simpleframework/xml/strategy/ClassToNamespaceVisitor.java Its not very well written, but it works! As far as Converters there is no preference, you need to use annotations with Converters for example. @Element private MyObject val This tells the converter to serialize MyObject, so it looks for a converter, if it finds one then it uses it, otherwise it uses default serialization. I guess if you had annotations on MyObject converters would be used first. Thanks, Niall --- On Wed, 11/7/12, João M. Gonçalves <jm...@gm...> wrote: > From: João M. Gonçalves <jm...@gm...> > Subject: Re: [Simple-support] ElementUnion and xs:any > To: "Simon Brodt" <sim...@if...> > Cc: sim...@li... > Received: Wednesday, 11 July, 2012, 3:23 AM > Hi Simon, > > Thanks for the reply! I guess I could code a Converter for > the > container class, that way it should work. Question: does a > registered > Converter take precedence over annotation-based > serialization? > > However, IMO, for a good XML-Java correspondence a fully > qualified > element name should map 1-to-1 to a Java class. But Simple > takes a > different (simpler! ;) ) approach. It gets the target class > explicitly > from method calls for reading and inspection for writing, > and I'd say > this design is great for performance. However flexible > lookup, maybe > with an additional setup step (i.e. "element {http://foo/bar/}x > should > be converted to class foo.bar.X"), would be extremely > convenient for > the case we're targeting. > > Cheers, > João > > On Wed, Jul 11, 2012 at 9:40 AM, Simon Brodt <sim...@if...> > wrote: > > Dear João, > > > > Would it be possible to use a ElementUnion, > > > > @ElementUnion({ > > @Element(name="circle", > type=Circle.class), > > @Element(name="square", > type=Square.class) > > @Element(name="generic", > type=GenericElement.class) > > }) > > > > together with an Visitor > > (http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#int > > ercept) that for the deserialization transforms > non-mapped xml-tags to > > generic xml-tag with an attribute indicating the > original name of the tag > > and transforms a generic xml-tag back to the original > tag for the > > serialization? > > > > True, an additional attribute for @ElementUnion where > you could specify that > > all unmapped tags should be interpreted as some type X > (i.e. > > GenericElement.class) would be more convenient. > > > > Best regards > > > > Simon > > > > -----Ursprüngliche Nachricht----- > > Von: João M. Gonçalves [mailto:jm...@gm...] > > Gesendet: Dienstag, 10. Juli 2012 20:39 > > An: sim...@li... > > Betreff: [Simple-support] ElementUnion and xs:any > > > > Hi Niall, all, > > I started using SimpleXML recently in an open source > project > > (https://github.com/societies/). We started out using > JAXB but due to > > a number of problems of JAXB on Android are attempting > a move to > > Simple. Today I came across two problems. The first one > is regarding > > using Simple in environments with multiple > ClassLoaders, such as an > > OSGi container. I didn't fully study the problem, will > do so in the > > next few days since it is not a show stopper for us. > I'll keep you > > posted. > > > > Regarding the second problem is the use of element > union. We were > > using JAXB because we wanted to be XML-centric (schema) > rather than > > Java-centric. Our data model for communication would be > designed in > > pure XML so that it could (theoretically) be used in > any language. > > Happens that we have "xs:any" in a few places. From > what I've gathered > > from Simple documentation, this would map to have an > Object field > > annotated with @ElementUnion. However, this places a > dependency in the > > containing types to the contained types: > > > > @ElementUnion({ > > @Element(name="circle", > type=Circle.class), > > @Element(name="square", > type=Square.class) > > }) > > > > This is not acceptable for us as we want to keep the > Java data model > > clean, consistent with the schema. If the dependency is > not in the > > schema it should not be in the Java version either. For > the same > > reason the explicit indication of the class as an > attribute (<any > > class="foo.bar.X">) is also not a good solution. One > good solution for > > us would be supporting the (de)serialization of a non > mapped class > > to/from a generic XML element, such as > org.w3c.dom.Element, as > > supported by JAXB. > > > > Any thoughts? I am available to contribute to Simple > regarding this > > issue if you want our help. > > Cheers, > > João > > > > > ---------------------------------------------------------------------------- > > -- > > 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 > > > > > > > > > ------------------------------------------------------------------------------ > > 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 > > ------------------------------------------------------------------------------ > 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: João M. G. <jm...@gm...> - 2012-07-11 10:23:30
|
Hi Simon,
Thanks for the reply! I guess I could code a Converter for the
container class, that way it should work. Question: does a registered
Converter take precedence over annotation-based serialization?
However, IMO, for a good XML-Java correspondence a fully qualified
element name should map 1-to-1 to a Java class. But Simple takes a
different (simpler! ;) ) approach. It gets the target class explicitly
from method calls for reading and inspection for writing, and I'd say
this design is great for performance. However flexible lookup, maybe
with an additional setup step (i.e. "element {http://foo/bar/}x should
be converted to class foo.bar.X"), would be extremely convenient for
the case we're targeting.
Cheers,
João
On Wed, Jul 11, 2012 at 9:40 AM, Simon Brodt <sim...@if...> wrote:
> Dear João,
>
> Would it be possible to use a ElementUnion,
>
> @ElementUnion({
> @Element(name="circle", type=Circle.class),
> @Element(name="square", type=Square.class)
> @Element(name="generic", type=GenericElement.class)
> })
>
> together with an Visitor
> (http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#int
> ercept) that for the deserialization transforms non-mapped xml-tags to
> generic xml-tag with an attribute indicating the original name of the tag
> and transforms a generic xml-tag back to the original tag for the
> serialization?
>
> True, an additional attribute for @ElementUnion where you could specify that
> all unmapped tags should be interpreted as some type X (i.e.
> GenericElement.class) would be more convenient.
>
> Best regards
>
> Simon
>
> -----Ursprüngliche Nachricht-----
> Von: João M. Gonçalves [mailto:jm...@gm...]
> Gesendet: Dienstag, 10. Juli 2012 20:39
> An: sim...@li...
> Betreff: [Simple-support] ElementUnion and xs:any
>
> Hi Niall, all,
> I started using SimpleXML recently in an open source project
> (https://github.com/societies/). We started out using JAXB but due to
> a number of problems of JAXB on Android are attempting a move to
> Simple. Today I came across two problems. The first one is regarding
> using Simple in environments with multiple ClassLoaders, such as an
> OSGi container. I didn't fully study the problem, will do so in the
> next few days since it is not a show stopper for us. I'll keep you
> posted.
>
> Regarding the second problem is the use of element union. We were
> using JAXB because we wanted to be XML-centric (schema) rather than
> Java-centric. Our data model for communication would be designed in
> pure XML so that it could (theoretically) be used in any language.
> Happens that we have "xs:any" in a few places. From what I've gathered
> from Simple documentation, this would map to have an Object field
> annotated with @ElementUnion. However, this places a dependency in the
> containing types to the contained types:
>
> @ElementUnion({
> @Element(name="circle", type=Circle.class),
> @Element(name="square", type=Square.class)
> })
>
> This is not acceptable for us as we want to keep the Java data model
> clean, consistent with the schema. If the dependency is not in the
> schema it should not be in the Java version either. For the same
> reason the explicit indication of the class as an attribute (<any
> class="foo.bar.X">) is also not a good solution. One good solution for
> us would be supporting the (de)serialization of a non mapped class
> to/from a generic XML element, such as org.w3c.dom.Element, as
> supported by JAXB.
>
> Any thoughts? I am available to contribute to Simple regarding this
> issue if you want our help.
> Cheers,
> João
>
> ----------------------------------------------------------------------------
> --
> 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
>
>
>
> ------------------------------------------------------------------------------
> 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: Simon B. <sim...@if...> - 2012-07-11 08:40:29
|
Dear João,
Would it be possible to use a ElementUnion,
@ElementUnion({
@Element(name="circle", type=Circle.class),
@Element(name="square", type=Square.class)
@Element(name="generic", type=GenericElement.class)
})
together with an Visitor
(http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#int
ercept) that for the deserialization transforms non-mapped xml-tags to
generic xml-tag with an attribute indicating the original name of the tag
and transforms a generic xml-tag back to the original tag for the
serialization?
True, an additional attribute for @ElementUnion where you could specify that
all unmapped tags should be interpreted as some type X (i.e.
GenericElement.class) would be more convenient.
Best regards
Simon
-----Ursprüngliche Nachricht-----
Von: João M. Gonçalves [mailto:jm...@gm...]
Gesendet: Dienstag, 10. Juli 2012 20:39
An: sim...@li...
Betreff: [Simple-support] ElementUnion and xs:any
Hi Niall, all,
I started using SimpleXML recently in an open source project
(https://github.com/societies/). We started out using JAXB but due to
a number of problems of JAXB on Android are attempting a move to
Simple. Today I came across two problems. The first one is regarding
using Simple in environments with multiple ClassLoaders, such as an
OSGi container. I didn't fully study the problem, will do so in the
next few days since it is not a show stopper for us. I'll keep you
posted.
Regarding the second problem is the use of element union. We were
using JAXB because we wanted to be XML-centric (schema) rather than
Java-centric. Our data model for communication would be designed in
pure XML so that it could (theoretically) be used in any language.
Happens that we have "xs:any" in a few places. From what I've gathered
from Simple documentation, this would map to have an Object field
annotated with @ElementUnion. However, this places a dependency in the
containing types to the contained types:
@ElementUnion({
@Element(name="circle", type=Circle.class),
@Element(name="square", type=Square.class)
})
This is not acceptable for us as we want to keep the Java data model
clean, consistent with the schema. If the dependency is not in the
schema it should not be in the Java version either. For the same
reason the explicit indication of the class as an attribute (<any
class="foo.bar.X">) is also not a good solution. One good solution for
us would be supporting the (de)serialization of a non mapped class
to/from a generic XML element, such as org.w3c.dom.Element, as
supported by JAXB.
Any thoughts? I am available to contribute to Simple regarding this
issue if you want our help.
Cheers,
João
----------------------------------------------------------------------------
--
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: João M. G. <jm...@gm...> - 2012-07-10 18:39:31
|
Hi Niall, all, I started using SimpleXML recently in an open source project (https://github.com/societies/). We started out using JAXB but due to a number of problems of JAXB on Android are attempting a move to Simple. Today I came across two problems. The first one is regarding using Simple in environments with multiple ClassLoaders, such as an OSGi container. I didn't fully study the problem, will do so in the next few days since it is not a show stopper for us. I'll keep you posted. Regarding the second problem is the use of element union. We were using JAXB because we wanted to be XML-centric (schema) rather than Java-centric. Our data model for communication would be designed in pure XML so that it could (theoretically) be used in any language. Happens that we have "xs:any" in a few places. From what I've gathered from Simple documentation, this would map to have an Object field annotated with @ElementUnion. However, this places a dependency in the containing types to the contained types: @ElementUnion({ @Element(name="circle", type=Circle.class), @Element(name="square", type=Square.class) }) This is not acceptable for us as we want to keep the Java data model clean, consistent with the schema. If the dependency is not in the schema it should not be in the Java version either. For the same reason the explicit indication of the class as an attribute (<any class="foo.bar.X">) is also not a good solution. One good solution for us would be supporting the (de)serialization of a non mapped class to/from a generic XML element, such as org.w3c.dom.Element, as supported by JAXB. Any thoughts? I am available to contribute to Simple regarding this issue if you want our help. Cheers, João |
|
From: Niall G. <gal...@ya...> - 2012-07-08 23:30:53
|
If this is for validation you can always use the @Validate annotation.
--- On Sun, 8/7/12, -=}\*/{=- <rui...@gm...> wrote:
From: -=}\*/{=- <rui...@gm...>
Subject: [Simple-support] suggestion for re pattern checkers ...
To: sim...@li...
Received: Sunday, 8 July, 2012, 6:13 AM
hi,
it would be nice to be able configure RE pattern checkers for strings and primitives...
// primitive@Attribute (pattern="\d{2}")int max99;
// string@Attribute (pattern="\d{1,3}-\d{1,3}")String range;
@Element (pattern="[a-zA-Z]{4,20}")
String firstName;
@Attribute (pattern="\p{Lower}{14}")String username;
// object
@Element (pattern="[a-zA-Z]{4,20} [a-zA-Z]{4,20}")FullName fn;
@Rootclass FullName {
String firstName, String lastName;
// ... @FromString public void parse(String s) {...}
@ToString // you may want to use the real toString for other stuff public String toString() {return firstName + " " + lastName;}
}
//// the code bellow would be nicer though... no need to write parse code or repeat patterns :)//// object @Element (pattern="([a-zA-Z]{4,20}) ([a-zA-Z]{4,20})")
FullName fn;
// object @Element (pattern="([a-zA-Z]{4,20}) ([a-zA-Z]{4,20})")FullName fn;
@Root (asPrimitive = true)
class FullName {
@Pattern (group = 0) String firstName, @Pattern (group = 1) String lastName; // ... @ToString public String toString() {return firstName + " " + lastName;}
}
... implied when reading and optional when writing...
think about it :)
[NiceSunDay]r.
-----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: -=}\\*/{=- <rui...@gm...> - 2012-07-08 13:13:36
|
hi,
it would be nice to be able configure RE pattern checkers for strings and
primitives...
// primitive
@Attribute (pattern="\d{2}")
int max99;
// string
@Attribute (pattern="\d{1,3}-\d{1,3}")
String range;
@Element (pattern="[a-zA-Z]{4,20}")
String firstName;
@Attribute (pattern="\p{Lower}{14}")
String username;
// object
@Element (pattern="[a-zA-Z]{4,20} [a-zA-Z]{4,20}")
FullName fn;
@Root
class FullName {
String firstName,
String lastName;
// ...
@FromString
public void parse(String s) {...}
@ToString // you may want to use the real toString for other stuff
public String toString() {return firstName + " " + lastName;}
}
//
// the code bellow would be nicer though... no need to write parse code or
repeat patterns :)
//
// object
@Element (pattern="([a-zA-Z]{4,20}) ([a-zA-Z]{4,20})")
FullName fn;
// object
@Element (pattern="([a-zA-Z]{4,20}) ([a-zA-Z]{4,20})")
FullName fn;
@Root (asPrimitive = true)
class FullName {
@Pattern (group = 0)
String firstName,
@Pattern (group = 1)
String lastName;
// ...
@ToString
public String toString() {return firstName + " " + lastName;}
}
... implied when reading and optional when writing...
think about it :)
[NiceSunDay]r.
|
|
From: Niall G. <gal...@ya...> - 2012-07-07 09:23:26
|
I am not sure, if Blackberry can support Java 1.5 then its possible, otherwise not. --- On Thu, 5/7/12, Mahesh Kulkarni <mah...@pa...> wrote: From: Mahesh Kulkarni <mah...@pa...> Subject: [Simple-support] Simple in Blackberry To: sim...@li... Received: Thursday, 5 July, 2012, 5:53 AM Hello, I just want to know that can we user simple 2.6.4 in blackberry os. I know blackberry supports j2me platform so on that basis how this can be done ?any help would be greatly appreciated thanks & regards -----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-07-07 09:22:43
|
You would need to write a converter for this. Transforms are for transformations that do not contain any XML. --- On Tue, 3/7/12, Ramiro del Corro <ram...@gm...> wrote: From: Ramiro del Corro <ram...@gm...> Subject: [Simple-support] Nested array list To: sim...@li... Received: Tuesday, 3 July, 2012, 3:25 PM Hi folks I will need to serialize a nested arrayList like so: @ElementListprotected ArrayList<ArrayList<MyClass>> and I am getting TransformException: Transform of class java.util.ArrayList not supported Is there a way to implement this without having to wrap the ArrayList<MyClass> inside a class?My second approach was to try to use a Converter but as I need names for the attributes, I can not figure out how to do it. Thanks in advanceRamiro -----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: Mahesh K. <mah...@pa...> - 2012-07-05 13:47:19
|
Hello, I just want to know that can we user simple 2.6.4 in blackberry os. I know blackberry supports j2me platform so on that basis how this can be done ? any help would be greatly appreciated thanks & regards |
|
From: Ramiro d. C. <ram...@gm...> - 2012-07-03 22:26:09
|
Hi folks I will need to serialize a nested arrayList like so: @ElementList protected ArrayList<ArrayList<MyClass>> and I am getting TransformException: Transform of class java.util.ArrayList not supported Is there a way to implement this without having to wrap the ArrayList<MyClass> inside a class? My second approach was to try to use a Converter but as I need names for the attributes, I can not figure out how to do it. Thanks in advance Ramiro |
|
From: Mishra, D. <c_d...@qu...> - 2012-07-03 08:19:32
|
Can someone please help me inject a custom Transform() object to the Persister() ? This doesn't work :
Persister serializer = new Persister(new Matcher() {
public Transform match(Class type) throws Exception {
if (type.isEnum()) {
return new CustomEnumTransform(type);
}
return null;
}
});
ERROR : Type mismatch: cannot convert from CustomEnumTransform to Transform
Although my CustomEnumTransform adheres to the interface :
public class CustomEnumTransform implements Transform<Enum>
Thanks !
________________________________
From: Mishra, Deepak [c_d...@qu...]
Sent: 02 July 2012 14:32:35
To: Niall Gallagher; sim...@li...
Subject: Re: [Simple-support] Parsing an XML containing Java keyword
Thanks for the reply Niall ! Let me rephrase my query...
I need to parse an XML like this :
<myEnum>new</myEnum>
My Java bean is this :
public enum MyEnum {
@Element(name="new")
NEW("new"),
OLD("old");
private final String value;
MyEnum(String v)
{
value = v;
}
}
My Java code for parsing is this :
public static void main(String[] args) throws Exception {
Serializer serializer = new Persister();
File source = new File("myenum.xml");
MyEnum example=null;
try{
example = serializer.read(MyEnum.class, source);
}
catch(IllegalArgumentException e)
{
e.printStackTrace();
}
}
The exception I get is this :
java.lang.IllegalArgumentException: No enum const class MyEnum.new
at java.lang.Enum.valueOf(Unknown Source)
at org.simpleframework.xml.transform.EnumTransform.read(EnumTransform.java:58)
at org.simpleframework.xml.transform.EnumTransform.read(EnumTransform.java:29)
at org.simpleframework.xml.transform.Transformer.read(Transformer.java:104)
How should I go around this ? Can you please provide some more pointers than those mentioned in your last reply.
Thanks !
________________________________
From: Niall Gallagher [gal...@ya...]
Sent: 02 July 2012 13:58:27
To: sim...@li...; Mishra, Deepak
Subject: Re: [Simple-support] Parsing an XML containing Java keyword
I am not sure what your trying to do here, but what you should do is implement your own EnumTransform and plug it in to the Persister using a Matcher.
--- On Fri, 29/6/12, Mishra, Deepak <c_d...@qu...> wrote:
From: Mishra, Deepak <c_d...@qu...>
Subject: [Simple-support] Parsing an XML containing Java keyword
To: "sim...@li..." <sim...@li...>
Received: Friday, 29 June, 2012, 3:49 AM
Hi,
We are working on an Android project which consumes some web-services not in our control. These web-services respond with an XML, with text value as "new". Example :
<myEnum>new</myEnum>
As per the XSD, we need a Java enum to code for this.
public enum MyEnum {
@Element(name="new")
new("new"), // but we can't use 'new' here as it's a Java keyword
old("old");
}
SimpleXml seems to use valueOf() - which we can't overrride and hence we are unable to proceed. Please suggest some alternatives. I got this working after changing SimpleXml source code, but this is not acceptable to my team !
PS : The exception if it helps (when I use NEW instead of new)
java.lang.IllegalArgumentException: No enum const class pojos2.MyEnum.new
at java.lang.Enum.valueOf(Unknown Source)
at org.simpleframework.xml.transform.EnumTransform.read(EnumTransform.java:58)
Thanks,
Deepak
-----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...<UrlBlockedError.aspx>
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Mishra, D. <c_d...@qu...> - 2012-07-02 09:02:49
|
Thanks for the reply Niall ! Let me rephrase my query...
I need to parse an XML like this :
<myEnum>new</myEnum>
My Java bean is this :
public enum MyEnum {
@Element(name="new")
NEW("new"),
OLD("old");
private final String value;
MyEnum(String v)
{
value = v;
}
}
My Java code for parsing is this :
public static void main(String[] args) throws Exception {
Serializer serializer = new Persister();
File source = new File("myenum.xml");
MyEnum example=null;
try{
example = serializer.read(MyEnum.class, source);
}
catch(IllegalArgumentException e)
{
e.printStackTrace();
}
}
The exception I get is this :
java.lang.IllegalArgumentException: No enum const class MyEnum.new
at java.lang.Enum.valueOf(Unknown Source)
at org.simpleframework.xml.transform.EnumTransform.read(EnumTransform.java:58)
at org.simpleframework.xml.transform.EnumTransform.read(EnumTransform.java:29)
at org.simpleframework.xml.transform.Transformer.read(Transformer.java:104)
How should I go around this ? Can you please provide some more pointers than those mentioned in your last reply.
Thanks !
________________________________
From: Niall Gallagher [gal...@ya...]
Sent: 02 July 2012 13:58:27
To: sim...@li...; Mishra, Deepak
Subject: Re: [Simple-support] Parsing an XML containing Java keyword
I am not sure what your trying to do here, but what you should do is implement your own EnumTransform and plug it in to the Persister using a Matcher.
--- On Fri, 29/6/12, Mishra, Deepak <c_d...@qu...> wrote:
From: Mishra, Deepak <c_d...@qu...>
Subject: [Simple-support] Parsing an XML containing Java keyword
To: "sim...@li..." <sim...@li...>
Received: Friday, 29 June, 2012, 3:49 AM
Hi,
We are working on an Android project which consumes some web-services not in our control. These web-services respond with an XML, with text value as "new". Example :
<myEnum>new</myEnum>
As per the XSD, we need a Java enum to code for this.
public enum MyEnum {
@Element(name="new")
new("new"), // but we can't use 'new' here as it's a Java keyword
old("old");
}
SimpleXml seems to use valueOf() - which we can't overrride and hence we are unable to proceed. Please suggest some alternatives. I got this working after changing SimpleXml source code, but this is not acceptable to my team !
PS : The exception if it helps (when I use NEW instead of new)
java.lang.IllegalArgumentException: No enum const class pojos2.MyEnum.new
at java.lang.Enum.valueOf(Unknown Source)
at org.simpleframework.xml.transform.EnumTransform.read(EnumTransform.java:58)
Thanks,
Deepak
-----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...<UrlBlockedError.aspx>
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Niall G. <gal...@ya...> - 2012-07-02 08:30:42
|
Maybe its me that is being unclear here, you never need anything other than the name= attribute for a constructor parameter. If you do then you have found a bug.
class X{@Element(required=false)String xX(@Element(name="x") String x){ this.x = x;}
}
The above will work without any issues.
Niall
--- On Fri, 29/6/12, Andrew Spinner <and...@ti...> wrote:
From: Andrew Spinner <and...@ti...>
Subject: [Simple-support] Fwd: Constructor injection problems
To:
Cc: sim...@li...
Received: Friday, 29 June, 2012, 2:47 PM
Hi Niall,
I think there may be a misunderstanding. I don't have to include required=true - that's working fine. I just have to include required=false on some elements, which I believe is the correct behaviour; it's just a little unclear in the documentation.
All seems to be working now.
Thanks,
Andrew
On Fri, Jun 29, 2012 at 9:20 AM, Niall Gallagher <gal...@ya...> wrote:
I have many tests that are working without the need for required=true, have you got some classpath issue? If you are convinced its a problem can you send me on the code u use in a test case, id like to see this, you may have found a bug.
--- On Thu, 28/6/12, Andrew Spinner <and...@ti...> wrote:
From: Andrew Spinner <and...@ti...>
Subject: Re: [Simple-support] Constructor injection problems
To: sim...@li...
Received: Thursday, 28 June, 2012, 9:15 AM
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...> 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
-----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-07-02 08:28:39
|
I am not sure what your trying to do here, but what you should do is implement your own EnumTransform and plug it in to the Persister using a Matcher.
--- On Fri, 29/6/12, Mishra, Deepak <c_d...@qu...> wrote:
From: Mishra, Deepak <c_d...@qu...>
Subject: [Simple-support] Parsing an XML containing Java keyword
To: "sim...@li..." <sim...@li...>
Received: Friday, 29 June, 2012, 3:49 AM
#yiv897925473 P {margin-top:0;margin-bottom:0;}
Hi,
We are working on an Android project which consumes some web-services not in our control. These web-services respond with an XML, with text value as "new". Example :
<myEnum>new</myEnum>
As per the XSD, we need a Java enum to code for this.
public enum MyEnum {
@Element(name="new")
new("new"), // but we can't use 'new' here as it's a Java keyword
old("old");
}
SimpleXml seems to use valueOf() - which we can't overrride and hence we are unable to proceed. Please suggest some alternatives. I got this working after changing SimpleXml source code, but this is not acceptable to my team !
PS : The exception if it helps (when I use NEW instead of new)
java.lang.IllegalArgumentException: No enum const class pojos2.MyEnum.new
at java.lang.Enum.valueOf(Unknown Source)
at org.simpleframework.xml.transform.EnumTransform.read(EnumTransform.java:58)
Thanks,
Deepak
-----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-29 21:47:52
|
Hi Niall,
I think there may be a misunderstanding. I don't have to include
required=true - that's working fine. I just have to include required=false
on some elements, which I believe is the correct behaviour; it's just a
little unclear in the documentation.
All seems to be working now.
Thanks,
Andrew
On Fri, Jun 29, 2012 at 9:20 AM, Niall Gallagher
<gal...@ya...>wrote:
> I have many tests that are working without the need for required=true,
> have you got some classpath issue? If you are convinced its a problem can
> you send me on the code u use in a test case, id like to see this, you may
> have found a bug.
>
>
> --- On *Thu, 28/6/12, Andrew Spinner <and...@ti...>* wrote:
>
>
> From: Andrew Spinner <and...@ti...>
> Subject: Re: [Simple-support] Constructor injection problems
> To: sim...@li...
> Received: Thursday, 28 June, 2012, 9:15 AM
>
>
> 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... <http://mc/compose?to=...@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...<http://mc/compose?to=...@ti...>
> >* wrote:
>
>
> From: Andrew Spinner <and...@ti...<http://mc/compose?to=...@ti...>
> >
> Subject: Re: [Simple-support] Constructor injection problems
> To:
> Cc: sim...@li...<http://mc/compose?to=...@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
>
>
>
> -----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: Mishra, D. <c_d...@qu...> - 2012-06-29 11:24:43
|
Hi,
We are working on an Android project which consumes some web-services not in our control. These web-services respond with an XML, with text value as "new". Example :
<myEnum>new</myEnum>
As per the XSD, we need a Java enum to code for this.
public enum MyEnum {
@Element(name="new")
new("new"), // but we can't use 'new' here as it's a Java keyword
old("old");
}
SimpleXml seems to use valueOf() - which we can't overrride and hence we are unable to proceed. Please suggest some alternatives. I got this working after changing SimpleXml source code, but this is not acceptable to my team !
PS : The exception if it helps (when I use NEW instead of new)
java.lang.IllegalArgumentException: No enum const class pojos2.MyEnum.new
at java.lang.Enum.valueOf(Unknown Source)
at org.simpleframework.xml.transform.EnumTransform.read(EnumTransform.java:58)
Thanks,
Deepak
|
|
From: Niall G. <gal...@ya...> - 2012-06-29 08:20:34
|
I have many tests that are working without the need for required=true, have you got some classpath issue? If you are convinced its a problem can you send me on the code u use in a test case, id like to see this, you may have found a bug.
--- On Thu, 28/6/12, Andrew Spinner <and...@ti...> wrote:
From: Andrew Spinner <and...@ti...>
Subject: Re: [Simple-support] Constructor injection problems
To: sim...@li...
Received: Thursday, 28 June, 2012, 9:15 AM
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...> 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
-----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
|