simple-support Mailing List for Simple (Page 25)
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: Jarrod S. <ja...@co...> - 2011-11-06 10:37:39
|
I have a doc that has something like the following structure:
<FAIL | OK>
<!-- In the FAIL Case: -->
<A>Error relating to A</A>
<B>Error relating to B</B>
<C>Error relating to C</C>
...
<ERROR>General Error Message</ERROR>
<ERROR>General Error Message</ERROR>
<ERROR>General Error Message</ERROR>
...
</FAIL | OK>
There could be a lot of different A, B, C, ...., and to make matters
worse, I haven't even been provided with a specification as to what
they all could be.
The contents of the elements is always just a string. So the document
is really just a flat list of elements containing strings. Is there a
simple way for me to declare a Class to parse this?
Something like:
@Root
public class MyErrorClass {
@ElementList(inline=true)
public List<APIError> errors;
}
@Root // <--- Don't want this to care about
the name of the element.
public class APIError
{
@Text
String error;
}
Another idea I had was to just use a Visitor to stomp all the element
names and just make them all ERROR. But it doesn't look like you can
change the element name of an InputNode. Anyway, this idea would only
work if the TreeStrategy visits the document Root node before any
others, so I could set a flag indicating this was a <FAIL> document.
Any suggestions appreciated.
|
|
From: Jarrod S. <ja...@co...> - 2011-11-06 06:23:55
|
Oops, meant to post that to the list for the future reference of others...
On Sun, Nov 6, 2011 at 5:21 PM, Jarrod Smith <ja...@co...> wrote:
> Thanks for the help Niall, I ended up with this:
>
> public class RootNodeVisitor implements Visitor
> {
> @Override
> public void read(Type arg0, NodeMap<InputNode> arg1) throws Exception
> {
> }
>
> @Override
> public void write(Type type, NodeMap<OutputNode> node) throws Exception
> {
> OutputNode element = node.getNode();
> if (element.isRoot())
> {
> element.setAttribute("error", element.getName()); // Root element
> is either <OK> or <FAIL>.
> }
> }
> }
>
> And modifying the class to support an error attribute:
>
> @Root(strict=false)
> public class MyResponse
> {
> @Attribute
> String error;
>
> ...
>
> On Thu, Nov 3, 2011 at 6:37 PM, Niall Gallagher
> <gal...@ya...> wrote:
>>
>> It sould be possible to do this with a custom strategy implementation. With this you can return the type meta data. Check out the examples in the test cases
>>
>> Sent from Yahoo!7 Mail on Android
>
>>> Thanks Niall,
>>> But I need to be able to tell if the root element is <OK> or <FAIL>. Is this possible?
|
|
From: Sreekanth V. <vie...@gm...> - 2011-11-04 13:19:50
|
Hi, I am running into the same issue reported in the following message. I was wondering if there is a resolution to this issue? >From what I understand, this issue happens if the default constructor creates and populates the array list with some elements. When deserializing, - Simple uses the annotated getter to get the existing list and just adds the elements from the deserialization process to this list without clearing this list first - Uses the annotated setter to set the list https://sourceforge.net/mailarchive/message.php?msg_id=27613384 Thanks, Sree |
|
From: Niall G. <gal...@ya...> - 2011-11-03 20:59:53
|
I had a similar problem with kxml. Take a look at the PullReader there should be a fix in there that can be used for the EventReader. Sent from Yahoo!7 Mail on Android |
|
From: Stefanato F. (K. 2) <fed...@cr...> - 2011-11-03 12:39:42
|
Hi Niall, trying to digging about an issue on deserializing an unexpected empty structure (i.e an empty char), I finally found out the reason. Locally, in my tests, the EventReader implementation is com.sun.xml.internal.stream.XMLEventReaderImpl while deployed on the Application Server (Weblogic 10.3), the implementing class is: weblogic.xml.stax.XMLEventReaderBase This causes the reader to go on StackOverflowException when calling reader.next() in such situation (empty char). I'm aware this is "out of your jurisdiction" and now I'll try to investigate how to patch it, nevertheless hopefully you may have some useful suggestions about that... Thanks in advance for any help. Regards federico |
|
From: Niall G. <gal...@ya...> - 2011-11-03 10:58:30
|
Try @Path("table1") for your elements!
Sent from Yahoo!7 Mail on Android
|
|
From: Jacob A. <ja...@av...> - 2011-11-03 10:53:49
|
Hi there, I need to connect to a backend with XML and decided to try out Simple for these purposes. Only, I've run into a problem. The problem is that the backend (XML autogenerated by .NET) defines a generic element "Table1", which includes an application key and is present in all calls to the server. For instance, take a look at these different documents: <AddUserLocation> <table1> <type>false</type> <city>Birkerød</city> <countrycode>DK</countrycode> <ticketcode>xxxxxxxxx</ticketcode> <longtitude>15.443104</longtitude> <latitude>35.839486</latitude> <ticketid>130</ticketid> <appkey>xxxxxxxx</appkey> </table1> </AddUserLocation> <GetAverageLocationsByAreal> <table1> <sorttype>5</sorttype> <type>34</type> <ticketcode>xxxxxxxxx</ticketcode> <longtitude>15.443107</longtitude> <latitude>35.839470</latitude> <ticketid>130</ticketid> <filter/> <count>20</count> <start>0</start> <appkey>xxxxxxxx</appkey> </table1> </GetAverageLocationsByAreal> * * Notice that while the root and leaf elements differ, the "table1"-element is present in both documents, and it always has the "appkey" element as a child. How can I model this in Simple? If I create a class called "Table1" and extend from it, the XML element "table1" will have a "class" attribute added to it (makes good sense, too, for the de-serialization), which I cannot get past the schema (and which will not be sent back to me in the response, where the problem will arise again). I've tried messing around with Element Unions, but that doesn't seem to fix the problem either, though I may have missed something. Best of all, Jacob Avlund |
|
From: Lumsdon, H. <Hug...@bl...> - 2011-11-02 11:08:11
|
Thanks Neil – we’ll take a look at transform.
We also discovered if we return empty string (“”) in our converter in the event of a null value it also fixes it.
From: Niall Gallagher [mailto:gal...@ya...]
Sent: 02 November 2011 11:02
To: simple-support@lists sourceforge. net; Lumsdon, Hugo
Subject: Re: [Simple-support] Null pointer in Reference.getType when using @Converter
Try a transform for strings, coverters are for composite objects not strings.
Sent from Yahoo!7 Mail on Android
________________________________
From: Lumsdon, Hugo <Hug...@bl...>;
To: sim...@li... <sim...@li...>;
Subject: [Simple-support] Null pointer in Reference.getType when using @Converter
Sent: Mon, Oct 31, 2011 6:52:50 PM
Hi,
We are trying to escape Xhtml on file read using an @Converter tag – however Simple falls over with a NPE when we have empty tags in our XML source docs – e.g.
<message/>
Here is an example of the @Converter annotation:
@Element(required = false)
@Convert(EscapeXhtmlConverter.class)
private String message = "";
And here is the very simple EscapeXhtmlConverter class:
import org.simpleframework.xml.convert.Converter;
import org.simpleframework.xml.stream.InputNode;
import org.simpleframework.xml.stream.OutputNode;
import freemarker.template.utility.StringUtil;
// TODO: Auto-generated Javadoc
/**
* The Class EscapeXmlConverter.
*/
public class EscapeXhtmlConverter implements Converter<String> {
/* (non-Javadoc)
* @see org.simpleframework.xml.convert.Converter#read(org.simpleframework.xml.stream.InputNode)
*/
@Override
public String read(InputNode node) throws Exception {
String value = node.getValue();
String escapedValue = StringUtil.XHTMLEnc(value);
return escapedValue;
}
@Override
public void write(OutputNode node, String value) throws Exception {
// Do nothing for now
}
}
And the stack trace:
java.lang.NullPointerException
at org.simpleframework.xml.convert.Reference.getType(Reference.java:70)
at org.simpleframework.xml.core.Factory.getOverride(Factory.java:143)
at org.simpleframework.xml.core.PrimitiveFactory.getInstance(PrimitiveFactory.java:82)
at org.simpleframework.xml.core.Primitive.readElement(Primitive.java:186)
at org.simpleframework.xml.core.Primitive.read(Primitive.java:124)
at org.simpleframework.xml.core.Composite.readVariable(Composite.java:687)
at org.simpleframework.xml.core.Composite.readInstance(Composite.java:635)
at org.simpleframework.xml.core.Composite.readUnion(Composite.java:610)
at org.simpleframework.xml.core.Composite.readElement(Composite.java:593)
at org.simpleframework.xml.core.Composite.readElements(Composite.java:506)
at org.simpleframework.xml.core.Composite.readSection(Composite.java:388)
at org.simpleframework.xml.core.Composite.read(Composite.java:367)
at org.simpleframework.xml.core.Composite.readDefault(Composite.java:262)
at org.simpleframework.xml.core.Composite.read(Composite.java:232)
at org.simpleframework.xml.core.Composite.read(Composite.java:202)
at org.simpleframework.xml.core.Composite.read(Composite.java:150)
at org.simpleframework.xml.core.Traverser.read(Traverser.java:92)
at org.simpleframework.xml.core.Persister.read(Persister.java:632)
at org.simpleframework.xml.core.Persister.read(Persister.java:613)
at org.simpleframework.xml.core.Persister.read(Persister.java:591)
at org.simpleframework.xml.core.Persister.read(Persister.java:550)
at org.simpleframework.xml.core.Persister.read(Persister.java:451)
at com.blackrock.ebiz.corecms.dao.shared.XmlMarshallerImpl.deserialise(XmlMarshallerImpl.java:30)
….
Thanks!
THIS MESSAGE AND ANY ATTACHMENTS ARE CONFIDENTIAL, PROPRIETARY, AND MAY BE PRIVILEGED. If this message was misdirected, BlackRock, Inc. and its subsidiaries, ("BlackRock") does not waive any confidentiality or privilege. If you are not the intended recipient, please notify us immediately and destroy the message without disclosing its contents to anyone. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. The views and opinions expressed in this e-mail message are the author's own and may not reflect the views and opinions of BlackRock, unless the author is authorized by BlackRock to express such views or opinions on its behalf. All email sent to or from this address is subject to electronic storage and review by BlackRock. Although BlackRock operates anti-virus programs, it does not accept responsibility for any damage whatsoever caused by viruses being passed.
--
BlackRock Advisors (UK) Limited is authorized and regulated by The Financial Services Authority. Registered in England. Registered No:796793. Registered Office: 33 King William Street, London EC4R 9AS. |
|
From: Niall G. <gal...@ya...> - 2011-11-02 11:02:21
|
Try a transform for strings, coverters are for composite objects not strings. Sent from Yahoo!7 Mail on Android |
|
From: Niall G. <gal...@ya...> - 2011-11-02 11:00:11
|
Root element names are ignored, it should just work. Sent from Yahoo!7 Mail on Android |
|
From: Jarrod S. <ja...@co...> - 2011-11-02 01:37:58
|
I have to parse server responses that where the body of the document is the
same, but the document root node can change depending on whether the
request resulted in errors:
e.g. Success response:
*<OK>*
<ELEM1>Data</ELEM1>
<ELEM2>Data</ELEM2>
...
*</OK>*
Error response:
*<FAIL>*
<ELEM1>Error information for ELEM1</ELEM1>
<ELEM2>Error information for ELEM2</ELEM2>
...
*</FAIL>*
*
*
How can I support this using Simple? I don't want to have to sniff the
input stream and switch classes based on whether I find an <OK> or <FAIL>
element. I just want to do the same persister.read(MyDocClass) with the
same MyDocClass in both cases.
* *
Thanks for an awesome XML lib, it rocks.
|
|
From: Lumsdon, H. <Hug...@bl...> - 2011-10-31 19:17:19
|
Hi,
We are trying to escape Xhtml on file read using an @Converter tag - however Simple falls over with a NPE when we have empty tags in our XML source docs - e.g.
<message/>
Here is an example of the @Converter annotation:
@Element(required = false)
@Convert(EscapeXhtmlConverter.class)
private String message = "";
And here is the very simple EscapeXhtmlConverter class:
import org.simpleframework.xml.convert.Converter;
import org.simpleframework.xml.stream.InputNode;
import org.simpleframework.xml.stream.OutputNode;
import freemarker.template.utility.StringUtil;
// TODO: Auto-generated Javadoc
/**
* The Class EscapeXmlConverter.
*/
public class EscapeXhtmlConverter implements Converter<String> {
/* (non-Javadoc)
* @see org.simpleframework.xml.convert.Converter#read(org.simpleframework.xml.stream.InputNode)
*/
@Override
public String read(InputNode node) throws Exception {
String value = node.getValue();
String escapedValue = StringUtil.XHTMLEnc(value);
return escapedValue;
}
@Override
public void write(OutputNode node, String value) throws Exception {
// Do nothing for now
}
}
And the stack trace:
java.lang.NullPointerException
at org.simpleframework.xml.convert.Reference.getType(Reference.java:70)
at org.simpleframework.xml.core.Factory.getOverride(Factory.java:143)
at org.simpleframework.xml.core.PrimitiveFactory.getInstance(PrimitiveFactory.java:82)
at org.simpleframework.xml.core.Primitive.readElement(Primitive.java:186)
at org.simpleframework.xml.core.Primitive.read(Primitive.java:124)
at org.simpleframework.xml.core.Composite.readVariable(Composite.java:687)
at org.simpleframework.xml.core.Composite.readInstance(Composite.java:635)
at org.simpleframework.xml.core.Composite.readUnion(Composite.java:610)
at org.simpleframework.xml.core.Composite.readElement(Composite.java:593)
at org.simpleframework.xml.core.Composite.readElements(Composite.java:506)
at org.simpleframework.xml.core.Composite.readSection(Composite.java:388)
at org.simpleframework.xml.core.Composite.read(Composite.java:367)
at org.simpleframework.xml.core.Composite.readDefault(Composite.java:262)
at org.simpleframework.xml.core.Composite.read(Composite.java:232)
at org.simpleframework.xml.core.Composite.read(Composite.java:202)
at org.simpleframework.xml.core.Composite.read(Composite.java:150)
at org.simpleframework.xml.core.Traverser.read(Traverser.java:92)
at org.simpleframework.xml.core.Persister.read(Persister.java:632)
at org.simpleframework.xml.core.Persister.read(Persister.java:613)
at org.simpleframework.xml.core.Persister.read(Persister.java:591)
at org.simpleframework.xml.core.Persister.read(Persister.java:550)
at org.simpleframework.xml.core.Persister.read(Persister.java:451)
at com.blackrock.ebiz.corecms.dao.shared.XmlMarshallerImpl.deserialise(XmlMarshallerImpl.java:30)
....
Thanks!
THIS MESSAGE AND ANY ATTACHMENTS ARE CONFIDENTIAL, PROPRIETARY, AND MAY BE PRIVILEGED. If this message was misdirected, BlackRock, Inc. and its subsidiaries, ("BlackRock") does not waive any confidentiality or privilege. If you are not the intended recipient, please notify us immediately and destroy the message without disclosing its contents to anyone. Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized. The views and opinions expressed in this e-mail message are the author's own and may not reflect the views and opinions of BlackRock, unless the author is authorized by BlackRock to express such views or opinions on its behalf. All email sent to or from this address is subject to electronic storage and review by BlackRock. Although BlackRock operates anti-virus programs, it does not accept responsibility for any damage whatsoever caused by viruses being passed.
--
BlackRock Advisors (UK) Limited is authorized and regulated by The Financial Services Authority. Registered in England. Registered No:796793. Registered Office: 33 King William Street, London EC4R 9AS. |
|
From: Niall G. <gal...@ya...> - 2011-10-24 10:43:49
|
You can annotate a method and put the logic there. Otherwise you can use a converter. Sent from Yahoo!7 Mail on Android |
|
From: bubbleguuum <bub...@fr...> - 2011-10-24 09:52:03
|
Let's say I have an element: @Element private String blargh; In some cases I want to do serialization with the blargh element (if it has a value of course) and sometimes I want to do serialization without it (even if it has a value). One inconvenient way to achieve serialization without it, would be to set blargh to null before serialization and restore its value after. Is there something more convenient ? |
|
From: Niall G. <gal...@ya...> - 2011-10-22 00:45:21
|
You are annotating an ArrayList<E>, this does not make much sense. Collections should not be annotated.
________________________________
From: Leonardo Seccia <le...@ma...>
To: sim...@li...
Sent: Wednesday, 19 October 2011 12:50 PM
Subject: [Simple-support] extends ArrayList<E> and simple xml
Hi all,
I am new to java development and to the simple xml library.
Here are my classes (some code has been removed to make it more concise):
@Root
@ElementList
public class MyArrayList<E> extends ArrayList<E>{
public void ToXml() throws Exception{
Serializer serializer = new Persister();
File file = new File("somewhere in my file system");
serializer.write(this, file);
}
}
@Root
public abstract class MediaEntry implements Serializable {
private static final long serialVersionUID = 1L;
@Element
public String Title;
@Element
public String Description;
@Element
public String Url;
@Element
public String LocalPath;
public MediaEntry(String title, String description, String url, String localPath) {
Title= title;
Description= description;
Url= url;
LocalPath= localPath;
}
}
public class VideoEntry extends MediaEntry {
private static final long serialVersionUID = 1L;
public VideoEntry(String title, String description, String url, String localPath) {
super(title, description, url, localPath);
}
}
When I instantiate MyArrayList<MediaEntry> add some VideoEntries and call ToXml, I only get an empty root ie. <MyArrayList />
How to I solve this? Is it something to do with the fact that MyArrayList is generic?
Thanks in advance,
Leo
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Niall G. <gal...@ya...> - 2011-10-22 00:42:59
|
There is a RegistryMatcher, just use this. Register your classes with it. Its available in 2.6.2.
________________________________
From: jc.jourdon <jc....@7g...>
To: sim...@li...
Sent: Friday, 21 October 2011 10:52 AM
Subject: Re: [Simple-support] Boolean Attribute 0 or 1
Hello back,
i implemented a Matcher as you proposed, but i need a Matcher that
Transform many different Type of data (Transform<Float>,
Transform<Integer> and Transform<Boolean>).
how can i do this with a single implementation of Matcher class ?
my Matcher , with a single transformer, so far :
public class LigneArticleFloatMatcher implements Matcher, Transform<Float> {
@Override
public Float read(String value) throws Exception {
if((value!="null")&&(value!=""))
{
try{
return Float.valueOf(value);
}catch(Exception e){
return 0f;
}
}else{
return 0f;
}
}
@Override
public String write(Float value) throws Exception {
return String.valueOf(value);
}
@SuppressWarnings("rawtypes")
@Override
public Transform match(Class type) throws Exception {
if(type == Float.class) {
return this;
}
return null;
}
}
Thanks in advance ^^
> hello,
>
> you've done a great job with this tool and i already parsed many
> different XML from soap servers since last 3 days, but i encountered
> boolean attributes with "0" or "1"
>
> <list mybool1="0" mybool2="1" attr1="attr" attr2="attr">
> <page mybool3="1">
> ...
> </page>
> <page mybool3="0">
> ...
> </page>
> ...
> </list>
>
> I tried to create this class :
>
> public class Boolean01Converter implements Converter<Boolean>
> {
> @Override
> public Boolean read(InputNode node) throws Exception {
> return new Boolean(node.getValue().equals("1"));
> }
> @Override
> public void write(OutputNode node, Boolean value) throws Exception {
> node.setValue(value.booleanValue()?"1":"0");
> }
> }
>
> and implemented it on my object definition :
>
> @Root(name="list")
> public class ListFcts
> {
> @Attribute
> @Convert(Boolean01Converter.class)
> private Boolean mybool1;
>
> @Attribute
> @Convert(Boolean01Converter.class)
> private Boolean mybool2;
>
> @Attribute
> private int ...
>
> @ElementList(name="page", inline=true)
> private List<Page> pages;
> }
>
>
> But i still get false for every boolean.
>
> Also : how can I attach the converter to the Persister instead of
> declaring it on @Attributes hundred times ?
>
> Many thanks in advance !!
------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn
about Cisco certifications, training, and career opportunities.
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: jc.jourdon <jc....@7g...> - 2011-10-21 09:52:55
|
Hello back,
i implemented a Matcher as you proposed, but i need a Matcher that
Transform many different Type of data (Transform<Float>,
Transform<Integer> and Transform<Boolean>).
how can i do this with a single implementation of Matcher class ?
my Matcher , with a single transformer, so far :
public class LigneArticleFloatMatcher implements Matcher, Transform<Float> {
@Override
public Float read(String value) throws Exception {
if((value!="null")&&(value!=""))
{
try{
return Float.valueOf(value);
}catch(Exception e){
return 0f;
}
}else{
return 0f;
}
}
@Override
public String write(Float value) throws Exception {
return String.valueOf(value);
}
@SuppressWarnings("rawtypes")
@Override
public Transform match(Class type) throws Exception {
if(type == Float.class) {
return this;
}
return null;
}
}
Thanks in advance ^^
> hello,
>
> you've done a great job with this tool and i already parsed many
> different XML from soap servers since last 3 days, but i encountered
> boolean attributes with "0" or "1"
>
> <list mybool1="0" mybool2="1" attr1="attr" attr2="attr">
> <page mybool3="1">
> ...
> </page>
> <page mybool3="0">
> ...
> </page>
> ...
> </list>
>
> I tried to create this class :
>
> public class Boolean01Converter implements Converter<Boolean>
> {
> @Override
> public Boolean read(InputNode node) throws Exception {
> return new Boolean(node.getValue().equals("1"));
> }
> @Override
> public void write(OutputNode node, Boolean value) throws Exception {
> node.setValue(value.booleanValue()?"1":"0");
> }
> }
>
> and implemented it on my object definition :
>
> @Root(name="list")
> public class ListFcts
> {
> @Attribute
> @Convert(Boolean01Converter.class)
> private Boolean mybool1;
>
> @Attribute
> @Convert(Boolean01Converter.class)
> private Boolean mybool2;
>
> @Attribute
> private int ...
>
> @ElementList(name="page", inline=true)
> private List<Page> pages;
> }
>
>
> But i still get false for every boolean.
>
> Also : how can I attach the converter to the Persister instead of
> declaring it on @Attributes hundred times ?
>
> Many thanks in advance !!
|
|
From: Leonardo S. <le...@ma...> - 2011-10-19 12:20:33
|
Hi all,
I am new to java development and to the simple xml library.
Here are my classes (some code has been removed to make it more concise):
@Root
@ElementList
public class MyArrayList<E> extends ArrayList<E>{
public void ToXml() throws Exception{
Serializer serializer = new Persister();
File file = new File("somewhere in my file system");
serializer.write(this, file);
}
}
@Root
public abstract class MediaEntry implements Serializable {
private static final long serialVersionUID = 1L;
@Element
public String Title;
@Element
public String Description;
@Element
public String Url;
@Element
public String LocalPath;
public MediaEntry(String title, String description, String
url, String localPath) {
Title= title;
Description= description;
Url= url;
LocalPath= localPath;
}
}
public class VideoEntry extends MediaEntry {
private static final long serialVersionUID = 1L;
public VideoEntry(String title, String description, String
url, String localPath) {
super(title, description, url, localPath);
}
}
When I instantiate MyArrayList<MediaEntry> add some VideoEntries and call
ToXml, I only get an empty root ie. <MyArrayList />
How to I solve this? Is it something to do with the fact that MyArrayList is
generic?
Thanks in advance,
Leo
|
|
From: Jebarlin R. <jeb...@gm...> - 2011-10-17 08:30:34
|
Hi Niall,
Thanks for the valuable update Niall, will wait for the next release with
this fix, which will help me for the further development.
Thanks & Regards,
Jebarlin.R
On Sat, Oct 15, 2011 at 6:43 PM, Niall Gallagher
<gal...@ya...>wrote:
> Hi,
>
> I had a chance to take a look at this using the large XML document you
> provided, and there is quite a simple fix associated with the
> ElementListUnion that doubles the performance. There should also be less
> churn in the garbage collector. I will ensure to add this fix to the next
> release.
>
> Thanks,
> Niall
>
> ------------------------------
> *From:* Jebarlin Robertson <jeb...@gm...>
>
> *To:* Niall Gallagher <gal...@ya...>
> *Cc:* sim...@li...
> *Sent:* Wednesday, 14 September 2011 5:22 AM
>
> *Subject:* Re: [Simple-support] Performance and time consuming issues for
> parsing a big XML file using Simple
>
> Hi Niall,
>
> Thanks for the valuable response...
>
> I am not able to send the attachment and Simple mail list is not allowing
> me to attach more than 40kb file size
>
>
> After calling this line CTDocument doc = serializer.read(CTDocument.class,
> new ByteArrayInputStream(data), false);
>
> Garbage collector is running more frequently and taking so much time to
> complete the parser....
>
> *Some sample code*
> *
> *
> @Root(name="document")
> public class CTDocument extends CTDocumentBase
> {
> @Element
> private CTBody body;
>
> public CTBody getBody() {
> return body;
> }
>
>
> @Validate
> public void validate() {
> System.out.println(" CTDocument @Validate ***********************");
> }
> }
>
> public class CTDocumentBase
> {
> @Element(name="background", required=false)
> private CTBackground background;
>
> public CTBackground getBackground() {
> return background;
> }
> }
>
> public class CTBody
> {
> @ElementListUnion ( {
> @ElementList(entry="p", inline=true, type=CTP.class, required = false),
> @ElementList(entry="tbl", inline=true, type=CTTbl.class, required =
> false)
> })
> List<WordXMLTagsOperation> operations;
>
> @Element(required=false)
> private CTSectPr sectPr;
>
> public List<WordXMLTagsOperation> getOperations() {
> return operations;
> }
> public CTSectPr getSectPr() {
> return sectPr;
> }
>
> @Validate
> public void validate() {
> System.out.println(" CTBody @Validate ***********************");
> }
> }
>
> public class CTP extends EGPContent implements WordXMLTagsOperation
> {
> @Attribute(required=false)
> private String rsidRPr;
>
> @Attribute(required=false)
> private String rsidR;
>
> @Attribute(required=false)
> private String rsidDel;
>
> @Attribute(required=false)
> private String rsidP;
>
> @Attribute(required=false)
> private String rsidRDefault;
>
> @Element(name="pPr", required=false)
> private CTPPr PPr;
>
> public CTPPr getPPr() {
> return PPr;
> }
> public String getRsidRPr() {
> return rsidRPr;
> }
> public String getRsidR() {
> return rsidR;
> }
>
> public String getRsidDel() {
> return rsidDel;
> }
>
> public String getRsidP() {
> return rsidP;
> }
>
> public String getRsidRDefault() {
> return rsidRDefault;
> }
> @Validate
> public void validate() {
> System.out.println(" CTP @Validate ***********************");
> }
> }
>
> public class EGPContent
> {
>
> @ElementListUnion({
> @ElementList(entry="r", inline=true, type=CTR.class, required =
> false),
> @ElementList(entry="hyperlink", inline=true, type=CTHyperlink.class,
> required = false),
> @ElementList(entry="subDoc", inline=true, type=CTRel.class, required =
> false),
> @ElementList(entry="customXml", inline=true,
> type=CTCustomXmlRun.class, required = false),
> @ElementList(entry="smartTag", inline=true, type=CTSmartTagRun.class,
> required = false),
> @ElementList(entry="fldSimple", inline=true, type=CTSimpleField.class,
> required = false),
> @ElementList(entry="sdt", inline=true, type=CTSdtRun.class, required =
> false)
> })
> List<WordXMLTagsOperation> PContentList;
>
> public List<WordXMLTagsOperation> getOperations() {
> return PContentList;
> }
> }
>
> I will send the remaining part in the following mail, as the Simple mailing
> list is not allowing to send more than 40kp body size
>
>
> Regards,
> Jebarlin
>
>
>
--
Thanks & Regards,
Jebarlin Robertson.R
GSM: 91-9538106181.
|
|
From: Niall G. <gal...@ya...> - 2011-10-16 06:38:03
|
Hi, I have released Simple 2.6.2. This release contains performance enhancements for the union annotations as well as better exception messages for errors relating to the @Order annotation. Thanks, Niall |
|
From: Niall G. <gal...@ya...> - 2011-10-15 13:13:54
|
Hi,
I had a chance to take a look at this using the large XML document you provided, and there is quite a simple fix associated with the ElementListUnion that doubles the performance. There should also be less churn in the garbage collector. I will ensure to add this fix to the next release.
Thanks,
Niall
________________________________
From: Jebarlin Robertson <jeb...@gm...>
To: Niall Gallagher <gal...@ya...>
Cc: sim...@li...
Sent: Wednesday, 14 September 2011 5:22 AM
Subject: Re: [Simple-support] Performance and time consuming issues for parsing a big XML file using Simple
Hi Niall,
Thanks for the valuable response...
I am not able to send the attachment and Simple mail list is not allowing me to attach more than 40kb file size
After calling this line CTDocument doc = serializer.read(CTDocument.class, new ByteArrayInputStream(data), false);
Garbage collector is running more frequently and taking so much time to complete the parser....
Some sample code
@Root(name="document")
public class CTDocument extends CTDocumentBase
{
@Element
private CTBody body;
public CTBody getBody() {
return body;
}
@Validate
public void validate() {
System.out.println(" CTDocument @Validate ***********************");
}
}
public class CTDocumentBase
{
@Element(name="background", required=false)
private CTBackground background;
public CTBackground getBackground() {
return background;
}
}
public class CTBody
{
@ElementListUnion ( {
@ElementList(entry="p", inline=true, type=CTP.class, required = false),
@ElementList(entry="tbl", inline=true, type=CTTbl.class, required = false)
})
List<WordXMLTagsOperation> operations;
@Element(required=false)
private CTSectPr sectPr;
public List<WordXMLTagsOperation> getOperations() {
return operations;
}
public CTSectPr getSectPr() {
return sectPr;
}
@Validate
public void validate() {
System.out.println(" CTBody @Validate ***********************");
}
}
public class CTP extends EGPContent implements WordXMLTagsOperation
{
@Attribute(required=false)
private String rsidRPr;
@Attribute(required=false)
private String rsidR;
@Attribute(required=false)
private String rsidDel;
@Attribute(required=false)
private String rsidP;
@Attribute(required=false)
private String rsidRDefault;
@Element(name="pPr", required=false)
private CTPPr PPr;
public CTPPr getPPr() {
return PPr;
}
public String getRsidRPr() {
return rsidRPr;
}
public String getRsidR() {
return rsidR;
}
public String getRsidDel() {
return rsidDel;
}
public String getRsidP() {
return rsidP;
}
public String getRsidRDefault() {
return rsidRDefault;
}
@Validate
public void validate() {
System.out.println(" CTP @Validate ***********************");
}
}
public class EGPContent
{
@ElementListUnion({
@ElementList(entry="r", inline=true, type=CTR.class, required = false),
@ElementList(entry="hyperlink", inline=true, type=CTHyperlink.class, required = false),
@ElementList(entry="subDoc", inline=true, type=CTRel.class, required = false),
@ElementList(entry="customXml", inline=true, type=CTCustomXmlRun.class, required = false),
@ElementList(entry="smartTag", inline=true, type=CTSmartTagRun.class, required = false),
@ElementList(entry="fldSimple", inline=true, type=CTSimpleField.class, required = false),
@ElementList(entry="sdt", inline=true, type=CTSdtRun.class, required = false)
})
List<WordXMLTagsOperation>PContentList;
public List<WordXMLTagsOperation> getOperations() {
return PContentList;
}
}
I will send the remaining part in the following mail, as the Simple mailing list is not allowing to send more than 40kp body size
Regards,
Jebarlin |
|
From: Niall G. <gal...@ya...> - 2011-10-12 07:31:54
|
Take a look at the tutorial, its very easy, also take a look at the test cases. ________________________________ From: Babu prasad <bab...@gm...> To: sim...@li... Sent: Tuesday, 20 September 2011 12:16 PM Subject: [Simple-support] Re lated annotation for @XmlSchemaType in simple-xml in jaxb: @XmlAttribute(name = "modified_dtt") @XmlSchemaType(name = "dateTime") protected XMLGregorianCalendar modifiedDtt; how to convert it into simple-xml or how to write a Tranformer class for this -- View this message in context: http://old.nabble.com/Related-annotation-for-%40XmlSchemaType-in-simple-xml-tp32501060p32501060.html Sent from the Simple XML Serialization mailing list archive at Nabble.com. ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Niall G. <gal...@ya...> - 2011-10-12 07:29:18
|
I have no idea what is wrong, is there an exception stack trace? Is there any information associated? ________________________________ From: "da...@al..." <da...@al...> To: sim...@li... Sent: Wednesday, 28 September 2011 9:32 AM Subject: [Simple-support] simple not working on android device Hi all, I'm using Simple 2.6.1 on an Android project for serialize some complex xml files. I use Eclipse and followed the procedure described on the project site (Simple XML in Android 1.5 and Up): 1) created the "libs" folder on the project root 2) put simple-xml-2.6.1.jar in the "libs" folder 3) added the jar to the build path 4) selected for export on the build path All works fine when I run the application on the android emulator. But when I install the application on the device I get a crash at the time of serialization. What's wrong? P.S. I'm developing with android api level 8 (android 2.2) ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Niall G. <gal...@ya...> - 2011-10-12 07:27:10
|
I am afraid ordering is not maintained when you get declaed methods. Not sure why, however the Class file will not contain ordered entries. I realise you looked at the class file, but still the values do not come out ordered. If you can manage to get them in declaration order let me know how u did it. ________________________________ From: Chandra Mohan <bsc...@ms...> To: sim...@li... Sent: Thursday, 29 September 2011 6:13 AM Subject: [Simple-support] order of elements not preserved? Hi All, I am using SimpleXml 2.6.1 in my android app. Eventhough the document says the order of the elements in the xml are same as the way they have defined in the class file, I am always getting the order to be random in the xml. If I add few more variables, the order of the elements again changes. Adding @Order notation works, but since the class is complex with 100s of variables, I do not want to add order. Is this a known bug for android versions? p.s: I opened the .class file disassembled and found the variables declared in the same order as java file, so I don't think it's a class file issue. Warm Regards, Chandra ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Niall G. <gal...@ya...> - 2011-10-12 07:24:10
|
Thanks for the feedback, glad you found the framework so useful. ________________________________ From: --sowdri-- <so...@gm...> To: sim...@li... Sent: Saturday, 8 October 2011 12:26 PM Subject: [Simple-support] Thank you note! Hi Simple Team, First of all, I'm not sure whether I can send feedback on the mailing list, searched on the site but couldn't find some sort of feedback section. Simple is a wonderful idea and the way its has been implemented is awesome! Many thanks for Simple Team and special thanks for the designers to have come up with an intuitive and natural way of expressing the relationship! I could imagine the amount of code that could have been save if I had come across simple-framework an year ago! SimpleFramework rocks! -- -sowdri- ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support |