simple-support Mailing List for Simple (Page 38)
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: Cristian <cri...@el...> - 2011-01-20 15:59:34
|
It's licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0 2011/1/20 jesus jimenez <jes...@ho...> > hello all, I was looking in the web and I would like to know, if > SimpleFrameWork is License GPL??? > tanks!! > nice work! > > > attentively jesus jimenz > > > ------------------------------------------------------------------------------ > Protect Your Site and Customers from Malware Attacks > Learn about various malware tactics and how to avoid them. Understand > malware threats, the impact they can have on your business, and how you > can protect your company and customers by using code signing. > http://p.sf.net/sfu/oracle-sfdevnl > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > > |
|
From: jesus j. <jes...@ho...> - 2011-01-20 15:52:01
|
hello all, I was looking in the web and I would like to know, if SimpleFrameWork is License GPL??? tanks!! nice work! attentively jesus jimenz |
|
From: H. B. <he...@zx...> - 2011-01-20 11:14:17
|
Niall, thanks for the prompt reply. I've been playing with it a bit,
and I found out in this particular example I can skip the Section part
altogether, as it is a List that is a member of SearchSuggestion.
Right now I have the following classes:
@Root(name="SearchSuggestion")
private static class Result {
@Element
String Query;
@ElementList
private ArrayList<Item> Section;
public List<Item> getSection(){
return Section;
}
}
@Root(strict=false)
private static class Item {
@Element(name="Text")
String text;
@Element(name="Description")
String description;
@Element(name="Url")
String url;
}
And am getting the payload with:
Result result = serializer.read(Result.class, input, false);
...and getting the Items with List<Item> list = result.getSection();
So I still have 2 classes instead of one, is this the absolute
minimum? I noticed I can't do List<Item> list =
serializer.read(Item.class, input, false) (possibly with a different
input source, e.g. a node) and have the serializer return the list in
one go. Is there any way, for instance, that I can grab a Node
(org.w3c.*) through (java.xml.xpath) Xpath and feed it into the
Persister as an InputNode? That way I can first select the nearest
element to Item and work with that (while typing this I'm realizing I
might be able to let XPath compile a list of nodes that contain just
<Item></Item> and work with that...).
Another question that is somewhat related, an Item in this case has an
<Image source="..."> element, I figured I could get it by adding a
@Path("Image/@source") to a String in the Item class, but this
consistently gets me a null. I was however able to get the attribute
by defining an Image class with an @Attribute String source. This is
basically the same question as before, apart from the class being on
the other side of the hierarchy, but is there any way I can reach the
attribute from inside Item without having to define an Image class?
|
|
From: Niall G. <gal...@ya...> - 2011-01-19 21:38:31
|
See Persister.read(class, source, false)
--- On Wed, 19/1/11, Cristian <cri...@el...> wrote:
From: Cristian <cri...@el...>
Subject: [Simple-support] How to ignore unused XML elements while deserializing a document?
To: sim...@li...
Received: Wednesday, 19 January, 2011, 1:25 PM
I'm using SimpleXml to (de)serialize POJOs. Now, I
have a big XML which has some elements which are not needed. For
instance, with this XML:
<Root>
<Element>Used</Element>
<Another>Not used</Another>
<Root>
I want to create a POJO which looks like:
@Root
class Root{
@Element
private String element;
}
Problem is that I'm getting this Exception:
simpleframework.xml.core.ElementException: Element 'Another' does not have a
match in class blah.blah.Blah at line 1
So... how should I configure the POJO so that I can parse the XML correctly?
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Niall G. <gal...@ya...> - 2011-01-19 21:37:51
|
Yes, see Persister.read(class, source, false) --- On Wed, 19/1/11, H. Brunsting <he...@zx...> wrote: > From: H. Brunsting <he...@zx...> > Subject: [Simple-support] Deserializing specific (lists of) children without having to map an entire XML tree? > To: sim...@li... > Received: Wednesday, 19 January, 2011, 5:51 AM > I hope I can explain this in an > understandable manner... > I've been reading the docs for a while, but one thing keeps > me > puzzled: is it possible to deserialize a list of things in > an xml > without deserializing the entire structure? > > An example is http://en.wikipedia.org/w/api.php?action=opensearch&search=john&format=xml&limit=10 > : > I only care about the Item objects, and I'd like a > List<Item>, is > there any way I can get that without having to make class > templates > for SearchSuggestion and Section or do I always have to > wrap the > entire hierarchy? > > Thanks. > > ------------------------------------------------------------------------------ > Protect Your Site and Customers from Malware Attacks > Learn about various malware tactics and how to avoid them. > Understand > malware threats, the impact they can have on your business, > and how you > can protect your company and customers by using code > signing. > http://p.sf.net/sfu/oracle-sfdevnl > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > |
|
From: Cristian <cri...@el...> - 2011-01-19 21:25:54
|
I'm using SimpleXml to (de)serialize POJOs. Now, I have a big XML which has
some elements which are not needed. For instance, with this XML:
<Root>
<Element>Used</Element>
<Another>Not used</Another>
<Root>
I want to create a POJO which looks like:
@Root
class Root{
@Element
private String element;
}
Problem is that I'm getting this Exception:
simpleframework.xml.core.ElementException: Element 'Another' does not have a
match in class blah.blah.Blah at line 1
So... how should I configure the POJO so that I can parse the XML correctly?
|
|
From: H. B. <he...@zx...> - 2011-01-19 13:51:31
|
I hope I can explain this in an understandable manner... I've been reading the docs for a while, but one thing keeps me puzzled: is it possible to deserialize a list of things in an xml without deserializing the entire structure? An example is http://en.wikipedia.org/w/api.php?action=opensearch&search=john&format=xml&limit=10 : I only care about the Item objects, and I'd like a List<Item>, is there any way I can get that without having to make class templates for SearchSuggestion and Section or do I always have to wrap the entire hierarchy? Thanks. |
|
From: Niall G. <gal...@ya...> - 2011-01-19 10:45:42
|
Hi, Ill take a look at this, it should be possible to use namespaces with the @Path annotation. Niall --- On Tue, 18/1/11, Cristian <cri...@el...> wrote: From: Cristian <cri...@el...> Subject: Re: [Simple-support] How to create inner children without creating inner class? To: "Niall Gallagher" <gal...@ya...> Cc: sim...@li... Received: Tuesday, 18 January, 2011, 1:51 PM I wanted to do something like: <Root> <namespace:Children> <InnerChildren>SomethingM</InnerChildren> </namespace:Children> </Root> I asked on SO and got this answer: http://stackoverflow.com/questions/4715148/how-to-create-inner-children-without-creating-another-class So... in order to emulate a namespace using paths, I will have to do something like @Path("namespace:Children"). If I use the CameStyle class to format the XML, what I get is <NamespaceChildren> which is obviously wrong. Anyway, I'd be nice if the Path extension supported namespaces. Thanks. 2011/1/18 Niall Gallagher <gal...@ya...> Hi, Can you send me an example of the XML you want to generate? Niall --- On Mon, 17/1/11, Cristian <cri...@el...> wrote: From: Cristian <cri...@el...> Subject: Re: [Simple-support] How to create inner children without creating inner class? To: sim...@li... Received: Monday, 17 January, 2011, 10:07 AM All right... I see that I can accomplish that by using Paths. This way: @org.simpleframework.xml.Root class Root { @Element @Path("children") private final String innerChildren; public Root(String name){ innerChildren = name; } } The problem is that now I want to give a namespace to the path... but I have found no way to do so. If I do @Path("myns:children") I get <mynschildren> instead of <myns:children>. Thanks for you help. 2011/1/17 Cristian <cri...@el...> I need to generate an XML like this: <Root> <Children> <InnerChildren>SomethingM</InnerChildren> </Children> </Root> The simplest solution is creating an inner class on the Root class: @Root class Root{ @Element Children element; @Root private static class Children{ @Element String innerChildren; } } But I want to avoid that inner class creation, since it will make things look strange while using Root objects. Is there anyway I can achieve that result without using inner classes? -----Inline Attachment Follows----- ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl -----Inline Attachment Follows----- _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Niall G. <gal...@ya...> - 2011-01-19 10:41:17
|
Hi, Currently it is not possible to use annotations to acquire free text like this. The @Text annotation can be used to grab text between elements. But this is only possible when there are no child elements. If you use a Visitor you can grab the text with OutputNode.getValue. Niall --- On Tue, 18/1/11, Casey Rodgers <cas...@gm...> wrote: From: Casey Rodgers <cas...@gm...> Subject: [Simple-support] Possible to to parse Text with child Element? To: sim...@li... Received: Tuesday, 18 January, 2011, 9:38 AM Hello, Is it possible to to parse XML containing text AND child elements? For example, is the following serializable? <element> THIS IS SOME TEXT <child-element> ..etc.. </child-element></element> Is it possible to parse this XML using SimpleXml? -- Casey Rodgers -----Inline Attachment Follows----- ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl -----Inline Attachment Follows----- _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Cristian <cri...@el...> - 2011-01-18 21:54:03
|
I wanted to do something like:
<Root>
<namespace:Children>
<InnerChildren>SomethingM</InnerChildren>
</namespace:Children>
</Root>
I asked on SO and got this answer:
http://stackoverflow.com/questions/4715148/how-to-create-inner-children-without-creating-another-class
So... in order to emulate a namespace using paths, I will have to do
something like @Path("namespace:Children"). If I use the CameStyle class to
format the XML, what I get is <NamespaceChildren> which is obviously wrong.
Anyway, I'd be nice if the Path extension supported namespaces.
Thanks.
2011/1/18 Niall Gallagher <gal...@ya...>
> Hi,
>
> Can you send me an example of the XML you want to generate?
>
> Niall
>
> --- On *Mon, 17/1/11, Cristian <cri...@el...>* wrote:
>
>
> From: Cristian <cri...@el...>
> Subject: Re: [Simple-support] How to create inner children without creating
> inner class?
> To: sim...@li...
> Received: Monday, 17 January, 2011, 10:07 AM
>
>
> All right... I see that I can accomplish that by using Paths. This way:
>
> @org.simpleframework.xml.Root
>
>
> class Root {
>
>
> @Element
>
>
> @Path("children")
> private final String innerChildren;
>
>
>
>
> public Root(String name){
>
>
> innerChildren = name;
>
>
> }
> }
>
>
>
> The problem is that now I want to give a namespace to the path... but I
> have found no way to do so. If I do @Path("myns:children") I get
> <mynschildren> instead of <myns:children>.
>
> Thanks for you help.
>
> 2011/1/17 Cristian <cri...@el...<http://mc/compose?to=...@el...>
> >
>
> I need to generate an XML like this:
>
> <Root>
> <Children>
> <InnerChildren>SomethingM</InnerChildren>
>
> </Children>
>
> </Root>
>
> The simplest solution is creating an inner class on the Root class:
>
> @Root
> class Root{
>
> @Element
> Children element;
>
>
> @Root
>
> private static class Children{
>
> @Element
>
>
> String innerChildren;
> }
>
> }
>
> But I want to avoid that inner class creation, since it will make things
> look strange while using Root objects. Is there anyway I can achieve that
> result without using inner classes?
>
>
>
> -----Inline Attachment Follows-----
>
>
> ------------------------------------------------------------------------------
> Protect Your Site and Customers from Malware Attacks
> Learn about various malware tactics and how to avoid them. Understand
> malware threats, the impact they can have on your business, and how you
> can protect your company and customers by using code signing.
> http://p.sf.net/sfu/oracle-sfdevnl
>
> -----Inline Attachment Follows-----
>
> _______________________________________________
> Simple-support mailing list
> Sim...@li...<http://mc/compose?to=...@li...>
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
>
>
|
|
From: Casey R. <cas...@gm...> - 2011-01-18 17:38:59
|
Hello,
Is it possible to to parse XML containing text AND child elements?
For example, is the following serializable?
<element>
THIS IS SOME TEXT
<child-element>
..etc..
</child-element>
</element>
Is it possible to parse this XML using SimpleXml?
-- Casey Rodgers
|
|
From: Niall G. <gal...@ya...> - 2011-01-18 07:53:38
|
Hi,
Can you send me an example of the XML you want to generate?
Niall
--- On Mon, 17/1/11, Cristian <cri...@el...> wrote:
From: Cristian <cri...@el...>
Subject: Re: [Simple-support] How to create inner children without creating inner class?
To: sim...@li...
Received: Monday, 17 January, 2011, 10:07 AM
All right... I see that I can accomplish that by using Paths. This way:
@org.simpleframework.xml.Root
class Root {
@Element
@Path("children")
private final String innerChildren;
public Root(String name){
innerChildren = name;
}
}
The problem is that now I want to give a namespace to the path... but I have found no way to do so. If I do @Path("myns:children") I get <mynschildren> instead of <myns:children>.
Thanks for you help.
2011/1/17 Cristian <cri...@el...>
I need to generate an XML like this:
<Root>
<Children>
<InnerChildren>SomethingM</InnerChildren>
</Children>
</Root>
The simplest solution is creating an inner class on the Root class:
@Root
class Root{
@Element
Children element;
@Root
private static class Children{
@Element
String innerChildren;
}
}
But I want to avoid that inner class creation, since it will make things look strange while using Root objects. Is there anyway I can achieve that result without using inner classes?
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Cristian <cri...@el...> - 2011-01-17 18:07:41
|
All right... I see that I can accomplish that by using Paths. This way:
@org.simpleframework.xml.Root
class Root {
@Element
@Path("children")
private final String innerChildren;
public Root(String name){
innerChildren = name;
}
}
The problem is that now I want to give a namespace to the path... but I have
found no way to do so. If I do @Path("myns:children") I get <mynschildren>
instead of <myns:children>.
Thanks for you help.
2011/1/17 Cristian <cri...@el...>
> I need to generate an XML like this:
>
> <Root>
> <Children>
> <InnerChildren>SomethingM</InnerChildren>
>
> </Children>
> </Root>
>
> The simplest solution is creating an inner class on the Root class:
>
> @Root
> class Root{
>
> @Element
> Children element;
>
> @Root
>
> private static class Children{
>
> @Element
> String innerChildren;
> }
> }
>
> But I want to avoid that inner class creation, since it will make things
> look strange while using Root objects. Is there anyway I can achieve that
> result without using inner classes?
>
|
|
From: Cristian <cri...@el...> - 2011-01-17 16:40:29
|
I need to generate an XML like this:
<Root>
<Children>
<InnerChildren>SomethingM</InnerChildren>
</Children>
</Root>
The simplest solution is creating an inner class on the Root class:
@Root
class Root{
@Element
Children element;
@Root
private static class Children{
@Element
String innerChildren;
}
}
But I want to avoid that inner class creation, since it will make things
look strange while using Root objects. Is there anyway I can achieve that
result without using inner classes?
|
|
From: Niall G. <gal...@ya...> - 2011-01-14 07:58:21
|
Hi, I think you just have to use the name="xxx" attributes on all the annotations. If you do not then the field names will not match the element and attribute names. I can't see any reason it will not work when the names are explicitly specified. Niall --- On Thu, 13/1/11, John Sonmez <joh...@gm...> wrote: From: John Sonmez <joh...@gm...> Subject: [Simple-support] Proguard on Android woes To: sim...@li... Received: Thursday, 13 January, 2011, 12:29 PM Anyone know how to get simple working with Proguard on Android?I been banging my head against the wall running into so many problems trying to serialize a set of files.I have everything working find when I don't use Proguard, but as soon as I turn it all everything breaks. Any tips on what things I need to put in the Proguard config so that Simple can have all the classes and names it needs? Thanks, John Sonmez http://simpleprogrammer.com http://elegantcode.com -----Inline Attachment Follows----- ------------------------------------------------------------------------------ Protect Your Site and Customers from Malware Attacks Learn about various malware tactics and how to avoid them. Understand malware threats, the impact they can have on your business, and how you can protect your company and customers by using code signing. http://p.sf.net/sfu/oracle-sfdevnl -----Inline Attachment Follows----- _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: John S. <joh...@gm...> - 2011-01-13 20:30:16
|
Anyone know how to get simple working with Proguard on Android? I been banging my head against the wall running into so many problems trying to serialize a set of files. I have everything working find when I don't use Proguard, but as soon as I turn it all everything breaks. Any tips on what things I need to put in the Proguard config so that Simple can have all the classes and names it needs? Thanks, John Sonmez http://simpleprogrammer.com http://elegantcode.com |
|
From: Niall G. <gal...@ya...> - 2011-01-13 10:46:12
|
Hi, I have written a demonstration here. https://simple.svn.sourceforge.net/svnroot/simple/trunk/download/stream/src/test/java/org/simpleframework/xml/convert/HideEnclosingConverterTest.java It shows how to do it. Niall --- On Wed, 12/1/11, Pete Calvert <pr...@ca...> wrote: > From: Pete Calvert <pr...@ca...> > Subject: Re: [Simple-support] Asymmetry in Persister behaviour > To: "Niall Gallagher" <gal...@ya...>, sim...@li... > Received: Wednesday, 12 January, 2011, 2:23 AM > Hi, > > Yep ok. I should have thought of that, thank you. And > there's no way to make them consistent without the child > node? As is, "@Element Key<Foo> foo" is going to end > up looking like: > > <foo><foo>...</foo></foo> > > If the only way is by making some changes, then I'm happy > to make them if you think this is worthwhile. I don't really > know my way around the code, but I think the following would > do it: > > - Stop Traverser.write(OutputNode, Object, Class) from > adding the child node itself (i.e. rather than working out a > name for a child, don't add a child). > - Add an argument "boolean createChild" to > Persister.write(Object, OutputNode, ...) methods. Then in > Persister.write(Object, OutputNode, Context, boolean) add > the child as before if it is set. > - Add a new method Persister.write(Object, OutputNode) that > defaults createChild to true to make this backwards > compatible (although I would argue that the default should > actually be false and that write(Object, Writer) should set > it to true). > > The potential problem is that I don't know whether > Traverser.write(OutputNode, Object, Class) is used > elsewhere, or just Traverser.write(OutputNode, Object, > Class, String). > > Thanks > Pete > > Niall Gallagher wrote: > > Hi, > > > > Take a look at the following, it works fine. > > > > https://simple.svn.sourceforge.net/svnroot/simple/trunk/download/stream/src/test/java/org/simpleframework/xml/convert/WrapperTest.java > > > > Niall > > > > --- On Tue, 11/1/11, Pete Calvert <pr...@ca...> > wrote: > > > >> From: Pete Calvert <pr...@ca...> > >> Subject: [Simple-support] Asymmetry in Persister > behaviour > >> To: sim...@li... > >> Received: Tuesday, 11 January, 2011, 4:25 PM > >> Hi, > >> > >> I've noticed that the behaviour of write(Object, > >> OutputNode) and read(Class, InputNode) is not > entirely consistent. read > >> loads directly from the node whereas write first > creates a new child > >> (using the name of the object's class) and then > writes to this. > >> > >> Is there a way of working around this? i.e. write > writing > >> directly to the node given? > >> > >> The reason I need this is that I'm trying to > import/export > >> Objectify entities. References to other entities > are stored as > >> "Key<T>", so I've got a Converter for "Key" > that 'skips' over the reference > >> to export the entity in its place. I've included > some code at the end of > >> the email that exhibits the behaviour I'm talking > about. > >> > >> Thanks > >> Pete > >> > >> --- > >> > >> import org.simpleframework.xml.*; > >> import org.simpleframework.xml.strategy.*; > >> import org.simpleframework.xml.convert.*; > >> import org.simpleframework.xml.core.*; > >> import org.simpleframework.xml.stream.*; > >> import java.io.*; > >> > >> public class Test { > >> @Root > >> public static class Example { > >> @Element Foo x; > >> } > >> > >> public static class Foo { > >> String val; > >> > >> public Foo(String x) { val = > x; } > >> } > >> > >> public static class FooConverter > >> implements Converter<Foo> { > >> public Foo read(InputNode > node) > >> throws Exception { > >> return new Foo(new > >> Persister().read(String.class, node)); > >> } > >> > >> public void write(OutputNode > node, > >> Foo f) throws Exception { > >> new > >> Persister().write(f.val, node); > >> } > >> } > >> > >> public static void main(String[] > args) > >> throws Exception { > >> Registry registry = new > >> Registry(); > >> Strategy strategy = new > >> RegistryStrategy(registry); > >> Serializer serializer = new > >> Persister(strategy); > >> > >> registry.bind(Foo.class, > >> FooConverter.class); > >> > >> Example bla = new Example(); > >> bla.x = new Foo("test"); > >> > >> serializer.write(bla, new > >> File("example.xml")); > >> serializer.read(Example.class, > new > >> File("example.xml")); > >> } > >> } > >> > >> > ------------------------------------------------------------------------------ > >> Protect Your Site and Customers from Malware > Attacks > >> Learn about various malware tactics and how to > avoid them. > >> Understand malware threats, the impact they can > have on your business, > >> and how you can protect your company and customers > by using code > >> signing. > >> http://p.sf.net/sfu/oracle-sfdevnl > >> _______________________________________________ > >> Simple-support mailing list > >> Sim...@li... > >> https://lists.sourceforge.net/lists/listinfo/simple-support > >> > > > > > > > > |
|
From: Pete C. <pr...@ca...> - 2011-01-12 10:23:14
|
Hi, Yep ok. I should have thought of that, thank you. And there's no way to make them consistent without the child node? As is, "@Element Key<Foo> foo" is going to end up looking like: <foo><foo>...</foo></foo> If the only way is by making some changes, then I'm happy to make them if you think this is worthwhile. I don't really know my way around the code, but I think the following would do it: - Stop Traverser.write(OutputNode, Object, Class) from adding the child node itself (i.e. rather than working out a name for a child, don't add a child). - Add an argument "boolean createChild" to Persister.write(Object, OutputNode, ...) methods. Then in Persister.write(Object, OutputNode, Context, boolean) add the child as before if it is set. - Add a new method Persister.write(Object, OutputNode) that defaults createChild to true to make this backwards compatible (although I would argue that the default should actually be false and that write(Object, Writer) should set it to true). The potential problem is that I don't know whether Traverser.write(OutputNode, Object, Class) is used elsewhere, or just Traverser.write(OutputNode, Object, Class, String). Thanks Pete Niall Gallagher wrote: > Hi, > > Take a look at the following, it works fine. > > https://simple.svn.sourceforge.net/svnroot/simple/trunk/download/stream/src/test/java/org/simpleframework/xml/convert/WrapperTest.java > > Niall > > --- On Tue, 11/1/11, Pete Calvert <pr...@ca...> wrote: > >> From: Pete Calvert <pr...@ca...> >> Subject: [Simple-support] Asymmetry in Persister behaviour >> To: sim...@li... >> Received: Tuesday, 11 January, 2011, 4:25 PM >> Hi, >> >> I've noticed that the behaviour of write(Object, >> OutputNode) and >> read(Class, InputNode) is not entirely consistent. read >> loads directly >> from the node whereas write first creates a new child >> (using the name of >> the object's class) and then writes to this. >> >> Is there a way of working around this? i.e. write writing >> directly to >> the node given? >> >> The reason I need this is that I'm trying to import/export >> Objectify >> entities. References to other entities are stored as >> "Key<T>", so I've >> got a Converter for "Key" that 'skips' over the reference >> to export the >> entity in its place. I've included some code at the end of >> the email >> that exhibits the behaviour I'm talking about. >> >> Thanks >> Pete >> >> --- >> >> import org.simpleframework.xml.*; >> import org.simpleframework.xml.strategy.*; >> import org.simpleframework.xml.convert.*; >> import org.simpleframework.xml.core.*; >> import org.simpleframework.xml.stream.*; >> import java.io.*; >> >> public class Test { >> @Root >> public static class Example { >> @Element Foo x; >> } >> >> public static class Foo { >> String val; >> >> public Foo(String x) { val = x; } >> } >> >> public static class FooConverter >> implements Converter<Foo> { >> public Foo read(InputNode node) >> throws Exception { >> return new Foo(new >> Persister().read(String.class, node)); >> } >> >> public void write(OutputNode node, >> Foo f) throws Exception { >> new >> Persister().write(f.val, node); >> } >> } >> >> public static void main(String[] args) >> throws Exception { >> Registry registry = new >> Registry(); >> Strategy strategy = new >> RegistryStrategy(registry); >> Serializer serializer = new >> Persister(strategy); >> >> registry.bind(Foo.class, >> FooConverter.class); >> >> Example bla = new Example(); >> bla.x = new Foo("test"); >> >> serializer.write(bla, new >> File("example.xml")); >> serializer.read(Example.class, new >> File("example.xml")); >> } >> } >> >> ------------------------------------------------------------------------------ >> Protect Your Site and Customers from Malware Attacks >> Learn about various malware tactics and how to avoid them. >> Understand >> malware threats, the impact they can have on your business, >> and how you >> can protect your company and customers by using code >> signing. >> http://p.sf.net/sfu/oracle-sfdevnl >> _______________________________________________ >> Simple-support mailing list >> Sim...@li... >> https://lists.sourceforge.net/lists/listinfo/simple-support >> > > > |
|
From: Niall G. <gal...@ya...> - 2011-01-12 09:34:26
|
Hi, Take a look at the following, it works fine. https://simple.svn.sourceforge.net/svnroot/simple/trunk/download/stream/src/test/java/org/simpleframework/xml/convert/WrapperTest.java Niall --- On Tue, 11/1/11, Pete Calvert <pr...@ca...> wrote: > From: Pete Calvert <pr...@ca...> > Subject: [Simple-support] Asymmetry in Persister behaviour > To: sim...@li... > Received: Tuesday, 11 January, 2011, 4:25 PM > Hi, > > I've noticed that the behaviour of write(Object, > OutputNode) and > read(Class, InputNode) is not entirely consistent. read > loads directly > from the node whereas write first creates a new child > (using the name of > the object's class) and then writes to this. > > Is there a way of working around this? i.e. write writing > directly to > the node given? > > The reason I need this is that I'm trying to import/export > Objectify > entities. References to other entities are stored as > "Key<T>", so I've > got a Converter for "Key" that 'skips' over the reference > to export the > entity in its place. I've included some code at the end of > the email > that exhibits the behaviour I'm talking about. > > Thanks > Pete > > --- > > import org.simpleframework.xml.*; > import org.simpleframework.xml.strategy.*; > import org.simpleframework.xml.convert.*; > import org.simpleframework.xml.core.*; > import org.simpleframework.xml.stream.*; > import java.io.*; > > public class Test { > @Root > public static class Example { > @Element Foo x; > } > > public static class Foo { > String val; > > public Foo(String x) { val = x; } > } > > public static class FooConverter > implements Converter<Foo> { > public Foo read(InputNode node) > throws Exception { > return new Foo(new > Persister().read(String.class, node)); > } > > public void write(OutputNode node, > Foo f) throws Exception { > new > Persister().write(f.val, node); > } > } > > public static void main(String[] args) > throws Exception { > Registry registry = new > Registry(); > Strategy strategy = new > RegistryStrategy(registry); > Serializer serializer = new > Persister(strategy); > > registry.bind(Foo.class, > FooConverter.class); > > Example bla = new Example(); > bla.x = new Foo("test"); > > serializer.write(bla, new > File("example.xml")); > serializer.read(Example.class, new > File("example.xml")); > } > } > > ------------------------------------------------------------------------------ > Protect Your Site and Customers from Malware Attacks > Learn about various malware tactics and how to avoid them. > Understand > malware threats, the impact they can have on your business, > and how you > can protect your company and customers by using code > signing. > http://p.sf.net/sfu/oracle-sfdevnl > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > |
|
From: Niall G. <gal...@ya...> - 2011-01-12 09:33:43
|
Hi,
Take a look at the org.simpleframework.xml.transform.Transform interface. You need to write a Transform implementation that will be used to convert your enums.
There are many examples in the test cases.
Niall
--- On Wed, 12/1/11, David Wu <wud...@gm...> wrote:
From: David Wu <wud...@gm...>
Subject: [Simple-support] A question about enum support
To: sim...@li...
Received: Wednesday, 12 January, 2011, 1:29 AM
Hi, all
I want to change my XML parsing tool from JAXB to Simple XML recently, and I have a question about enum support.
In JAXB, there is an annotation "XMLEnumValue" to assign another value for the enum name. For example:
public enum Coin {
@XmlEnumValue("1")
PENNY(1),
@XmlEnumValue("5")
NICKEL(5),
@XmlEnumValue("10")
DIME(10),
@XmlEnumValue("25")
QUARTER(25)
}
public class Test {
public Coin coin;
}
Test test = new Test();
test.coin = Coin.PENNY;
After serialization, the test object will be transferred to:
<test>
<coin>1</coin>
</test>
Then I want to do the same thing using Simple XML, however, Simple XML doesn't have a similar annotation. and If I just define Coin like:
public enum Coin {
PENNY(1),
NICKEL(5),
DIME(10),
QUARTER(25)
}
Then after serialization, the test object will be:
<test>
<coin>PENNY</coin>
</test>
I want "1", not "PENNY", what shall I do?
Can simple XML do the similar thing, so I can use this feature?
I really need this feature, so I'd like to get help from all of you.
Thank you very much.
David
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: David Wu <wud...@gm...> - 2011-01-12 09:29:07
|
Hi, all
I want to change my XML parsing tool from JAXB to Simple XML recently, and I
have a question about enum support.
In JAXB, there is an annotation "XMLEnumValue" to assign another value for
the enum name. For example:
public enum Coin {
@XmlEnumValue("1")
PENNY(1),
@XmlEnumValue("5")
NICKEL(5),
@XmlEnumValue("10")
DIME(10),
@XmlEnumValue("25")
QUARTER(25)
}
public class Test {
public Coin coin;
}
Test test = new Test();
test.coin = Coin.PENNY;
After serialization, the test object will be transferred to:
<test>
<coin>1</coin>
</test>
Then I want to do the same thing using Simple XML, however, Simple XML
doesn't have a similar annotation. and If I just define Coin like:
public enum Coin {
PENNY(1),
NICKEL(5),
DIME(10),
QUARTER(25)
}
Then after serialization, the test object will be:
<test>
<coin>PENNY</coin>
</test>
I want "1", not "PENNY", what shall I do?
Can simple XML do the similar thing, so I can use this feature?
I really need this feature, so I'd like to get help from all of you.
Thank you very much.
David
|
|
From: Pete C. <pr...@ca...> - 2011-01-12 00:25:52
|
Hi, I've noticed that the behaviour of write(Object, OutputNode) and read(Class, InputNode) is not entirely consistent. read loads directly from the node whereas write first creates a new child (using the name of the object's class) and then writes to this. Is there a way of working around this? i.e. write writing directly to the node given? The reason I need this is that I'm trying to import/export Objectify entities. References to other entities are stored as "Key<T>", so I've got a Converter for "Key" that 'skips' over the reference to export the entity in its place. I've included some code at the end of the email that exhibits the behaviour I'm talking about. Thanks Pete --- import org.simpleframework.xml.*; import org.simpleframework.xml.strategy.*; import org.simpleframework.xml.convert.*; import org.simpleframework.xml.core.*; import org.simpleframework.xml.stream.*; import java.io.*; public class Test { @Root public static class Example { @Element Foo x; } public static class Foo { String val; public Foo(String x) { val = x; } } public static class FooConverter implements Converter<Foo> { public Foo read(InputNode node) throws Exception { return new Foo(new Persister().read(String.class, node)); } public void write(OutputNode node, Foo f) throws Exception { new Persister().write(f.val, node); } } public static void main(String[] args) throws Exception { Registry registry = new Registry(); Strategy strategy = new RegistryStrategy(registry); Serializer serializer = new Persister(strategy); registry.bind(Foo.class, FooConverter.class); Example bla = new Example(); bla.x = new Foo("test"); serializer.write(bla, new File("example.xml")); serializer.read(Example.class, new File("example.xml")); } } |
|
From: Niall G. <gal...@ya...> - 2011-01-08 02:12:59
|
Hi,
You could apply a convention here, like in CamelCaseStyle you can say
new CamelCase(false, false)
Which will convert PersonName to personName. However, as the XML specification implies, XML is case sensitive, which means PersonName is not equal to personName as an element. Also you may notice in the CamelCaseStyle the setElement and setAttribute methods, this allows for various alternatives. For example
camelCase.setElement("PersonName", "personName")
camelCase.setElement("personname", "personName")
etc..
Case insensitivity is not supported because is not really valid XML.
Niall
--- On Fri, 7/1/11, Greg Milette <gre...@gm...> wrote:
From: Greg Milette <gre...@gm...>
Subject: Re: Re: [Simple-support] Case insensitive deserialization
To: "Niall Gallagher" <gal...@ya...>
Cc: sim...@li...
Received: Friday, 7 January, 2011, 5:22 AM
Hello.
I am still having a problem getting inconsistent cased xml to deserialize. I would really appreciate your help.
For example, in the code below, the SampleObject has a "personName" member variable. When the test code passes in "PersonName" the object cannot deserialize.
One solution that will work every time is to use a Style as I have done below, which will accept "personname" in the xml.
The problem is that using a style means that the xml ALWAYS has to be lowercase. This means that while "personname" will be deserialize, "PersonName" or "personName" will not.
Question: How do I make the Persister deserialize any case? Using the Style and Format alone does not work.
Thanks!
import org.junit.Test;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.core.Persister;
import org.simpleframework.xml.stream.Format;
import org.simpleframework.xml.stream.Style;
public class TestSimple
{
@Test
public void test()
{
//the name is capital and it doesn't like it!
String withUppercase = "<SampleObject><PersonName>john</PersonName></SampleObject>";
Style anycase = new Style()
{
@Override
public String getElement(String arg0)
{
return arg0.toLowerCase();
}
@Override
public String getAttribute(String arg0)
{
return arg0.toLowerCase();
}
};
Format format = new Format(anycase);
Persister serializer = new Persister(format);
SampleObject output;
try
{
output = (SampleObject)serializer.read(SampleObject.class, withUppercase);
}
catch (Exception e)
{
throw new RuntimeException("failed to deserialize as stream", e);
}
System.out.println("output: " + output.getPersonName());
}
}
@Root(name="SampleObject")
class SampleObject
{
@Element
String personName; //note: personName starts with lowercase!
public String getPersonName()
{
return personName;
}
}
On Wed, Sep 29, 2010 at 2:06 PM, Greg Milette <gre...@gm...> wrote:
Hi,
I was unable to find a test case so I have created my own and included it below.
The xml has "Name" as the attribute, but the class has "name" with lowercase n.
I expect that my Style implementation will cause the framework to succeed in deserializing, but it fails.
Can you kindly suggest the appropriate use of the Style object to achieve my desired effect of case insensitivity?
Thanks!
import org.junit.Test;
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.core.Persister;
import org.simpleframework.xml.stream.Format;
import org.simpleframework.xml.stream.Style;
public class TestSample
{
@Test
public void test()
{
//the name is capital and it doesn't like it!
String withUppercase = "<SampleObject Name=\"john\"/>";
Style anycase = new Style(){
@Override
public String getElement(String arg0)
{
return arg0.toLowerCase();
}
@Override
public String getAttribute(String arg0)
{
return arg0.toLowerCase();
}
};
Format format = new Format(anycase);
Persister serializer = new Persister(format);
Object output;
try
{
output = serializer.read(SampleObject.class, withUppercase, false);
}
catch (Exception e)
{
throw new RuntimeException("failed to deserialize as stream", e);
}
}
}
@Root
class SampleObject
{
@Attribute
String name; //note: name is lowercase!
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
}
On Sun, Sep 26, 2010 at 10:11 PM, Niall Gallagher <gal...@ya...> wrote:
Hi,
You can set the style in the Format object, and pass that to the persister. I think there is actually a test case available with the download that has an example of case insensitive deserialization.
Niall
--- On Sun, 26/9/10, gre...@gm... <gre...@gm...> wrote:
From: gre...@gm... <gre...@gm...>
Subject: Re: Re: [Simple-support] Case insensitive deserialization
To: "Niall Gallagher" <gal...@ya...>
Cc: sim...@li...
Received: Sunday, 26 September, 2010, 5:34 AM
I agree that the Style class could work, but the Persister class does not allow me to set a Style.
How do I use a Style in the deserialization process?
Thanks,
Greg
On Sep 26, 2010 8:26am, Greg Milette <gre...@gm...> wrote:
>
> Hi
>
> On Sep 26, 2010 4:48 AM, "Niall Gallagher" gal...@ya...> wrote:
>
>
> Hi,
>
>
>
> Take a look at the Style interface, it should allow you to do this.
>
>
>
> Niall
>
> --- On Fri, 24/9/10, Greg Milette gre...@gm...> wrote:
>
>
>
> From: Greg Milette gre...@gm...>
> Subject: [Simple-support] Case insensitive deserialization
>
> To: sim...@li...
> Received: Friday, 24 September, 2010, 6:29 AM
>
> >
> > How do I make the deserializer case insensitive?
>
> >
> > I've got an element like
> > name-----Inline Attachment Follows-----
>
>
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
>
> http://p.sf.net/sfu/novell-sfdev2dev
>
> -----Inline Attachment Follows-----
>
>
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
>
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
>
>
>
>
>
>
|
|
From: Niall G. <gal...@ya...> - 2011-01-06 07:25:00
|
Hi, Ya, I have been meaning to do this. I will hopefully get a chance to do this soon. Should be a fairly easy task. Also, typing exceptions better I think would be helpful so that only PersistenceExceptions are thrown. Niall --- On Wed, 5/1/11, Atkins, Brian <Bri...@ne...> wrote: From: Atkins, Brian <Bri...@ne...> Subject: [Simple-support] Request: accessible data fields in PersistenceException To: sim...@li... Received: Wednesday, 5 January, 2011, 1:12 PM I am using Simple for both serialization and as a configuration mechanism. I'd like to format user friendly messages when deserialization fails due to missing elements or attributes, or when values can't be parsed correctly (e.g. NumberFormatException). Would it be possible to put relevant data in accessible fields in PersistenceException? For deserialization, information such as enclosing element/class, the actual element or attribute that failed (perhaps already indicated by exception subtype and/or cause exception (e.g. FormatException w/ cause NumberFormatException) would be most helpful. Much of this data is already provided, but it is immediately formatted into the message text. If the same information could also be provided as fields accessible from the exception class, it would be much easier to customize handling of the exception. Any information on existing methods of getting this sort of information during deserialization would also be welcome. Thanks! Batkins -----Inline Attachment Follows----- ------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl -----Inline Attachment Follows----- _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Atkins, B. <Bri...@ne...> - 2011-01-05 21:12:19
|
I am using Simple for both serialization and as a configuration mechanism. I'd like to format user friendly messages when deserialization fails due to missing elements or attributes, or when values can't be parsed correctly (e.g. NumberFormatException). Would it be possible to put relevant data in accessible fields in PersistenceException? For deserialization, information such as enclosing element/class, the actual element or attribute that failed (perhaps already indicated by exception subtype and/or cause exception (e.g. FormatException w/ cause NumberFormatException) would be most helpful. Much of this data is already provided, but it is immediately formatted into the message text. If the same information could also be provided as fields accessible from the exception class, it would be much easier to customize handling of the exception. Any information on existing methods of getting this sort of information during deserialization would also be welcome. Thanks! Batkins |