simple-support Mailing List for Simple (Page 64)
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: <Nia...@ub...> - 2009-06-15 08:42:11
|
Hi, You can not serialize an array of ArrayList objects. Each Collection declaration needs to be annotated with @ElementList. You are probably annotating with @ElementArray or @Element. Niall -----Original Message----- From: meghiddo [mailto:mat...@ho...] Sent: 14 June 2009 22:54 To: sim...@li... Subject: Re: [Simple-support] Cant convert java.util.arrayList?!!?! meghiddo wrote: > > I was so close to finally having this working. WHen i ran my methods > I got this though: > > org.simpleframework.xml.transform.TransformException: Transform of > class [Ljava.util.ArrayList; not supported > > and my xml file came out only partly finished: > > <measurementProjectCollection> > <measurementProject> > <projectId>wsnPondMeasurements</projectId> > <name>WSN Pond Measurements</name> > > It cut off everything after that which was: > > <permissions class="java.util.ArrayList" /> > <devices class="java.util.ArrayList" /> > <channels class="java.util.ArrayList" /> > </measurementProject> > <measurementProject> > <projectId>exampleProject1</projectId> > <name>exampleProject1</name> > <permissions class="java.util.ArrayList" /> > <devices class="java.util.ArrayList" /> > <channels class="java.util.ArrayList" /> > </measurementProject> > </measurementProjectCollection> > > So apparently it does not want to put the permissions, devices, or > channels tags into xml form. > > Please tell me there is a way around this, my project is so close to > working, I just need to get that xml converted to an xml file! > nothing at all? It seems like a pretty straightforward question, is it possible to use "ArrayList[] devices;" to in the xml output? -- View this message in context: http://www.nabble.com/Cant-convert-java.util.arrayList-%21%21-%21-tp2393 3276p24026131.html Sent from the Simple XML Serialization mailing list archive at Nabble.com. ------------------------------------------------------------------------ ------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Simple-support mailing list Sim...@li... https://lists.sourceforge.net/lists/listinfo/simple-support Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company registered in England & Wales under company number 2035362, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS AG (London Branch) is registered as a branch of a foreign company under number BR004507, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS Clearing and Execution Services Limited is a company registered in England & Wales under company number 03123037, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS reserves the right to retain all messages. Messages are protected and accessed only in legally justified cases. |
|
From: meghiddo <mat...@ho...> - 2009-06-14 21:53:57
|
meghiddo wrote: > > I was so close to finally having this working. WHen i ran my methods I > got this though: > > org.simpleframework.xml.transform.TransformException: Transform of class > [Ljava.util.ArrayList; not supported > > and my xml file came out only partly finished: > > <measurementProjectCollection> > <measurementProject> > <projectId>wsnPondMeasurements</projectId> > <name>WSN Pond Measurements</name> > > It cut off everything after that which was: > > <permissions class="java.util.ArrayList" /> > <devices class="java.util.ArrayList" /> > <channels class="java.util.ArrayList" /> > </measurementProject> > <measurementProject> > <projectId>exampleProject1</projectId> > <name>exampleProject1</name> > <permissions class="java.util.ArrayList" /> > <devices class="java.util.ArrayList" /> > <channels class="java.util.ArrayList" /> > </measurementProject> > </measurementProjectCollection> > > So apparently it does not want to put the permissions, devices, or > channels tags into xml form. > > Please tell me there is a way around this, my project is so close to > working, I just need to get that xml converted to an xml file! > nothing at all? It seems like a pretty straightforward question, is it possible to use "ArrayList[] devices;" to in the xml output? -- View this message in context: http://www.nabble.com/Cant-convert-java.util.arrayList-%21%21-%21-tp23933276p24026131.html Sent from the Simple XML Serialization mailing list archive at Nabble.com. |
|
From: meghiddo <mat...@ho...> - 2009-06-08 22:27:44
|
I was so close to finally having this working. WHen i ran my methods I got
this though:
org.simpleframework.xml.transform.TransformException: Transform of class
[Ljava.util.ArrayList; not supported
and my xml file came out only partly finished:
<measurementProjectCollection>
<measurementProject>
<projectId>wsnPondMeasurements</projectId>
<name>WSN Pond Measurements</name>
It cut off everything after that which was:
<permissions class="java.util.ArrayList" />
<devices class="java.util.ArrayList" />
<channels class="java.util.ArrayList" />
</measurementProject>
<measurementProject>
<projectId>exampleProject1</projectId>
<name>exampleProject1</name>
<permissions class="java.util.ArrayList" />
<devices class="java.util.ArrayList" />
<channels class="java.util.ArrayList" />
</measurementProject>
</measurementProjectCollection>
So apparently it does not want to put the permissions, devices, or channels
tags into xml form.
Please tell me there is a way around this, my project is so close to
working, I just need to get that xml converted to an xml file!
--
View this message in context: http://www.nabble.com/Cant-convert-java.util.arrayList-%21%21-%21-tp23933276p23933276.html
Sent from the Simple XML Serialization mailing list archive at Nabble.com.
|
|
From: meghiddo <mat...@ho...> - 2009-06-08 22:10:57
|
Just to update, I messed around with things and I can get an xml file, but
when I open it all it contains it this:
<string><?xml version="1.0" encoding="UTF-8"?>
<deviceCollection>
<device>
<deviceId>exampleDevice1</deviceId>
<name>Example Device 1</name>
</device>
<device>
<deviceId>WSN-Module-8F3A-D247-4B99</deviceId>
<name>WSN CRio Device</name>
</device>
</deviceCollection></string>
Not exactly what I need eh? Closer I hope though
--
View this message in context: http://www.nabble.com/Need-to-use-simple-to-write-an-inputStream-to-some-useable-xml-form-tp23931939p23933034.html
Sent from the Simple XML Serialization mailing list archive at Nabble.com.
|
|
From: meghiddo <mat...@ho...> - 2009-06-08 20:53:21
|
SO I have a method that uses httpclient to get data from a web service. The
data is stored on the web service in an xml format. I can use httpclient
getMethod to retrieve this xml either as a stream or a string.
So I have that data stored in a varable, called responseBody.
Now I need to convert that into xml form. If I try to add the current value
of responseBody to a list (when it is a String) the list does print out the
data and it does look like xml. But for some reason it is not being
recognized as xml. It is being recognized as a String, and even though that
String looks like xml, it is not being recognized as such ny a rich:tree
The final goal is to somehow bind this xml to a list (or some other possible
value), which I can then bind to a richfaces tree through a backing bean.
So here is my method that gets the responseBody from the web service:
public void load(){
// Create an instance of HttpClient.
HttpClient client = new HttpClient();
SimpleXml access = new SimpleXml();
// Create a method instance.
GetMethod method = new GetMethod(devicesUrl);
InputStream responseBody = null;
try {
// Execute the method.
int statusCode = client.executeMethod(method);
//System.out.println( method.getStatusCode());
if (statusCode != HttpStatus.SC_OK) {
System.out.println("Method failed: " + method.getStatusLine());
}
// Read the response body.
responseBody = method.getResponseBodyAsStream();
//System.out.println("printing current value of
method.getResponseBodyAsString from httpclient class "+
//method.getResponseBodyAsString());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("printing InputStream responseBody from httpclient
class: " + responseBody.toString());
}
This seems to be working OK. Through various tests I have been able to
print out the value of resposeBody and it does return this:
<?xml version="1.0" encoding="UTF-8"?>
<deviceCollection>
<device>
<deviceId>exampleDevice1</deviceId>
<name>Example Device 1</name>
</device>
<device>
<deviceId>WSN-Module-8F3A-D247-4B99</deviceId>
<name>WSN CRio Device</name>
</device>
</deviceCollection>
That is if I get responseBody as a String. If I get responseBody as a
stream, I cant print out the value but I am guessing it would be the same,
just in a stream form right? If I try to print it as a Stream it gives me
some odd print out that doesnt mean much, I just know it does not mean null.
So assuming that is true, I have my variable responseBody, either as a
String or Stream depending on what I do, and it holds the xml I printed
above.
Now I need simple to take that data in, and output it in some kind of xml
form that I can use. Although Im not sure what yet...
Like I said, the end goal is to use this xml to populate a rich tree. If I
leave responseBody as a String, and use that to populate the tree it gives
me a one node tree that has all of that xml text on one line...not too
useful.
>From what I understand from the jboss forum, if I can get some form of xml
bound to the rich tree then I can use this line on my jsf page to do what I
need:
<rich:recursiveTreeNodesAdaptor roots="#{recTreeBean.data}" var="item"
nodes="#{item.name}" />
Ideally that will make a nice tree. If that line were to use the xml I
printed from above, the result Im hoping for would be a tree like this:
-exampleDevice1
---Example Device 1
-WSN-Module-8F3A-D247-4B99
---WSN CRio Device
But I just cant get this working,
so any help at all anyone might have would be great. I mean anything, I
have tried all I can think to do, so even if you have help pretaining to the
tree rather than simpleXml that is great
Thanks
--
View this message in context: http://www.nabble.com/Need-to-use-simple-to-write-an-inputStream-to-some-useable-xml-form-tp23931939p23931939.html
Sent from the Simple XML Serialization mailing list archive at Nabble.com.
|
|
From: Niall G. <gal...@ya...> - 2009-06-06 10:52:12
|
Hi,
Send me on your annotated code. So I can see the schema you are using to parse the XML. From the exception it looks like you have annotated the List with either @Element or @Attribute instead of @ElementList.
Niall
--- On Fri, 6/5/09, meghiddo <mat...@ho...> wrote:
> From: meghiddo <mat...@ho...>
> Subject: [Simple-support] had parsing working for strings, but now need to do so for ArrayList
> To: sim...@li...
> Date: Friday, June 5, 2009, 3:32 PM
>
> I had code working that took data from a web service,
> parsed it, and loaded
> the values into a list that I could use in a
> rich:tree. This was working
> just fine when it took the data from this xml:
>
> [code] <?xml version="1.0"
> encoding="UTF-8" ?>
> - <deviceCollection>
> - <device>
> <deviceId>exampleDevice1</deviceId>
> <name>Example Device 1</name>
> </device>
> - <device>
>
> <deviceId>WSN-Module-8F3A-D247-4B99</deviceId>
> <name>WSN CRio Device</name>
> </device>
> </deviceCollection> [/code]
>
> But now I need to convert it to take the data from a
> different xml set up
> that looks like this:
>
> [code] - <measurementProject>
> <projectId>1</projectId>
> <name>matt</name>
> <permissions class="java.util.ArrayList" />
> <devices class="java.util.ArrayList" />
> <channels class="java.util.ArrayList" />
>
> </measurementProject> [/code]
>
> But when I did so I get this exception:
>
> [code]org.simpleframework.xml.core.InstantiationException:
> Type class
> java.util.ArrayList is not compatible with class
> java.lang.String
> at
> org.simpleframework.xml.core.Factory.getOverride(Factory.java:105)
> at
> org.simpleframework.xml.core.PrimitiveFactory.getInstance(PrimitiveFactory.java:66)
> at
> org.simpleframework.xml.core.Primitive.readElement(Primitive.java:181)
> at
> org.simpleframework.xml.core.Primitive.read(Primitive.java:119)
> at
> org.simpleframework.xml.core.Composite.readObject(Composite.java:520)
> at
> org.simpleframework.xml.core.Composite.read(Composite.java:477)
> at
> org.simpleframework.xml.core.Composite.readElement(Composite.java:458)
> at
> org.simpleframework.xml.core.Composite.readElements(Composite.java:374)
> at
> org.simpleframework.xml.core.Composite.read(Composite.java:259)
> at
> org.simpleframework.xml.core.Composite.read(Composite.java:204)
> at
> org.simpleframework.xml.core.Composite.read(Composite.java:158)
> at
> org.simpleframework.xml.core.Composite.read(Composite.java:135)
> at
> org.simpleframework.xml.core.Traverser.read(Traverser.java:78)
> at
> org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:182)
> at
> org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:159)
> at
> org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:117)
> at
> org.simpleframework.xml.core.Composite.readObject(Composite.java:520)
> at
> org.simpleframework.xml.core.Composite.read(Composite.java:477)
> at
> org.simpleframework.xml.core.Composite.readElement(Composite.java:458)
> at
> org.simpleframework.xml.core.Composite.readElements(Composite.java:374)
> at
> org.simpleframework.xml.core.Composite.read(Composite.java:259)
> at
> org.simpleframework.xml.core.Composite.read(Composite.java:204)
> at
> org.simpleframework.xml.core.Composite.read(Composite.java:158)
> at
> org.simpleframework.xml.core.Composite.read(Composite.java:135)
> at
> org.simpleframework.xml.core.Traverser.read(Traverser.java:78)
> at
> org.simpleframework.xml.core.Persister.read(Persister.java:544)
> at
> org.simpleframework.xml.core.Persister.read(Persister.java:526)
> at
> org.simpleframework.xml.core.Persister.read(Persister.java:507)
> at
> org.simpleframework.xml.core.Persister.read(Persister.java:489)
> at
> org.simpleframework.xml.core.Persister.read(Persister.java:471)
> at
> org.simpleframework.xml.core.Persister.read(Persister.java:452)
> at
> projectContainer.MeasurementProjectCollectionXMLAO.readXML(MeasurementProjectCollectionXMLAO.java:17)
> at
> testContainer.ProjectTreeTest.loadProjectNodes(ProjectTreeTest.java:34)
> at
> testContainer.TempMain.main(TempMain.java:11)
> [/code]
>
> So it is obvious that ther is a problem with parsing this
> new xml due to the
> fact it has these three lines:
>
> [code] <permissions
> class="java.util.ArrayList" />
> <devices class="java.util.ArrayList" />
> <channels class="java.util.ArrayList" />
> [/code]
>
> Things were fine when it was only parsing Strings, but
> there is a problem
> with the parsing of the ArrayLists.
> I'm not sure where to look to find the problem and how to
> solve it honestly.
> If I were to guess I would say there will need to be a
> change made to:
>
> [code]public class MeasurementProjectCollectionXMLAO {
>
> public MeasurementProjectCollection
> readXML(InputStream xml) {
> Serializer serializer =
> new Persister();
>
>
> MeasurementProjectCollection measurementProjectCollection =
> null;
> try {
>
> measurementProjectCollection =
> serializer.read(MeasurementProjectCollection.class, xml);
> } catch (Exception e)
> {
> //
> TODO Auto-generated catch block
>
> e.printStackTrace();
> }
> try {
>
> xml.close();
> } catch (IOException
> e) {
> //
> TODO Auto-generated catch block
>
> e.printStackTrace();
> }
> return
> measurementProjectCollection;
> } [/code]
>
>
> But I really do not know where. If it is any help,
> here is the class that
> calls the xml parser, and then loads the values to a
> list.
>
>
> [code]public void loadProjectNodes() {
>
>
>
> MeasurementProjectCollectionXMLAO access = new
> MeasurementProjectCollectionXMLAO();
> ProjectHttpClient
> method = new ProjectHttpClient();
> MeasurementProjectCollection
> measurementProjectCollection = null;
>
>
>
> try {
>
> measurementProjectCollection =
> access.readXML(method.Response(null));
> }
> catch (Exception e) {
>
> // TODO Auto-generated catch block
>
> e.printStackTrace();
> }
>
>
>
> //System.out.println("printing deviceCollection =
> access.readXML(method.getResponseBodyAsStream(null));: "
>
> //+ deviceCollection.toString());
>
>
> for
> (MeasurementProject measurementProject :
> measurementProjectCollection.getMeasurementProjects()){
> String
> x = measurementProject.getName();
>
> projectNameList.add(x);
>
> //System.out.println(ids);
> }
>
>
> }
>
> public List<String>
> getProjectNameList() {
> //loadNodes();
> return
> projectNameList;
> }
>
> public void
> setProjectnameList(List<String>
> projectNameList) {
> this.projectNameList
> = projectNameList;
> }
>
> public void print(){
>
> System.out.println("Printing projectNameList values:
> "+projectNameList);
> }
> } [/code]
>
> As soon as I try to call loadProjectNodes I get that
> exception though.
>
> I have to get this working by Tuesday. May seem like
> plenty of time but
> with my track record on these kind of things...
> --
> View this message in context: http://www.nabble.com/had-parsing-working-for-strings%2C-but-now-need-to-do-so-for-ArrayList-tp23896552p23896552.html
> Sent from the Simple XML Serialization mailing list archive
> at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> OpenSolaris 2009.06 is a cutting edge operating system for
> enterprises
> looking to deploy the next generation of Solaris that
> includes the latest
> innovations from Sun and the OpenSource community. Download
> a copy and
> enjoy capabilities such as Networking, Storage and
> Virtualization.
> Go to: http://p.sf.net/sfu/opensolaris-get
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
|
|
From: meghiddo <mat...@ho...> - 2009-06-06 06:54:51
|
I resolved this on my own
In my measurementProject class I had declarations for devices, permissions,
and channels (the three that were giving me trouble) but I had them declared
as Strings instead of an ArrayList. I changed that, and then I had one
other problem, but all I had to do was change my properties field from
required=true to required=false, and it worked immediately.
The way I figred it out was, I just played around with that readXml method,
by erasing methods that came after a period,
Then I would hit the period so it would pop up with the list of all possible
methods, along with descriptions of what they did, and I read through those.
In doing so I got a better understanding of how simplexml works, and then
the idea just came to me (after reading through a few more lines in the
stack).
meghiddo wrote:
>
> I had code working that took data from a web service, parsed it, and
> loaded the values into a list that I could use in a rich:tree. This was
> working just fine when it took the data from this xml:
>
> [code] <?xml version="1.0" encoding="UTF-8" ?>
> - <deviceCollection>
> - <device>
> <deviceId>exampleDevice1</deviceId>
> <name>Example Device 1</name>
> </device>
> - <device>
> <deviceId>WSN-Module-8F3A-D247-4B99</deviceId>
> <name>WSN CRio Device</name>
> </device>
> </deviceCollection> [/code]
>
> But now I need to convert it to take the data from a different xml set up
> that looks like this:
>
> [code] - <measurementProject>
> <projectId>1</projectId>
> <name>matt</name>
> <permissions class="java.util.ArrayList" />
> <devices class="java.util.ArrayList" />
> <channels class="java.util.ArrayList" />
> </measurementProject> [/code]
>
> But when I did so I get this exception:
>
> [code]org.simpleframework.xml.core.InstantiationException: Type class
> java.util.ArrayList is not compatible with class java.lang.String
> at org.simpleframework.xml.core.Factory.getOverride(Factory.java:105)
> at
> org.simpleframework.xml.core.PrimitiveFactory.getInstance(PrimitiveFactory.java:66)
> at org.simpleframework.xml.core.Primitive.readElement(Primitive.java:181)
> at org.simpleframework.xml.core.Primitive.read(Primitive.java:119)
> at org.simpleframework.xml.core.Composite.readObject(Composite.java:520)
> at org.simpleframework.xml.core.Composite.read(Composite.java:477)
> at org.simpleframework.xml.core.Composite.readElement(Composite.java:458)
> at
> org.simpleframework.xml.core.Composite.readElements(Composite.java:374)
> at org.simpleframework.xml.core.Composite.read(Composite.java:259)
> at org.simpleframework.xml.core.Composite.read(Composite.java:204)
> at org.simpleframework.xml.core.Composite.read(Composite.java:158)
> at org.simpleframework.xml.core.Composite.read(Composite.java:135)
> at org.simpleframework.xml.core.Traverser.read(Traverser.java:78)
> at
> org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:182)
> at
> org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:159)
> at
> org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:117)
> at org.simpleframework.xml.core.Composite.readObject(Composite.java:520)
> at org.simpleframework.xml.core.Composite.read(Composite.java:477)
> at org.simpleframework.xml.core.Composite.readElement(Composite.java:458)
> at
> org.simpleframework.xml.core.Composite.readElements(Composite.java:374)
> at org.simpleframework.xml.core.Composite.read(Composite.java:259)
> at org.simpleframework.xml.core.Composite.read(Composite.java:204)
> at org.simpleframework.xml.core.Composite.read(Composite.java:158)
> at org.simpleframework.xml.core.Composite.read(Composite.java:135)
> at org.simpleframework.xml.core.Traverser.read(Traverser.java:78)
> at org.simpleframework.xml.core.Persister.read(Persister.java:544)
> at org.simpleframework.xml.core.Persister.read(Persister.java:526)
> at org.simpleframework.xml.core.Persister.read(Persister.java:507)
> at org.simpleframework.xml.core.Persister.read(Persister.java:489)
> at org.simpleframework.xml.core.Persister.read(Persister.java:471)
> at org.simpleframework.xml.core.Persister.read(Persister.java:452)
> at
> projectContainer.MeasurementProjectCollectionXMLAO.readXML(MeasurementProjectCollectionXMLAO.java:17)
> at
> testContainer.ProjectTreeTest.loadProjectNodes(ProjectTreeTest.java:34)
> at testContainer.TempMain.main(TempMain.java:11) [/code]
>
> So it is obvious that ther is a problem with parsing this new xml due to
> the fact it has these three lines:
>
> [code] <permissions class="java.util.ArrayList" />
> <devices class="java.util.ArrayList" />
> <channels class="java.util.ArrayList" />
> [/code]
>
> Things were fine when it was only parsing Strings, but there is a problem
> with the parsing of the ArrayLists.
> I'm not sure where to look to find the problem and how to solve it
> honestly.
> If I were to guess I would say there will need to be a change made to:
>
> [code]public class MeasurementProjectCollectionXMLAO {
>
> public MeasurementProjectCollection readXML(InputStream xml) {
> Serializer serializer = new Persister();
>
> MeasurementProjectCollection measurementProjectCollection = null;
> try {
> measurementProjectCollection =
> serializer.read(MeasurementProjectCollection.class, xml);
> } catch (Exception e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> try {
> xml.close();
> } catch (IOException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> return measurementProjectCollection;
> } [/code]
>
>
> But I really do not know where. If it is any help, here is the class that
> calls the xml parser, and then loads the values to a list.
>
>
> [code]public void loadProjectNodes() {
>
> MeasurementProjectCollectionXMLAO access = new
> MeasurementProjectCollectionXMLAO();
> ProjectHttpClient method = new ProjectHttpClient();
> MeasurementProjectCollection measurementProjectCollection = null;
>
>
> try {
> measurementProjectCollection = access.readXML(method.Response(null));
> } catch (Exception e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
>
> //System.out.println("printing deviceCollection =
> access.readXML(method.getResponseBodyAsStream(null));: "
> //+ deviceCollection.toString());
>
> for (MeasurementProject measurementProject :
> measurementProjectCollection.getMeasurementProjects()){
> String x = measurementProject.getName();
> projectNameList.add(x);
> //System.out.println(ids);
> }
>
> }
>
> public List<String> getProjectNameList() {
> //loadNodes();
> return projectNameList;
> }
>
> public void setProjectnameList(List<String> projectNameList) {
> this.projectNameList = projectNameList;
> }
>
> public void print(){
> System.out.println("Printing projectNameList values: "+projectNameList);
> }
> } [/code]
>
> As soon as I try to call loadProjectNodes I get that exception though.
>
> I have to get this working by Tuesday. May seem like plenty of time but
> with my track record on these kind of things...
>
--
View this message in context: http://www.nabble.com/had-parsing-working-for-strings%2C-but-now-need-to-do-so-for-ArrayList-tp23896552p23899261.html
Sent from the Simple XML Serialization mailing list archive at Nabble.com.
|
|
From: meghiddo <mat...@ho...> - 2009-06-05 22:32:46
|
I had code working that took data from a web service, parsed it, and loaded
the values into a list that I could use in a rich:tree. This was working
just fine when it took the data from this xml:
[code] <?xml version="1.0" encoding="UTF-8" ?>
- <deviceCollection>
- <device>
<deviceId>exampleDevice1</deviceId>
<name>Example Device 1</name>
</device>
- <device>
<deviceId>WSN-Module-8F3A-D247-4B99</deviceId>
<name>WSN CRio Device</name>
</device>
</deviceCollection> [/code]
But now I need to convert it to take the data from a different xml set up
that looks like this:
[code] - <measurementProject>
<projectId>1</projectId>
<name>matt</name>
<permissions class="java.util.ArrayList" />
<devices class="java.util.ArrayList" />
<channels class="java.util.ArrayList" />
</measurementProject> [/code]
But when I did so I get this exception:
[code]org.simpleframework.xml.core.InstantiationException: Type class
java.util.ArrayList is not compatible with class java.lang.String
at org.simpleframework.xml.core.Factory.getOverride(Factory.java:105)
at
org.simpleframework.xml.core.PrimitiveFactory.getInstance(PrimitiveFactory.java:66)
at org.simpleframework.xml.core.Primitive.readElement(Primitive.java:181)
at org.simpleframework.xml.core.Primitive.read(Primitive.java:119)
at org.simpleframework.xml.core.Composite.readObject(Composite.java:520)
at org.simpleframework.xml.core.Composite.read(Composite.java:477)
at org.simpleframework.xml.core.Composite.readElement(Composite.java:458)
at org.simpleframework.xml.core.Composite.readElements(Composite.java:374)
at org.simpleframework.xml.core.Composite.read(Composite.java:259)
at org.simpleframework.xml.core.Composite.read(Composite.java:204)
at org.simpleframework.xml.core.Composite.read(Composite.java:158)
at org.simpleframework.xml.core.Composite.read(Composite.java:135)
at org.simpleframework.xml.core.Traverser.read(Traverser.java:78)
at
org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:182)
at
org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:159)
at
org.simpleframework.xml.core.CompositeInlineList.read(CompositeInlineList.java:117)
at org.simpleframework.xml.core.Composite.readObject(Composite.java:520)
at org.simpleframework.xml.core.Composite.read(Composite.java:477)
at org.simpleframework.xml.core.Composite.readElement(Composite.java:458)
at org.simpleframework.xml.core.Composite.readElements(Composite.java:374)
at org.simpleframework.xml.core.Composite.read(Composite.java:259)
at org.simpleframework.xml.core.Composite.read(Composite.java:204)
at org.simpleframework.xml.core.Composite.read(Composite.java:158)
at org.simpleframework.xml.core.Composite.read(Composite.java:135)
at org.simpleframework.xml.core.Traverser.read(Traverser.java:78)
at org.simpleframework.xml.core.Persister.read(Persister.java:544)
at org.simpleframework.xml.core.Persister.read(Persister.java:526)
at org.simpleframework.xml.core.Persister.read(Persister.java:507)
at org.simpleframework.xml.core.Persister.read(Persister.java:489)
at org.simpleframework.xml.core.Persister.read(Persister.java:471)
at org.simpleframework.xml.core.Persister.read(Persister.java:452)
at
projectContainer.MeasurementProjectCollectionXMLAO.readXML(MeasurementProjectCollectionXMLAO.java:17)
at testContainer.ProjectTreeTest.loadProjectNodes(ProjectTreeTest.java:34)
at testContainer.TempMain.main(TempMain.java:11) [/code]
So it is obvious that ther is a problem with parsing this new xml due to the
fact it has these three lines:
[code] <permissions class="java.util.ArrayList" />
<devices class="java.util.ArrayList" />
<channels class="java.util.ArrayList" />
[/code]
Things were fine when it was only parsing Strings, but there is a problem
with the parsing of the ArrayLists.
I'm not sure where to look to find the problem and how to solve it honestly.
If I were to guess I would say there will need to be a change made to:
[code]public class MeasurementProjectCollectionXMLAO {
public MeasurementProjectCollection readXML(InputStream xml) {
Serializer serializer = new Persister();
MeasurementProjectCollection measurementProjectCollection = null;
try {
measurementProjectCollection =
serializer.read(MeasurementProjectCollection.class, xml);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
xml.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return measurementProjectCollection;
} [/code]
But I really do not know where. If it is any help, here is the class that
calls the xml parser, and then loads the values to a list.
[code]public void loadProjectNodes() {
MeasurementProjectCollectionXMLAO access = new
MeasurementProjectCollectionXMLAO();
ProjectHttpClient method = new ProjectHttpClient();
MeasurementProjectCollection measurementProjectCollection = null;
try {
measurementProjectCollection = access.readXML(method.Response(null));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//System.out.println("printing deviceCollection =
access.readXML(method.getResponseBodyAsStream(null));: "
//+ deviceCollection.toString());
for (MeasurementProject measurementProject :
measurementProjectCollection.getMeasurementProjects()){
String x = measurementProject.getName();
projectNameList.add(x);
//System.out.println(ids);
}
}
public List<String> getProjectNameList() {
//loadNodes();
return projectNameList;
}
public void setProjectnameList(List<String> projectNameList) {
this.projectNameList = projectNameList;
}
public void print(){
System.out.println("Printing projectNameList values: "+projectNameList);
}
} [/code]
As soon as I try to call loadProjectNodes I get that exception though.
I have to get this working by Tuesday. May seem like plenty of time but
with my track record on these kind of things...
--
View this message in context: http://www.nabble.com/had-parsing-working-for-strings%2C-but-now-need-to-do-so-for-ArrayList-tp23896552p23896552.html
Sent from the Simple XML Serialization mailing list archive at Nabble.com.
|
|
From: Niall G. <gal...@ya...> - 2009-05-30 11:45:10
|
Hi,
This should work for your XML.
@Root
class DeviceCollection{
@ElementList(inline=true)
private Collection<Device> list;
@Root
private static class Device {
@Element String deviceId;
@Element String name;
}
public Collection<Device> getDeviceCollection() {
return list;
}
}
Niall
--- On Thu, 5/28/09, meghiddo <mat...@ho...> wrote:
> From: meghiddo <mat...@ho...>
> Subject: [Simple-support] How to parse xml into objects I can use to build a richfaces tree?
> To: sim...@li...
> Date: Thursday, May 28, 2009, 7:21 AM
>
> There has to be a way to do this!! I need java code that
> will
>
> 1 - look at this xml schema
> 2 - take whatever the text node value is for
> <deviceId> and set it equal to
> String device; or treenode device;
>
> It seems so simple, but I just cant seem to do it!!
>
>
>
> The xml looks like this:
>
> [code]<deviceCollection>
> <device>
>
> <deviceId>exampleDevice1</deviceId>
> <name>Example Device
> 1</name>
> </device>
> </deviceCollection>[/code]
>
> I have a readXml method already:
>
> [code]public DeviceCollection readXML(InputStream xml)
> throws Exception {
> Serializer serializer = new
> Persister();
>
> DeviceCollection
> deviceCollection = null;
> deviceCollection =
> serializer.read(DeviceCollection.class, xml);
> xml.close();
> return deviceCollection;
>
> }
> [/code]
>
> And here is my method where I am attempting to bind this
> data:
>
> [code]static String devicesUrl =
> "http://webc-apps.ni.com/measure/1.01/devices";
>
> public static void updateNode() throws
> IOException, Exception {
>
> // Create an instance of
> HttpClient.
> HttpClient client =
> new HttpClient();
>
> // Create a method
> instance.
> GetMethod method =
> new GetMethod(devicesUrl);
>
> XMLTreeDataBuilderTest node =
> new XMLTreeDataBuilderTest();
> DeviceCollectionXMLAO access =
> new DeviceCollectionXMLAO();
> DeviceCollection
> deviceCollection;
>
>
> deviceCollection =
> access.readXML(method.getResponseBodyAsStream());
>
> [/code]
>
> I am not sure where I am going wrong here. All I
> really know is I am
> needing to take the values from the deviceid node and name
> node, and bind
> them to something which I can then use in my jsf page to
> build a tree.
> It has to be dynamic as well, because that xml from the top
> is going to be
> different depending on the user..
> please help, Ive been at this for a week and havent made
> much progress
> --
> View this message in context: http://www.nabble.com/How-to-parse-xml-into-objects-I-can-use-to-build-a-richfaces-tree--tp23762343p23762343.html
> Sent from the Simple XML Serialization mailing list archive
> at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd,
> NYC. CaT
> is a gathering of tech-side developers & brand
> creativity professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity,
> Processing, &
> iPhoneDevCamp as they present alongside digital
> heavyweights like Barbarian
> Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
|
|
From: meghiddo <mat...@ho...> - 2009-05-28 14:12:14
|
The xml looks like this:
[code]<deviceCollection>
<device>
<deviceId>exampleDevice1</deviceId>
<name>Example Device 1</name>
</device>
</deviceCollection>[/code]
I have a readXml method already:
[code]public DeviceCollection readXML(InputStream xml) throws Exception {
Serializer serializer = new Persister();
DeviceCollection deviceCollection = null;
deviceCollection = serializer.read(DeviceCollection.class, xml);
xml.close();
return deviceCollection;
}
[/code]
And here is my method where I am attempting to bind this data:
[code]static String devicesUrl =
"http://webc-apps.ni.com/measure/1.01/devices";
public static void updateNode() throws IOException, Exception {
// Create an instance of HttpClient.
HttpClient client = new HttpClient();
// Create a method instance.
GetMethod method = new GetMethod(devicesUrl);
XMLTreeDataBuilderTest node = new XMLTreeDataBuilderTest();
DeviceCollectionXMLAO access = new DeviceCollectionXMLAO();
DeviceCollection deviceCollection;
deviceCollection = access.readXML(method.getResponseBodyAsStream());
[/code]
I am not sure where I am going wrong here. All I really know is I am
needing to take the values from the deviceid node and name node, and bind
them to something which I can then use in my jsf page to build a tree.
It has to be dynamic as well, because that xml from the top is going to be
different depending on the user..
please help, Ive been at this for a week and havent made much progress
--
View this message in context: http://www.nabble.com/How-to-parse-xml-into-objects-I-can-use-to-build-a-richfaces-tree--tp23762343p23762343.html
Sent from the Simple XML Serialization mailing list archive at Nabble.com.
|
|
From: Niall G. <gal...@ya...> - 2009-05-26 16:07:18
|
Hi,
This is caused by StAX rather than Simple. There may be a StAX implementation that does not use a buffering input stream out there, perhaps the Woodstox StAX implementation? Also you could create a single root and write all nodes as children of that root. If none of these are satisfactory then you will have to wrap the input stream in something that will give all bytes up to the final element. I might add this to the org.simpleframework.xml.util package myself as others have asked the same.
Regards,
Niall
--- On Tue, 5/26/09, Niklas Hag <nik...@ni...> wrote:
> From: Niklas Hag <nik...@ni...>
> Subject: [Simple-support] Streaming root elements
> To: sim...@li...
> Date: Tuesday, May 26, 2009, 5:59 AM
> Hi,
> I'm new at this - and I'm probably doin' some trivial
> error.
>
> I have a very simple implementation and I like to put some
> Simple-java
> classes on a stream, in sequence.
>
> In the below example the XML is put on a stream and I would
> have hoped that
> the persister should manage to parse the stream as several
> sequential XML
> root nodes (i.e. AnnotatedTestClass instances)
> But the first invocation of persister.read(clazz,
> inputStream) empties the
> stream but however just one object is returned.
> The next attempt to invoke the method will block,
> naturally.
>
> How do I get around this? Is it possible or have I
> misunderstood the usage
> of stream as input?
>
>
> Many thanks in advance
>
> - Niklas
>
>
> // XML is
> "<annotatedTestClass>
> <num>77</num>
> <name>test1</name>
> </annotatedTestClass><annotatedTestClass>
> <num>77</num>
> <name>test1</name>
> </annotatedTestClass><annotatedTestClass>
> <num>77</num>
> <name>test1</name>
> </annotatedTestClass>"
>
> // Sample code
> persister = new org.simpleframework.xml.core.Persister();
> for (int iter=0; iter<3; iter++) {
> AnnotatedTestClass obj2 =
> (AnnotatedTestClass)persister.read(AnnotatedTestClass.class,
> inputStream);
> // etc ...
> }
>
>
> // Class impl
> @Root(strict=false)
> public class AnnotatedTestClass {
>
> public AnnotatedTestClass() {
> }
>
> @Element(required=false)
> private Integer num;
>
> @Element(required=false)
> private String name;
>
> public Integer getNum() {
> return num;
> }
>
> public void setNum(Integer num) {
> this.num = num;
> }
>
> public String getName() {
> return name;
> }
>
> public void setName(String name) {
> this.name = name;
> }
>
> @Override
> public boolean equals(Object obj) {
> AnnotatedTestClass
> other = (AnnotatedTestClass)obj;
> boolean eq =
> Equals.equals(this.num, other.getNum());
> eq &=
> Equals.equals(this.name, other.getName());
> return eq;
> }
>
>
>
>
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd,
> NYC. CaT
> is a gathering of tech-side developers & brand
> creativity professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity,
> Processing, &
> iPhoneDevCamp asthey present alongside digital heavyweights
> like Barbarian
> Group, R/GA, & Big Spaceship. http://www.creativitycat.com
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
|
|
From: Niklas H. <nik...@ni...> - 2009-05-26 12:59:34
|
Hi,
I'm new at this - and I'm probably doin' some trivial error.
I have a very simple implementation and I like to put some Simple-java
classes on a stream, in sequence.
In the below example the XML is put on a stream and I would have hoped that
the persister should manage to parse the stream as several sequential XML
root nodes (i.e. AnnotatedTestClass instances)
But the first invocation of persister.read(clazz, inputStream) empties the
stream but however just one object is returned.
The next attempt to invoke the method will block, naturally.
How do I get around this? Is it possible or have I misunderstood the usage
of stream as input?
Many thanks in advance
- Niklas
// XML is
"<annotatedTestClass>
<num>77</num>
<name>test1</name>
</annotatedTestClass><annotatedTestClass>
<num>77</num>
<name>test1</name>
</annotatedTestClass><annotatedTestClass>
<num>77</num>
<name>test1</name>
</annotatedTestClass>"
// Sample code
persister = new org.simpleframework.xml.core.Persister();
for (int iter=0; iter<3; iter++) {
AnnotatedTestClass obj2 =
(AnnotatedTestClass)persister.read(AnnotatedTestClass.class, inputStream);
// etc ...
}
// Class impl
@Root(strict=false)
public class AnnotatedTestClass {
public AnnotatedTestClass() {
}
@Element(required=false)
private Integer num;
@Element(required=false)
private String name;
public Integer getNum() {
return num;
}
public void setNum(Integer num) {
this.num = num;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public boolean equals(Object obj) {
AnnotatedTestClass other = (AnnotatedTestClass)obj;
boolean eq = Equals.equals(this.num, other.getNum());
eq &= Equals.equals(this.name, other.getName());
return eq;
}
|
|
From: Niall G. <gal...@ya...> - 2009-05-22 14:17:56
|
Hi Greg,
Thanks for the feedback, ill take a look in to this.
Niall
--- On Sat, 5/16/09, Greg Cottman <gre...@qu...> wrote:
> From: Greg Cottman <gre...@qu...>
> Subject: [Simple-support] Transform exception on enum in ElementMap
> To: "sim...@li..." <sim...@li...>
> Date: Saturday, May 16, 2009, 3:13 AM
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Hi
> Niall,
>
>
>
>
> I
> am using Simple XML 2.0.4 with Java 1.6.0_04 in a Windows
> XP environment.
>
>
>
>
> I
> have a test program:
>
>
>
>
> package test;
>
>
>
>
> import java.io.File;
>
> import
> java.util.HashMap;
>
> import java.util.Map;
>
>
>
>
> import
> org.simpleframework.xml.ElementMap;
>
> import
> org.simpleframework.xml.Root;
>
> import
> org.simpleframework.xml.Serializer;
>
> import
> org.simpleframework.xml.core.Persister;
>
>
>
>
> public enum Example
>
> {
>
> CAT,
>
> DOG,
>
> FERRET;
>
>
>
>
> public static void main( String[] args
> )
>
> {
>
>
> try
>
>
> {
>
>
> TestExample test = new TestExample();
>
>
> for ( Example x :
> Example.values() )
>
>
> test.add( x );
>
>
>
>
>
> File file = new File( "example.xml" );
>
>
> Serializer s = new Persister();
>
>
> s.write( test, file );
>
>
>
>
>
> test = s.read( TestExample.class, file );
>
>
> }
>
>
> catch( Exception e )
>
>
> {
>
>
> e.printStackTrace();
>
>
> }
>
> }
>
> }
>
>
>
>
> @Root
>
> class TestExample
>
> {
>
> @ElementMap( keyType =
> String.class, valueType = Object.class )
>
> public
> Map<String,Object> objectMap = new
> HashMap<String,Object>();
>
>
>
>
> @ElementMap( keyType =
> String.class, valueType = Example.class )
>
> public
> Map<String,Example> enumMap = new
> HashMap<String,Example>();
>
>
>
>
> public void add( Example x
> )
>
> {
>
>
> objectMap.put( x.name(),
> x );
>
>
> enumMap.put( x.name(),
> x );
>
> }
>
> }
>
>
>
>
> That
> generates this XML:
>
>
>
>
> <testExample>
>
> <objectMap
> class="java.util.HashMap">
>
>
> <entry>
>
>
> <string>CAT</string>
>
>
> <object
> class="test.Example">CAT</object>
>
>
>
> </entry>
>
>
> <entry>
>
>
> <string>FERRET</string>
>
>
> <object
> class="test.Example">FERRET</object>
>
>
>
> </entry>
>
>
> <entry>
>
>
> <string>DOG</string>
>
>
> <object
> class="test.Example">DOG</object>
>
>
>
> </entry>
>
>
> </objectMap>
>
> <enumMap
> class="java.util.HashMap">
>
>
> <entry>
>
>
> <string>CAT</string>
>
>
> <example>CAT</example>
>
>
> </entry>
>
>
> <entry>
>
>
> <string>FERRET</string>
>
>
> <example>FERRET</example>
>
>
> </entry>
>
>
> <entry>
>
>
> <string>DOG</string>
>
>
> <example>DOG</example>
>
>
> </entry>
>
>
> </enumMap>
>
> </testExample>
>
>
>
>
> The
> problem is that while both map elements can be serialised,
> only the enumMap
> element can be deserialised. The objectMap element
> will throw this
> TransformException:
>
>
>
>
> org.simpleframework.xml.transform.TransformException: Transform of
> class com.kaiz.darms.configuration.Example not
> supported
>
>
> at
> org.simpleframework.xml.transform.Transformer.read(Transformer.java:104)
>
>
> at
> org.simpleframework.xml.core.Support.read(Support.java:176)
>
>
> at
> org.simpleframework.xml.core.PrimitiveFactory.getInstance(PrimitiveFactory.java:110)
>
>
> at
> org.simpleframework.xml.core.Primitive.readTemplate(Primitive.java:225)
>
>
> at
> org.simpleframework.xml.core.Primitive.read(Primitive.java:166)
>
>
> at
> org.simpleframework.xml.core.Composite.readPrimitive(Composite.java:178)
>
>
> at
> org.simpleframework.xml.core.Composite.read(Composite.java:133)
>
>
> at
> org.simpleframework.xml.core.Traverser.read(Traverser.java:78)
>
>
> at
> org.simpleframework.xml.core.CompositeValue.read(CompositeValue.java:102)
>
>
> at
> org.simpleframework.xml.core.CompositeMap.populate(CompositeMap.java:177)
>
>
> at
> org.simpleframework.xml.core.CompositeMap.read(CompositeMap.java:148)
>
>
> at
> org.simpleframework.xml.core.Composite.readObject(Composite.java:517)
>
>
> at
> org.simpleframework.xml.core.Composite.read(Composite.java:477)
>
>
> at
> org.simpleframework.xml.core.Composite.readElement(Composite.java:458)
>
>
> at
> org.simpleframework.xml.core.Composite.readElements(Composite.java:374)
>
>
> at
> org.simpleframework.xml.core.Composite.read(Composite.java:259)
>
>
> at
> org.simpleframework.xml.core.Composite.read(Composite.java:204)
>
>
> at
> org.simpleframework.xml.core.Composite.read(Composite.java:158)
>
>
> at
> org.simpleframework.xml.core.Composite.read(Composite.java:135)
>
>
> at
> org.simpleframework.xml.core.Traverser.read(Traverser.java:78)
>
>
> at
> org.simpleframework.xml.core.Persister.read(Persister.java:544)
>
>
> at
> org.simpleframework.xml.core.Persister.read(Persister.java:526)
>
>
> at
> org.simpleframework.xml.core.Persister.read(Persister.java:507)
>
>
> at
> org.simpleframework.xml.core.Persister.read(Persister.java:489)
>
>
> at
> org.simpleframework.xml.core.Persister.read(Persister.java:471)
>
>
> at
> org.simpleframework.xml.core.Persister.read(Persister.java:452)
>
>
> at
> org.simpleframework.xml.core.Persister.read(Persister.java:431)
>
>
> at
> com.kaiz.darms.configuration.Example.main(Example.java:30)
>
>
>
>
> I
> did try adding a @Root annotation to the Example
> class. This stopped
> Simple throwing an exception but the deserialised objectMap
> had null for each value.
>
>
>
>
> Cheers,
>
> Greg.
>
>
>
> Greg Cottman
>
> Tel: +61 419
> 535 485
>
> mailto:Gre...@qu...
>
>
>
>
>
>
>
>
>
>
> -----Inline Attachment Follows-----
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd,
> NYC. CaT
> is a gathering of tech-side developers & brand
> creativity professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity,
> Processing, &
> iPhoneDevCamp asthey present alongside digital heavyweights
> like Barbarian
> Group, R/GA, & Big Spaceship. http://www.creativitycat.com
> -----Inline Attachment Follows-----
>
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
|
|
From: Greg C. <gre...@qu...> - 2009-05-16 10:12:37
|
Hi Niall,
I am using Simple XML 2.0.4 with Java 1.6.0_04 in a Windows XP environment.
I have a test program:
package test;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.simpleframework.xml.ElementMap;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
public enum Example
{
CAT,
DOG,
FERRET;
public static void main( String[] args )
{
try
{
TestExample test = new TestExample();
for ( Example x : Example.values() )
test.add( x );
File file = new File( "example.xml" );
Serializer s = new Persister();
s.write( test, file );
test = s.read( TestExample.class, file );
}
catch( Exception e )
{
e.printStackTrace();
}
}
}
@Root
class TestExample
{
@ElementMap( keyType = String.class, valueType = Object.class )
public Map<String,Object> objectMap = new HashMap<String,Object>();
@ElementMap( keyType = String.class, valueType = Example.class )
public Map<String,Example> enumMap = new HashMap<String,Example>();
public void add( Example x )
{
objectMap.put( x.name(), x );
enumMap.put( x.name(), x );
}
}
That generates this XML:
<testExample>
<objectMap class="java.util.HashMap">
<entry>
<string>CAT</string>
<object class="test.Example">CAT</object>
</entry>
<entry>
<string>FERRET</string>
<object class="test.Example">FERRET</object>
</entry>
<entry>
<string>DOG</string>
<object class="test.Example">DOG</object>
</entry>
</objectMap>
<enumMap class="java.util.HashMap">
<entry>
<string>CAT</string>
<example>CAT</example>
</entry>
<entry>
<string>FERRET</string>
<example>FERRET</example>
</entry>
<entry>
<string>DOG</string>
<example>DOG</example>
</entry>
</enumMap>
</testExample>
The problem is that while both map elements can be serialised, only the enumMap element can be deserialised. The objectMap element will throw this TransformException:
org.simpleframework.xml.transform.TransformException: Transform of class com.kaiz.darms.configuration.Example not supported
at org.simpleframework.xml.transform.Transformer.read(Transformer.java:104)
at org.simpleframework.xml.core.Support.read(Support.java:176)
at org.simpleframework.xml.core.PrimitiveFactory.getInstance(PrimitiveFactory.java:110)
at org.simpleframework.xml.core.Primitive.readTemplate(Primitive.java:225)
at org.simpleframework.xml.core.Primitive.read(Primitive.java:166)
at org.simpleframework.xml.core.Composite.readPrimitive(Composite.java:178)
at org.simpleframework.xml.core.Composite.read(Composite.java:133)
at org.simpleframework.xml.core.Traverser.read(Traverser.java:78)
at org.simpleframework.xml.core.CompositeValue.read(CompositeValue.java:102)
at org.simpleframework.xml.core.CompositeMap.populate(CompositeMap.java:177)
at org.simpleframework.xml.core.CompositeMap.read(CompositeMap.java:148)
at org.simpleframework.xml.core.Composite.readObject(Composite.java:517)
at org.simpleframework.xml.core.Composite.read(Composite.java:477)
at org.simpleframework.xml.core.Composite.readElement(Composite.java:458)
at org.simpleframework.xml.core.Composite.readElements(Composite.java:374)
at org.simpleframework.xml.core.Composite.read(Composite.java:259)
at org.simpleframework.xml.core.Composite.read(Composite.java:204)
at org.simpleframework.xml.core.Composite.read(Composite.java:158)
at org.simpleframework.xml.core.Composite.read(Composite.java:135)
at org.simpleframework.xml.core.Traverser.read(Traverser.java:78)
at org.simpleframework.xml.core.Persister.read(Persister.java:544)
at org.simpleframework.xml.core.Persister.read(Persister.java:526)
at org.simpleframework.xml.core.Persister.read(Persister.java:507)
at org.simpleframework.xml.core.Persister.read(Persister.java:489)
at org.simpleframework.xml.core.Persister.read(Persister.java:471)
at org.simpleframework.xml.core.Persister.read(Persister.java:452)
at org.simpleframework.xml.core.Persister.read(Persister.java:431)
at com.kaiz.darms.configuration.Example.main(Example.java:30)
I did try adding a @Root annotation to the Example class. This stopped Simple throwing an exception but the deserialised objectMap had null for each value.
Cheers,
Greg.
Greg Cottman
Tel: +61 419 535 485
mailto:Gre...@qu...
|
|
From: Niall G. <gal...@ya...> - 2009-05-05 20:00:55
|
Hi, I am not really that sure I understand what you are asking. What do you mean by "scope" here? Do you mean your class loader does not have access to some of the classes? Thanks, Niall --- On Mon, 5/4/09, danlourd <dan...@ya...> wrote: > From: danlourd <dan...@ya...> > Subject: [Simple-support] Serialization and Deserialization through sockets > To: sim...@li... > Date: Monday, May 4, 2009, 6:25 PM > > Hi, > > We have this common interface ITest that all our client > implements. Each > client have different implementation of ITest. We serialize > this objects and > send it it through a socket. Now on the other end of that > socket we > deserialize that object. > > I'm having problem deserializing that object because it > can't map to a > "class" within that scope. Is there a way in simple xml > while deserializing > to force to map an object known within the scope where an > object is being > deserialized? > > Thanks, > Dan Ramirez > > > -- > View this message in context: http://www.nabble.com/Serialization-and-Deserialization-through-sockets-tp23379532p23379532.html > Sent from the Simple XML Serialization mailing list archive > at Nabble.com. > > > ------------------------------------------------------------------------------ > The NEW KODAK i700 Series Scanners deliver under ANY > circumstances! Your > production scanning environment may not be a perfect world > - but thanks to > Kodak, there's a perfect scanner to get the job done! With > the NEW KODAK i700 > Series Scanner you'll get full speed at 300 dpi even with > all image > processing features enabled. http://p.sf.net/sfu/kodak-com > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > |
|
From: danlourd <dan...@ya...> - 2009-05-05 01:23:34
|
Hi, We have this common interface ITest that all our client implements. Each client have different implementation of ITest. We serialize this objects and send it it through a socket. Now on the other end of that socket we deserialize that object. I am having problem deserializing that object because it can't map to a "class" in that scope. Is there a way in simple xml while deserializing to force to map an object known within the scope where deserialize an object is being deserialized? Thanks, Dan Ramirez -- View this message in context: http://www.nabble.com/Serialization-and-Deserialization-through-sockets-tp23379532p23379532.html Sent from the Simple XML Serialization mailing list archive at Nabble.com. |
|
From: <Nia...@ub...> - 2009-04-28 10:42:38
|
Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company registered in England & Wales under company number 2035362, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS AG (London Branch) is registered as a branch of a foreign company under number BR004507, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS Clearing and Execution Services Limited is a company registered in England & Wales under company number 03123037, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS reserves the right to retain all messages. Messages are protected and accessed only in legally justified cases. |
|
From: Vladimir K. <me...@li...> - 2009-04-28 10:39:34
|
It's like org.simpleframework.xml.filter.Filter, but returning Object instead
of String. This option is for deserialization only. Example of optimal desired
behavior (CustomHandler should be given to Persister):
<bean class="example.Bean">
<param>${object}</param>
</bean>
@Root
public class Bean {
private Custom object;
@Element
public void setParam(Custom object) {
this.object = object;
}
}
public class Custom {
public int var1;
public int var2;
}
public class CustomHandler implements Handler {
public Object handle(String s) {
// here can be a script interpreter
if ("object".equals(s)) {
Custom c = new Custom();
c.var1 = 13;
c.var2 = 42;
return c;
} else {
return null;
}
}
}
On Вторник 28 апреля 2009 10:30:14 Nia...@ub... wrote:
> Hi,
>
> I am not sure what you mean here. Passing by value and reference? Can you
> provide an example?
> Niall
--
Vladimir Kulev
Mobile: +7 (921) 5554422
Jabber: lig...@ja...
|
|
From: <Nia...@ub...> - 2009-04-28 06:49:17
|
Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company registered in England & Wales under company number 2035362, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS AG (London Branch) is registered as a branch of a foreign company under number BR004507, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS Clearing and Execution Services Limited is a company registered in England & Wales under company number 03123037, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS reserves the right to retain all messages. Messages are protected and accessed only in legally justified cases. |
|
From: <Nia...@ub...> - 2009-04-27 06:37:46
|
Visit our website at http://www.ubs.com This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mails are not encrypted and cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. This message is provided for informational purposes and should not be construed as a solicitation or offer to buy or sell any securities or related financial instruments. UBS Limited is a company registered in England & Wales under company number 2035362, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS AG (London Branch) is registered as a branch of a foreign company under number BR004507, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS Clearing and Execution Services Limited is a company registered in England & Wales under company number 03123037, whose registered office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom. UBS reserves the right to retain all messages. Messages are protected and accessed only in legally justified cases. |
|
From: Vladimir K. <me...@li...> - 2009-04-26 01:02:13
|
Hi all!
I want to use simpleframework for injecting some beans configurations in my
project. The thing I want is the following:
<bean>
<param>${var1 - var2}</param>
</bean>
While "param" can be passed by value (e.g. it's a string) everything is ok,
but if it's an EJB bean or something else... Is there a possibility of
relatively small hack to enable "${...}" passing by reference?
--
Vladimir Kulev
Mobile: +7 (921) 5554422
Jabber: lig...@ja...
|
|
From: Ian H. <ia...@ta...> - 2009-04-25 16:19:20
|
Hello,
I found an exception in Simple 2.0.4 (it was also present in 2.0.1). See the
stack trace below.
The date was serialized using Simple in one locale (MESZ), and deserialized
in another locale (EST).
Is there a way to change how the date is serialized?
I don't actually need the time or the timezone information.
Thanks,
Ian
java.text.ParseException: Unparseable date: "2009-04-24 18:32:59.479 MESZ"
at java.text.DateFormat.parse(DateFormat.java:335)
at
org.simpleframework.xml.transform.DateType$DateFormat.getDate(DateType.java:
191)
at
org.simpleframework.xml.transform.DateType.getDate(DateType.java:114)
at
org.simpleframework.xml.transform.DateTransform.read(DateTransform.java:77)
at
org.simpleframework.xml.transform.DateTransform.read(DateTransform.java:46)
at
org.simpleframework.xml.transform.Transformer.read(Transformer.java:106)
at org.simpleframework.xml.core.Support.read(Support.java:113)
at
org.simpleframework.xml.core.PrimitiveFactory.getInstance(PrimitiveFactory.j
ava:110)
at
org.simpleframework.xml.core.Primitive.readTemplate(Primitive.java:204)
at org.simpleframework.xml.core.Primitive.read(Primitive.java:145)
at
org.simpleframework.xml.core.Primitive.readElement(Primitive.java:180)
at
org.simpleframework.xml.core.Primitive.readElement(Primitive.java:163)
at org.simpleframework.xml.core.Primitive.read(Primitive.java:119)
at org.simpleframework.xml.core.Composite.read(Composite.java:435)
at
org.simpleframework.xml.core.Composite.readElement(Composite.java:415)
at
org.simpleframework.xml.core.Composite.readElements(Composite.java:331)
at org.simpleframework.xml.core.Composite.read(Composite.java:216)
at org.simpleframework.xml.core.Composite.read(Composite.java:161)
at org.simpleframework.xml.core.Composite.read(Composite.java:137)
at org.simpleframework.xml.core.Traverser.read(Traverser.java:78)
at org.simpleframework.xml.core.Persister.read(Persister.java:544)
at org.simpleframework.xml.core.Persister.read(Persister.java:526)
at org.simpleframework.xml.core.Persister.read(Persister.java:507)
at org.simpleframework.xml.core.Persister.read(Persister.java:489)
at org.simpleframework.xml.core.Persister.read(Persister.java:471)
at org.simpleframework.xml.core.Persister.read(Persister.java:452)
at org.simpleframework.xml.core.Persister.read(Persister.java:431)
|
|
From: Niall G. <gal...@ya...> - 2009-04-25 10:00:26
|
Hi, The TreeStrategy is basically the default strategy. You can extend that instead, it will give you the very same functionality. Niall --- On Fri, 4/24/09, Mirza Abbas Raza <abb...@ya...> wrote: > From: Mirza Abbas Raza <abb...@ya...> > Subject: [Simple-support] Suppressing class attribute in serialization > To: sim...@li... > Date: Friday, April 24, 2009, 3:32 PM > Hi, > > I have a class that is used for multiple purposes and hence > is needed to be serialized with a different element name in > the respective scenario. In all cases where the element name > is different than the class name, the class attribute is > injected by Simple. Looking into DefaultStrategy and also on > one of the forums, I understood that the label name is to be > removed from the map which is used for serialization. The > issue that I face is that I do not have to rewrite the whole > strategy but rather just not have the class name printed > out. I wanted to extend DefaultStrategy but it is protected. > Is there a simpler way to tweak this functionality? > Appreciate any help. > > Thanks, > Abbas > > -----Inline Attachment Follows----- > > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensign option that enables > unlimited > royalty-free distribution of the report engine for > externally facing > server and web deployment. > http://p.sf.net/sfu/businessobjects > -----Inline Attachment Follows----- > > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > |
|
From: Mirza A. R. <abb...@ya...> - 2009-04-24 22:59:39
|
Hi, I have a class that is used for multiple purposes and hence is needed to be serialized with a different element name in the respective scenario. In all cases where the element name is different than the class name, the class attribute is injected by Simple. Looking into DefaultStrategy and also on one of the forums, I understood that the label name is to be removed from the map which is used for serialization. The issue that I face is that I do not have to rewrite the whole strategy but rather just not have the class name printed out. I wanted to extend DefaultStrategy but it is protected. Is there a simpler way to tweak this functionality? Appreciate any help. Thanks, Abbas |
|
From: <Nia...@ub...> - 2009-04-22 08:40:27
|
Hi,
You do not even need to use CycleStrategy. Use the TreeStrategy if you
like, and make sure the usual class label is named to something else.
For example
Strategy strategy = new TreeStrategy("className", "arrayLength");
Serializer serializer = new Persister(strategy)
For now ignore "arrayLength" it is simply the name of the attribute to
use when specifying the length of an array when it is serialized. Here
the "className" attribute given the the actual class used for the
element. So for example your serialized XML might look like this.
<root className="fr.smile.SomeClass">
<data>some data</data>
</root>
Here the serialization class name will not conflict with existing
"class" attributes any more.
Regards,
Niall
-----Original Message-----
From: Patrice [mailto:pat...@sm...]
Sent: 21 April 2008 19:27
To: sim...@li...
Subject: [Simple-support] "class" attribute on parsing legacy xml
Hello,
I'm having difficulty reading an existing Xml file with "class"
attribute. The issue was mentionned by someone else on this list, and
Niall's answer was to use CycleStrategy, but I can't figure out how.
------------------------------------------------------------------------
------
Stay on top of everything new and different, both inside and around Java
(TM) technology - register by April 22, and save $200 on the JavaOne
(SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
Visit our website at http://www.ubs.com
This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.
E-mails are not encrypted and cannot be guaranteed to be secure or
error-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The sender
therefore does not accept liability for any errors or omissions in the
contents of this message which arise as a result of e-mail transmission.
If verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities
or related financial instruments.
UBS Limited is a company registered in England & Wales under company
number 2035362, whose registered office is at 1 Finsbury Avenue,
London, EC2M 2PP, United Kingdom.
UBS AG (London Branch) is registered as a branch of a foreign company
under number BR004507, whose registered office is at
1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
UBS Clearing and Execution Services Limited is a company registered
in England & Wales under company number 03123037, whose registered
office is at 1 Finsbury Avenue, London, EC2M 2PP, United Kingdom.
UBS reserves the right to retain all messages. Messages are protected
and accessed only in legally justified cases.
|