simple-support Mailing List for Simple (Page 3)
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: Sobeos <so...@gm...> - 2014-09-11 09:41:51
|
I'm reusing XML elements in my xml based on the id ref machanism which is working fine. http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#reus e Now I want to unmarshall the id attribute as a normal member variable. As result I get always 0. Is there a way to get the value of id in the java object when using final Strategy strategy = new CycleStrategy("id", "ref");? Any ideas/hints? --- Diese E-Mail ist frei von Viren und Malware, denn der avast! Antivirus Schutz ist aktiv. http://www.avast.com |
|
From: Niall G. <gal...@ya...> - 2014-07-31 22:42:18
|
You can use a converter, it should be able to remove the tag. The problem here is how do you distinguish null from an empty list. The tag is needed for this in order to do a verbatim serialization/deserialization.
--------------------------------------------
On Fri, 1/8/14, Vojtěch Rýznar <ry...@ce...> wrote:
Subject: [Simple-support] How can I make Simple not to serialize empty ArrayList?
To: sim...@li...
Received: Friday, 1 August, 2014, 6:26 AM
Good day, I need an advice please. let's say I
have class
Person:
@Root(name="Person")
public class Person {
@Element(name="Name")
public String name = "MyName"
@ElementList(name="AddressList", entry="Address", required=false)
public ArrayList<Address> addressList = new ArrayList<>();
}
... and class Address:
public class Address {
@Element(name="Street")
public String street;
@Element(name="City")
public String city;
}
When addressList has no items Simple produces this
XML:
<Person>
<Name>MyName</Name>
<AddressList/>
</Person>
Please, how can I make Simple omit tag
AddressList
if there are no items on the list? I want the XML
look like this
in such case:
<Person>
<Name>MyName</Name>
</Person>
I don't want to set the addressList to null.
When I create
Person object I want the addressList to be
initialized so that I
can easily add addresses if needed and I don't
need to check
whehter it is null and instantiate it. The example
above is very
simple but when my object hierarchy is more
complicated it is
unconvenient to check and initialize all lists. I
hoped I could
resolve it using some anotation or custom converter
or something
like that.
Thank you in advance. Vojta
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Infragistics Professional
Build stunning WinForms apps today!
Reboot your WinForms applications with our WinForms
controls.
Build a bridge from your legacy apps to the future.
http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Vojtěch R. <ry...@ce...> - 2014-07-31 20:45:09
|
Good day, I need an advice please. let's say I have class Person:
|@Root(name="Person")
public class Person {
@Element(name="Name")
public String name= "MyName"
@ElementList(name="AddressList", entry="Address", required=false)
public ArrayList<Address> addressList= new ArrayList<>();
}|
... and class Address:
|public class Address {
@Element(name="Street")
public String street;
@Element(name="City")
public String city;
}|
When addressList has no items Simple produces this XML:
|<Person>
<Name>MyName</Name>
<AddressList/>
</Person>|
Please, how can I make Simple omit tag *AddressList* if there are no
items on the list? I want the XML look like this in such case:
|<Person>
<Name>MyName</Name>
</Person>|
I don't want to set the addressList to null. When I create Person object
I want the addressList to be initialized so that I can easily add
addresses if needed and I don't need to check whehter it is null and
instantiate it. The example above is very simple but when my object
hierarchy is more complicated it is unconvenient to check and initialize
all lists. I hoped I could resolve it using some anotation or custom
converter or something like that.
Thank you in advance. Vojta
|
|
From: Niall G. - Y. <Nia...@yi...> - 2014-06-13 23:37:55
|
I think I mentioned that non-static inners cannot be instantiated via reflection, it has an implicit "this"...
From: Miha Vitorovic [mailto:mih...@gm...]
Sent: 13 June 2014 01:57
To: Niall Gallagher; sim...@li...
Subject: Re: [Simple-support] Writing to XML fails
Hi,
could you please help me get this working? I really do not know what is wrong. I haven't had the time to look into the simple sources yet...
Thanks, Miha
On 7.6.2014 10:16, Miha Vitorovic wrote:
Thanks, I had a similar idea over the night, but I cannot get it working:
package com.mycompany.simpletest;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;
@Root
public class Pair<A, B> {
@Element(name = "first")
private final A first;
@Element(name = "second")
private final B second;
public Pair(@Element(name = "first") A first, @Element(name = "second") B second) {
this.first = first;
this.second = second;
}
public A getFirst() { return first; }
public B getSecond() { return second; }
}
- - - - - - - -
package com.mycompany.simpletest;
import java.util.ArrayList;
import java.util.List;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;
@Root
public class Test {
@Root
public class Info {
@Element(name = "name")
private final String name;
public Info(@Element(name = "name") String name) { this.name = name; }
public String getName() { return name; }
}
@ElementList
private List<Pair<Info, Info>> list;
public Test() {
list = new ArrayList<>();
}
public void add(String s1, String s2) {
Info i1 = new Info(s1);
Info i2 = new Info(s2);
Pair<Info, Info> p = new Pair<>(i1, i2);
list.add(p);
}
}
- - - - - - - -
package com.mycompany.simpletest;
import java.io.FileOutputStream;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.convert.AnnotationStrategy;
import org.simpleframework.xml.core.Persister;
import org.simpleframework.xml.strategy.Strategy;
public class SimpleTest {
public static void main(String[] args) {
Test t1 = new Test();
t1.add("a", "b");
t1.add("b", "c");
try {
FileOutputStream out = new FileOutputStream("test.xml");
Strategy strategy = new AnnotationStrategy();
Serializer serializer = new Persister(strategy);
serializer.write(t1, out);
out.close();
} catch (Exception e) { e.printStackTrace(); }
}
}
Br, Miha
On 7.6.2014 3:58, Niall Gallagher wrote:
You cannot construct a non static inner class through reflection. For the constructors also you must specify the names
Pair(@Element(name="first") A first, @Element(name="second") B second)
--------------------------------------------
On Fri, 6/6/14, Miha Vitorovic <mih...@gm...><mailto:mih...@gm...> wrote:
|
|
From: Miha V. <mih...@gm...> - 2014-06-12 15:56:50
|
Hi,
could you please help me get this working? I really do not know what is
wrong. I haven't had the time to look into the simple sources yet...
Thanks, Miha
On 7.6.2014 10:16, Miha Vitorovic wrote:
> Thanks, I had a similar idea over the night, but I cannot get it working:
>
> package com.mycompany.simpletest;
>
> import org.simpleframework.xml.Element;
> import org.simpleframework.xml.Root;
>
> @Root
> public class Pair<A, B> {
> @Element(name = "first")
> private final A first;
> @Element(name = "second")
> private final B second;
>
> public Pair(@Element(name = "first") A first, @Element(name =
> "second") B second) {
> this.first = first;
> this.second = second;
> }
>
> public A getFirst() { return first; }
> public B getSecond() { return second; }
> }
> - - - - - - - -
> package com.mycompany.simpletest;
>
> import java.util.ArrayList;
> import java.util.List;
> import org.simpleframework.xml.Element;
> import org.simpleframework.xml.ElementList;
> import org.simpleframework.xml.Root;
>
> @Root
> public class Test {
> @Root
> public class Info {
> @Element(name = "name")
> private final String name;
>
> public Info(@Element(name = "name") String name) { this.name =
> name; }
>
> public String getName() { return name; }
> }
>
> @ElementList
> private List<Pair<Info, Info>> list;
>
> public Test() {
> list = new ArrayList<>();
> }
>
> public void add(String s1, String s2) {
> Info i1 = new Info(s1);
> Info i2 = new Info(s2);
> Pair<Info, Info> p = new Pair<>(i1, i2);
> list.add(p);
> }
> }
> - - - - - - - -
> package com.mycompany.simpletest;
>
> import java.io.FileOutputStream;
> import org.simpleframework.xml.Serializer;
> import org.simpleframework.xml.convert.AnnotationStrategy;
> import org.simpleframework.xml.core.Persister;
> import org.simpleframework.xml.strategy.Strategy;
>
> public class SimpleTest {
>
> public static void main(String[] args) {
> Test t1 = new Test();
> t1.add("a", "b");
> t1.add("b", "c");
>
> try {
> FileOutputStream out = new FileOutputStream("test.xml");
> Strategy strategy = new AnnotationStrategy();
> Serializer serializer = new Persister(strategy);
> serializer.write(t1, out);
> out.close();
> } catch (Exception e) { e.printStackTrace(); }
> }
> }
>
> Br, Miha
>
> On 7.6.2014 3:58, Niall Gallagher wrote:
>> You cannot construct a non static inner class through reflection. For the constructors also you must specify the names
>>
>> Pair(@Element(name="first") A first, @Element(name="second") B second)
>>
>> --------------------------------------------
>> On Fri, 6/6/14, Miha Vitorovic<mih...@gm...> wrote:
>>
>>
>
|
|
From: Niall G. - Y. <Nia...@yi...> - 2014-06-11 01:07:27
|
Try public static enum, reflection does not deal well with non static inners. Apart from that it should serialize fine.
From: Maxim Solodovnik [mailto:sol...@gm...]
Sent: 10 June 2014 18:19
To: sim...@li...
Subject: Re: [Simple-support] Serializing java.util.Set<Enum>
Sorry for the noise, was issue in my code, everything works as expected
On 10 June 2014 10:36, Maxim Solodovnik <sol...@gm...<mailto:sol...@gm...>> wrote:
Hello,
I currently have the following class
@Root(name = "A")
public class A implements Serializable {
public enum B {
b1, b2, b3, b4
}
@ElementList(data = true, required = false)
private Set<B> bs = new HashSet<A.B>();
}
And it seems like Set<B> is not serialized :(
Also tried with
@ElementMap
Is there any way to fix/debug this?
I'm using latest simple-xml
Thanks in advance
--
WBR
Maxim aka solomax
--
WBR
Maxim aka solomax
|
|
From: Maxim S. <sol...@gm...> - 2014-06-10 08:18:36
|
Sorry for the noise, was issue in my code, everything works as expected
On 10 June 2014 10:36, Maxim Solodovnik <sol...@gm...> wrote:
> Hello,
>
> I currently have the following class
>
> @Root(name = "A")
> public class A implements Serializable {
> public enum B {
> b1, b2, b3, b4
> }
> @ElementList(data = true, required = false)
> private Set<B> bs = new HashSet<A.B>();
>
> }
>
> And it seems like Set<B> is not serialized :(
>
> Also tried with
> @ElementMap
>
> Is there any way to fix/debug this?
>
> I'm using latest simple-xml
>
> Thanks in advance
>
> --
> WBR
> Maxim aka solomax
>
--
WBR
Maxim aka solomax
|
|
From: Maxim S. <sol...@gm...> - 2014-06-10 03:36:26
|
Hello,
I currently have the following class
@Root(name = "A")
public class A implements Serializable {
public enum B {
b1, b2, b3, b4
}
@ElementList(data = true, required = false)
private Set<B> bs = new HashSet<A.B>();
}
And it seems like Set<B> is not serialized :(
Also tried with
@ElementMap
Is there any way to fix/debug this?
I'm using latest simple-xml
Thanks in advance
--
WBR
Maxim aka solomax
|
|
From: Miha V. <mih...@gm...> - 2014-06-07 08:16:40
|
Thanks, I had a similar idea over the night, but I cannot get it working:
package com.mycompany.simpletest;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;
@Root
public class Pair<A, B> {
@Element(name = "first")
private final A first;
@Element(name = "second")
private final B second;
public Pair(@Element(name = "first") A first, @Element(name =
"second") B second) {
this.first = first;
this.second = second;
}
public A getFirst() { return first; }
public B getSecond() { return second; }
}
- - - - - - - -
package com.mycompany.simpletest;
import java.util.ArrayList;
import java.util.List;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;
@Root
public class Test {
@Root
public class Info {
@Element(name = "name")
private final String name;
public Info(@Element(name = "name") String name) { this.name =
name; }
public String getName() { return name; }
}
@ElementList
private List<Pair<Info, Info>> list;
public Test() {
list = new ArrayList<>();
}
public void add(String s1, String s2) {
Info i1 = new Info(s1);
Info i2 = new Info(s2);
Pair<Info, Info> p = new Pair<>(i1, i2);
list.add(p);
}
}
- - - - - - - -
package com.mycompany.simpletest;
import java.io.FileOutputStream;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.convert.AnnotationStrategy;
import org.simpleframework.xml.core.Persister;
import org.simpleframework.xml.strategy.Strategy;
public class SimpleTest {
public static void main(String[] args) {
Test t1 = new Test();
t1.add("a", "b");
t1.add("b", "c");
try {
FileOutputStream out = new FileOutputStream("test.xml");
Strategy strategy = new AnnotationStrategy();
Serializer serializer = new Persister(strategy);
serializer.write(t1, out);
out.close();
} catch (Exception e) { e.printStackTrace(); }
}
}
Br, Miha
On 7.6.2014 3:58, Niall Gallagher wrote:
> You cannot construct a non static inner class through reflection. For the constructors also you must specify the names
>
> Pair(@Element(name="first") A first, @Element(name="second") B second)
>
> --------------------------------------------
> On Fri, 6/6/14, Miha Vitorovic <mih...@gm...> wrote:
>
>
|
|
From: Niall G. <gal...@ya...> - 2014-06-07 01:58:55
|
You cannot construct a non static inner class through reflection. For the constructors also you must specify the names
Pair(@Element(name="first") A first, @Element(name="second") B second)
--------------------------------------------
On Fri, 6/6/14, Miha Vitorovic <mih...@gm...> wrote:
Subject: [Simple-support] Writing to XML fails
To: sim...@li...
Received: Friday, 6 June, 2014, 3:38 PM
Hi Niall,
first off, thanks for the great library. But
I'm having
trouble fitting the following
together:
package
com.mycompany.simpletest;
import
org.simpleframework.xml.Element;
import
org.simpleframework.xml.Root;
@Root(name = "pair")
public class Pair<A, B> {
@Element
private final A first;
@Element
private final B second;
public Pair(A first, B second)
{
this.first =
first;
this.second =
second;
}
public A getFirst() { return
first; }
public B getSecond() { return
second; }
}
------------------
package com.mycompany.simpletest;
import java.util.ArrayList;
import java.util.List;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;
@Root(name = "test")
public class Test {
@Root(name = "element1")
public class Info {
@Element
private String name;
public Info(String name) {
this.name = name;
}
}
@ElementList(name = "list")
private List<Pair<Info,
Info>> list;
public Test() {
list = new ArrayList<>();
}
public void add(String s1, String s2) {
Info i1 = new Info(s1);
Info i2 = new Info(s2);
Pair<Info, Info> p = new
Pair<>(i1, i2);
list.add(p);
}
}
------------------
package com.mycompany.simpletest;
import java.io.FileOutputStream;
import org.simpleframework.xml.Serializer;
import
org.simpleframework.xml.convert.AnnotationStrategy;
import org.simpleframework.xml.core.Persister;
import
org.simpleframework.xml.strategy.Strategy;
public class SimpleTest {
public static void main(String[] args) {
Test t1 = new Test();
t1.add("a",
"b");
t1.add("b",
"c");
try {
FileOutputStream out =
new
FileOutputStream("test.xml");
Strategy strategy = new
AnnotationStrategy();
Serializer serializer =
new Persister(strategy);
serializer.write(t1,
out);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
And this is the result:
org.simpleframework.xml.core.ConstructorException: Can not
construct inner class
com.mycompany.simpletest.Test$Info
at
org.simpleframework.xml.core.ConstructorScanner.scan(ConstructorScanner.java:122)
at
org.simpleframework.xml.core.ConstructorScanner.<init>(ConstructorScanner.java:73)
at
org.simpleframework.xml.core.ClassScanner.<init>(ClassScanner.java:109)
at
org.simpleframework.xml.core.ObjectScanner.<init>(ObjectScanner.java:78)
at
org.simpleframework.xml.core.ScannerFactory.getInstance(ScannerFactory.java:81)
at
org.simpleframework.xml.core.Support.getScanner(Support.java:357)
at
org.simpleframework.xml.core.Source.getScanner(Source.java:271)
at
org.simpleframework.xml.core.Source.getCaller(Source.java:300)
at
org.simpleframework.xml.core.Composite.writeReplace(Composite.java:1147)
at
org.simpleframework.xml.core.Composite.writeUnion(Composite.java:1124)
at
org.simpleframework.xml.core.Composite.writeElements(Composite.java:1098)
at
org.simpleframework.xml.core.Composite.writeSection(Composite.java:1004)
at
org.simpleframework.xml.core.Composite.write(Composite.java:975)
at
org.simpleframework.xml.core.Composite.write(Composite.java:952)
at
org.simpleframework.xml.core.Traverser.write(Traverser.java:236)
at
org.simpleframework.xml.core.CompositeList.write(CompositeList.java:248)
at
org.simpleframework.xml.core.Composite.writeElement(Composite.java:1256)
at
org.simpleframework.xml.core.Composite.writeElement(Composite.java:1239)
at
org.simpleframework.xml.core.Composite.writeUnion(Composite.java:1127)
at
org.simpleframework.xml.core.Composite.writeElements(Composite.java:1098)
at
org.simpleframework.xml.core.Composite.writeSection(Composite.java:1004)
at
org.simpleframework.xml.core.Composite.write(Composite.java:975)
at
org.simpleframework.xml.core.Composite.write(Composite.java:952)
at
org.simpleframework.xml.core.Traverser.write(Traverser.java:236)
at
org.simpleframework.xml.core.Traverser.write(Traverser.java:208)
at
org.simpleframework.xml.core.Traverser.write(Traverser.java:186)
at
org.simpleframework.xml.core.Persister.write(Persister.java:1180)
at
org.simpleframework.xml.core.Persister.write(Persister.java:1162)
at
org.simpleframework.xml.core.Persister.write(Persister.java:1140)
at
org.simpleframework.xml.core.Persister.write(Persister.java:1259)
at
org.simpleframework.xml.core.Persister.write(Persister.java:1241)
at
org.simpleframework.xml.core.Persister.write(Persister.java:1222)
at
com.mycompany.simpletest.SimpleTest.main(SimpleTest.java:31)
Can you please help?
Thanks and br, Miha
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph
databases and their
applications. Written by three acclaimed leaders in the
field,
this first edition is now available. Download your free book
today!
http://p.sf.net/sfu/NeoTech
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Miha V. <mih...@gm...> - 2014-06-06 22:38:17
|
Hi Niall,
first off, thanks for the great library. But I'm having trouble fitting
the following together:
package com.mycompany.simpletest;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;
@Root(name = "pair")
public class Pair<A, B> {
@Element
private final A first;
@Element
private final B second;
public Pair(A first, B second) {
this.first = first;
this.second = second;
}
public A getFirst() { return first; }
public B getSecond() { return second; }
}
------------------
package com.mycompany.simpletest;
import java.util.ArrayList;
import java.util.List;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;
@Root(name = "test")
public class Test {
@Root(name = "element1")
public class Info {
@Element
private String name;
public Info(String name) {
this.name = name;
}
}
@ElementList(name = "list")
private List<Pair<Info, Info>> list;
public Test() {
list = new ArrayList<>();
}
public void add(String s1, String s2) {
Info i1 = new Info(s1);
Info i2 = new Info(s2);
Pair<Info, Info> p = new Pair<>(i1, i2);
list.add(p);
}
}
------------------
package com.mycompany.simpletest;
import java.io.FileOutputStream;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.convert.AnnotationStrategy;
import org.simpleframework.xml.core.Persister;
import org.simpleframework.xml.strategy.Strategy;
public class SimpleTest {
public static void main(String[] args) {
Test t1 = new Test();
t1.add("a", "b");
t1.add("b", "c");
try {
FileOutputStream out = new FileOutputStream("test.xml");
Strategy strategy = new AnnotationStrategy();
Serializer serializer = new Persister(strategy);
serializer.write(t1, out);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
And this is the result:
org.simpleframework.xml.core.ConstructorException: Can not construct
inner class com.mycompany.simpletest.Test$Info
at
org.simpleframework.xml.core.ConstructorScanner.scan(ConstructorScanner.java:122)
at
org.simpleframework.xml.core.ConstructorScanner.<init>(ConstructorScanner.java:73)
at
org.simpleframework.xml.core.ClassScanner.<init>(ClassScanner.java:109)
at
org.simpleframework.xml.core.ObjectScanner.<init>(ObjectScanner.java:78)
at
org.simpleframework.xml.core.ScannerFactory.getInstance(ScannerFactory.java:81)
at org.simpleframework.xml.core.Support.getScanner(Support.java:357)
at org.simpleframework.xml.core.Source.getScanner(Source.java:271)
at org.simpleframework.xml.core.Source.getCaller(Source.java:300)
at
org.simpleframework.xml.core.Composite.writeReplace(Composite.java:1147)
at
org.simpleframework.xml.core.Composite.writeUnion(Composite.java:1124)
at
org.simpleframework.xml.core.Composite.writeElements(Composite.java:1098)
at
org.simpleframework.xml.core.Composite.writeSection(Composite.java:1004)
at org.simpleframework.xml.core.Composite.write(Composite.java:975)
at org.simpleframework.xml.core.Composite.write(Composite.java:952)
at org.simpleframework.xml.core.Traverser.write(Traverser.java:236)
at
org.simpleframework.xml.core.CompositeList.write(CompositeList.java:248)
at
org.simpleframework.xml.core.Composite.writeElement(Composite.java:1256)
at
org.simpleframework.xml.core.Composite.writeElement(Composite.java:1239)
at
org.simpleframework.xml.core.Composite.writeUnion(Composite.java:1127)
at
org.simpleframework.xml.core.Composite.writeElements(Composite.java:1098)
at
org.simpleframework.xml.core.Composite.writeSection(Composite.java:1004)
at org.simpleframework.xml.core.Composite.write(Composite.java:975)
at org.simpleframework.xml.core.Composite.write(Composite.java:952)
at org.simpleframework.xml.core.Traverser.write(Traverser.java:236)
at org.simpleframework.xml.core.Traverser.write(Traverser.java:208)
at org.simpleframework.xml.core.Traverser.write(Traverser.java:186)
at org.simpleframework.xml.core.Persister.write(Persister.java:1180)
at org.simpleframework.xml.core.Persister.write(Persister.java:1162)
at org.simpleframework.xml.core.Persister.write(Persister.java:1140)
at org.simpleframework.xml.core.Persister.write(Persister.java:1259)
at org.simpleframework.xml.core.Persister.write(Persister.java:1241)
at org.simpleframework.xml.core.Persister.write(Persister.java:1222)
at com.mycompany.simpletest.SimpleTest.main(SimpleTest.java:31)
Can you please help?
Thanks and br, Miha
|
|
From: Niall G. <gal...@ya...> - 2014-05-16 03:37:48
|
@Root
class Item{
@Path("value[1]")
@Text
String text;
@Path("value[2]")
@Element
String label
}
this should work, if not use a Converter
--------------------------------------------
On Wed, 14/5/14, Muhannad <muh...@gm...> wrote:
Subject: [Simple-support] I have a Tet and Element in one xml element
To: sim...@li...
Received: Wednesday, 14 May, 2014, 11:11 PM
Hello
I am using simple xml , it is great , but I faced a
problem that I have the next xml
<item key="2">
<value>Textual Data</value>
<value>
<label>Another Textual Data</label></value>
</item>
If I use @Text annotation with @Element , it is
not allowed , so any work around?
--
Best Regards
Muhannad al HaririSoftware
Developer
Stackoverflow
Profile
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing
- For FREE
Instantly run your Selenium tests across 300+ browser/OS
combos.
Get unparalleled scalability from the best Selenium testing
platform available
Simple to use. Nothing to install. Get started now for
free."
http://p.sf.net/sfu/SauceLabs
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Muhannad <muh...@gm...> - 2014-05-15 06:12:27
|
Hello I am using simple xml , it is great , but I faced a problem that I have the next xml <item key="2"> <value>Textual Data</value> <value> <label>Another Textual Data</label> </value> </item> If I use @Text annotation with @Element , it is not allowed , so any work around? -- *Best Regards * *Muhannad al Hariri* *Software Developer* *Stackoverflow Profile <http://stackoverflow.com/users/716865/muhannad>* |
|
From: dennis <de...@li...> - 2014-04-29 12:41:07
|
Hi Roger, Some time ago I posted a sed script to convert the java classes output of xjc to something that works with SimpleXML. I have attached the scripts in case you or anyone else is interested. I made some updates during my conversations with Kyle and others. I didn't keep up with new Simple developments for a while, so new concepts may need some fidling. See: http://sourceforge.net/p/simple/mailman/message/29161101/ The script works as follows (tested on Ubuntu Linux some time ago): - generate source with xjc: xjc XMLSchema.xsd - jaxb2simple.sed generated/JAXBSource.java > src/generated/SimpleSource.java - or in batch with the rewrite script: NAMESPACE=generated cd $NAMESPACE for i in *.java ;do ../../rewrite.sh $i ../$NAMESPACE/ddi/$i ;done The generated code can now be used on android with simple. Some things may need to be fixed, since I didn't test yet with an XSD covering all concepts, and because simpleframework defaults to require all elements (opposed to jaxb). Expect fixes for emply lists, and enumerations of strings (Android does not seem to return valueOf correctly when casing of remaining letters does not match enum name). Kind regards, Dennis * Roger Lee <Ro...@L2...> [700101 01:00]: > Been using JAXB to test some XML parsing. Now I need to deploy the > solution to an Android App. Does SimpleXML have or recommend a tool to > generate the Java Classes from an Marshaling similar to the JDK's XJC? > TIA |
|
From: Niall G. - Y. <Nia...@yi...> - 2014-04-29 00:16:42
|
Hi, There is currently no tool to generate java classes. However a simple search and replace of JAXB annotations on any generated code should be workable. Niall From: Roger Lee [mailto:Ro...@L2...] Sent: 29 April 2014 01:33 To: sim...@li... Subject: [Simple-support] Does SimpleXML have its own version of 'XJC'? Been using JAXB to test some XML parsing. Now I need to deploy the solution to an Android App. Does SimpleXML have or recommend a tool to generate the Java Classes from an Marshaling similar to the JDK's XJC? TIA |
|
From: Roger L. <Ro...@L2...> - 2014-04-28 15:51:25
|
Been using JAXB to test some XML parsing. Now I need to deploy the solution to an Android App. Does SimpleXML have or recommend a tool to generate the Java Classes from an Marshaling similar to the JDK's XJC? TIA |
|
From: Boris G. <bo...@gl...> - 2014-03-26 14:14:46
|
Hi Niall Thank you for your really, so would i need converter on userInfo or on address? Also is there a good sample for this, i am kind of new to Java. UserInfo contains much more info witch get deserialized just fine, it just address i need to get Address in to the right variable depending on Attribute. Thank you. Boris On 3/26/2014 12:59 AM, Niall Gallagher - Yieldbroker wrote: > > Hi, > > You would have to write a Converter for this. This requires you implement > > http://simple.sourceforge.net/download/stream/doc/javadoc/org/simpleframework/xml/convert/Converter.html > > Niall > > *From:*Boris Gligich [mailto:bo...@gl...] > *Sent:* 26 March 2014 14:31 > *To:* sim...@li... > *Subject:* [Simple-support] Multiple Elements with same name, > different Attributes > > Hi All, thank you for support and great product. > > > I have following XML > > <userInfo> > <address type="home"> > <a>123 Home Way</a> > </address> > <address type="office"> > <a>212 city street</a> > </address> > </userInfo> > > > and this Class: > > public class userInfo{ > String home; > String office; > } > > > And i have no idea how to accomplish this, as @path doesn't support attribute filtering, please help. > > Also order of address is not guaranteed, it could be in any order... > > Thank you. > > -- > Boris |
|
From: Niall G. - Y. <Nia...@yi...> - 2014-03-26 04:59:12
|
Hi, You would have to write a Converter for this. This requires you implement http://simple.sourceforge.net/download/stream/doc/javadoc/org/simpleframework/xml/convert/Converter.html Niall From: Boris Gligich [mailto:bo...@gl...] Sent: 26 March 2014 14:31 To: sim...@li... Subject: [Simple-support] Multiple Elements with same name, different Attributes Hi All, thank you for support and great product. I have following XML <userInfo> <address type="home"> <a>123 Home Way</a> </address> <address type="office"> <a>212 city street</a> </address> </userInfo> and this Class: public class userInfo{ String home; String office; } And i have no idea how to accomplish this, as @path doesn't support attribute filtering, please help. Also order of address is not guaranteed, it could be in any order... Thank you. -- Boris |
|
From: Boris G. <bo...@gl...> - 2014-03-26 03:44:23
|
Hi All, thank you for support and great product.
I have following XML
<userInfo>
<address type="home">
<a>123 Home Way</a>
</address>
<address type="office">
<a>212 city street</a>
</address>
</userInfo>
and this Class:
public class userInfo{
String home;
String office;
}
And i have no idea how to accomplish this, as @path doesn't support attribute filtering, please help.
Also order of address is not guaranteed, it could be in any order...
Thank you.
--
Boris
|
|
From: Tomáš P. <tom...@at...> - 2014-03-07 14:28:52
|
Sorry, my fault, it must be
@Path("SummaryReservations")
@Attribute(name = "Count")
int summaryRservationsCount;
@Path("SummaryReservations/Filter/FilterByType")
@Attribute(name = "Count")
int filterByTypeCount;
@Path("SummaryReservations/Filter/FilterByDateLimit")
@Attribute(name = "Count")
int filterByDateLimitCount;
@Path("SummaryReservations/Filter/FilterByAll")
@Attribute(name = "Count")
int filterByAllCount;
--
Ing. Tomáš Procházka
2014-03-07 15:20 GMT+01:00 Tomáš Procházka <tom...@at...>:
> I have small problem
>
> I have this XML
>
> <Statistics>
> <SummaryReservations Count="34">
> <Filter>
> <FilterByType Count="34"/>
> <FilterByDateLimit Count="6"/>
> <FilterByAll Count="6"/>
> </Filter>
> </SummaryReservations>
> </Statistics>
>
>
> And thiss class
>
> public class Statistics {
>
> @Path("SummaryReservations")
> @Attribute(name = "Count")
> int summaryRservationsCount;
>
> @Path("Filter/FilterByType")
> @Attribute(name = "Count")
> int filterByTypeCount;
>
> @Path("Filter/FilterByDateLimit")
> @Attribute(name = "Count")
> int filterByDateLimitCount;
>
> @Path("Filter/FilterByAll")
> @Attribute(name = "Count")
> int filterByAllCount;
>
> But only summaryRservationsCount is filled, all other fields stay at 0
> Do somebody know why?
>
>
|
|
From: Tomáš P. <tom...@at...> - 2014-03-07 14:20:40
|
I have small problem
I have this XML
<Statistics>
<SummaryReservations Count="34">
<Filter>
<FilterByType Count="34"/>
<FilterByDateLimit Count="6"/>
<FilterByAll Count="6"/>
</Filter>
</SummaryReservations>
</Statistics>
And thiss class
public class Statistics {
@Path("SummaryReservations")
@Attribute(name = "Count")
int summaryRservationsCount;
@Path("Filter/FilterByType")
@Attribute(name = "Count")
int filterByTypeCount;
@Path("Filter/FilterByDateLimit")
@Attribute(name = "Count")
int filterByDateLimitCount;
@Path("Filter/FilterByAll")
@Attribute(name = "Count")
int filterByAllCount;
But only summaryRservationsCount is filled, all other fields stay at 0
Do somebody know why?
|
|
From: Paul J. <pa...@pa...> - 2014-02-14 12:31:41
|
Hi,
Thanks for the tips so far. For most of the issues I raised I now have
workarounds that will suffice. And I'm going to investigate JSON
serialisation shortly.
However, there are two issues that I still need some help with:
1) Maps with inline values
If I have a field like this:
@ElementMap(inline=true, attribute=true)
Map<String,VarInfo> sinks = new HashMap<String,VarInfo>();
It produces XML like this:
<entry key="xss">
<varInfo>
<field>jim</field>
<field2>bob</field2>
</varInfo>
</entry>
I want XML like this:
<varInfo key="xss">
<field>jim</field>
<field2>bob</field2>
</varInfo>
I did propose a hack to write this correctly, but it breaks reading - and I
can't see how to fix that. Also, there is a teasing note in Entry.java
saying "value objects can be written inline if desired" - so I think there
is a way to do it, I've just not figured it out yet.
2) Default values
I want to have a field like:
@Attribute(default=true)
boolean myField;
Now, when writing, if myField is true, then I want to skip the field. And
when reading, if the attribute it missing, I want to use the default value.
Note that "empty" does NOT have these semantics.
I realise this is probably a new feature, but it would be extremely helpful
to me, in keeping the generated XML concise. I have considered putting this
at other parts in my app (e.g. just letting myField be null and handling
that appropriately) but it really would help to have Simple do this.
Any input would be appreciated,
Paul
|
|
From: Lumsdon, H. <Hug...@bl...> - 2014-02-13 16:56:49
|
Hi Niall,
We want to ignore every element - so a converter isn't practical.
Actually I was thinking that, unless I'm completely misunderstanding things, the version annotation / attribute pretty much does what we want - however I'd rather leave this for actual versioning. Having a similar root attribute that is just a Boolean would be good.
Thanks.
-----Original Message-----
From: Niall Gallagher [mailto:gal...@ya...]
Sent: 05 February 2014 07:28
To: sim...@li...; Lumsdon, Hugo
Subject: Re: [Simple-support] Dynamically turn off strict mode
Hi,
I am afraid there is no way to do this. The only thing I could suggest is to use a converter for the parts you want to parse in non-strict way.
Niall
--------------------------------------------
On Tue, 4/2/14, Lumsdon, Hugo <Hug...@bl...> wrote:
Subject: [Simple-support] Dynamically turn off strict mode
To: "sim...@li..." <sim...@li...>
Received: Tuesday, 4 February, 2014, 9:46 AM
Hi,
We’re after a way to turn
off strict mode dynamically, based on an attribute in the root element of the source XML document. e.g.
<contentType
dummy=”true”>
i.e. if the “dummy”
attribute is set to true we want to be able to make all fields / attributes optional – equivalent to called Serializer.read(x,x, false) – but dynamically.
Any suggestions how best to do
this?
Thanks,
Hugo.
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 and BlackRock Investment Management (UK) Limited are authorised and regulated by the Financial Conduct Authority. Registered in England No.
796793 and No. 2020394 respectively. BlackRock Life Limited is authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and Prudential Regulation Authority. Registered in England No. 2223202.
Registered Offices: Drapers Gardens, 12 Throgmorton Avenue, London EC2N 2DL. BlackRock International Limited is authorised and regulated by the Financial Conduct Authority and is a registered investment adviser with the Securities and Exchange Commission (SEC). Registered in Scotland No.
SC160821. Registered Office: 40 Torphichen Street, Edinburgh, EH3 8JB.
© 2013 BlackRock, Inc. All Rights reserved.
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
-----Inline Attachment Follows-----
_______________________________________________
Simple-support mailing list
Sim...@li...
https://lists.sourceforge.net/lists/listinfo/simple-support
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 and BlackRock Investment Management (UK) Limited are authorised and regulated by the Financial Conduct Authority. Registered in England No. 796793 and No. 2020394 respectively. BlackRock Life Limited is authorised by the Prudential Regulation Authority and regulated by the Financial Conduct Authority and Prudential Regulation Authority. Registered in England No. 2223202. Registered Offices: Drapers Gardens, 12 Throgmorton Avenue, London EC2N 2DL. BlackRock International Limited is authorised and regulated by the Financial Conduct Authority and is a registered investment adviser with the Securities and Exchange Commission (SEC). Registered in Scotland No. SC160821. Registered Office: 40 Torphichen Street, Edinburgh, EH3 8JB.
© 2013 BlackRock, Inc. All Rights reserved.
|
|
From: Niall G. - Y. <Nia...@yi...> - 2014-02-12 22:15:42
|
There is no DefaultConverter nor is there ever likely to be, one thing you can do with a converter which may help is you can give it a reference to the Serializer and push through objects again with the outputnode or inputnode. There are examples in the test cases of this. There is also an empty attribute on @Text and @Attribute that can set defaults.
/**
* This is used to provide a default value for the attribute if
* the annotated field or method is null. This ensures the the
* serialization process writes the attribute with a value even
* if the value is null, and allows deserialization to determine
* whether the value within the object was null or not.
*
* @return this returns the default attribute value to use
*/
String empty() default "";
From: Paul Johnston [mailto:pa...@pa...]
Sent: 13 February 2014 07:52
To: sim...@li...
Subject: [Simple-support] Default converter & default values
Hi,
Thanks for the tips on JSON. I haven't looked into them just yet; will do shortly. In the meantime, I have a couple more questions:
1) Is there a DefaultConverter I can inherit from?
When writing a Converter I often find I only want to explicitly set an attribute or two, and would otherwise like to use the default conversion behaviour. It would be helpful if I could subclass something like DefaultConverter and call super.write() when I need.
I'm aware that I can kind of get this behaviour using a Strategy - in fact, that's what I'm doing now. But I'd prefer to use a Converter because then I can keep serialisation logic with the class that is being serialised, rather than having a central serialisation class.
2) Is there a way to have default values?
I have a few classes with a number of boolean attributes. 95% of the time these fields are at their default value and it would make the XML much more concise to omit them. The semantics I'd like are that when writing, the node is only generated if the value does not match the default. And when reading, if the node is not present, then the default is used.
Any hints appreciated,
Paul
|
|
From: Paul J. <pa...@pa...> - 2014-02-12 20:52:14
|
Hi, Thanks for the tips on JSON. I haven't looked into them just yet; will do shortly. In the meantime, I have a couple more questions: 1) Is there a DefaultConverter I can inherit from? When writing a Converter I often find I only want to explicitly set an attribute or two, and would otherwise like to use the default conversion behaviour. It would be helpful if I could subclass something like DefaultConverter and call super.write() when I need. I'm aware that I can kind of get this behaviour using a Strategy - in fact, that's what I'm doing now. But I'd prefer to use a Converter because then I can keep serialisation logic with the class that is being serialised, rather than having a central serialisation class. 2) Is there a way to have default values? I have a few classes with a number of boolean attributes. 95% of the time these fields are at their default value and it would make the XML much more concise to omit them. The semantics I'd like are that when writing, the node is only generated if the value does not match the default. And when reading, if the node is not present, then the default is used. Any hints appreciated, Paul |