simple-support Mailing List for Simple (Page 75)
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: Alan G. <al...@bl...> - 2008-06-01 18:39:44
|
It's not jumping out at me. Is there an interface where you can write multiple objects to one file? XStream has object streams for this purpose... http://xstream.codehaus.org/objectstream.html It surrounds a series of objects in an enclosing element. Alan Gutierrez -- Alan Gutierrez | al...@bl... | http://blogometer.com/ | 504 717 1428 Think New Orleans | http://thinknola.com/ |
|
From: Kevin J. <kjo...@in...> - 2008-05-30 06:18:54
|
this works great - thanks!
-kevin
On May 28, 2008, at 12:01 AM, Timo Rumland wrote:
> Hi Kevin,
>
> the following code produces exactly the result you desire:
>
> ----------------------------
>
> public class SimpleXMLTest {
>
> @Root
> private class Event {
>
> @Text
> private String text;
>
> public Event( String text ) {
> this.text = text;
> }
>
> public String getText() {
> return text;
> }
> }
>
> @Root( name = "events" )
> private class EventList {
>
> @ElementList( inline = true )
> private List< Event > events = new ArrayList< Event >();
>
> public List< Event > getEvents() {
> return events;
> }
> }
>
> public SimpleXMLTest() throws Exception {
>
> EventList list = new EventList();
>
> list.getEvents().add( new Event( "foo" ) );
> list.getEvents().add( new Event( "bar" ) );
>
> Serializer serializer = new Persister();
> serializer.write( list, System.out );
> }
>
> public static void main( String[] args ) throws Exception {
> new SimpleXMLTest();
> }
> }
> ----------------------------
>
>
> Please have a look at the "name" and "inline" annotation parameters -
> these control the "format" of the XML, so it looks like your XML
> example.
>
>
> Hope that helps
>
>
> Regards,
> Timo
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Timo R. <cr...@ol...> - 2008-05-28 07:02:06
|
Hi Kevin,
the following code produces exactly the result you desire:
----------------------------
public class SimpleXMLTest {
@Root
private class Event {
@Text
private String text;
public Event( String text ) {
this.text = text;
}
public String getText() {
return text;
}
}
@Root( name = "events" )
private class EventList {
@ElementList( inline = true )
private List< Event > events = new ArrayList< Event >();
public List< Event > getEvents() {
return events;
}
}
public SimpleXMLTest() throws Exception {
EventList list = new EventList();
list.getEvents().add( new Event( "foo" ) );
list.getEvents().add( new Event( "bar" ) );
Serializer serializer = new Persister();
serializer.write( list, System.out );
}
public static void main( String[] args ) throws Exception {
new SimpleXMLTest();
}
}
----------------------------
Please have a look at the "name" and "inline" annotation parameters -
these control the "format" of the XML, so it looks like your XML
example.
Hope that helps
Regards,
Timo
|
|
From: Kevin J. <ke...@tr...> - 2008-05-28 04:51:30
|
So I determined that using the "ElementArray" annotation type will do
the trick, however - is there a way to suppress the "length" attribute
from serializing to the XML?
<events length="2">
<event>Event1</event>
<event>Event2</event>
</events>
thanks,
-kevin
On May 27, 2008, at 8:53 PM, Kevin Johnson wrote:
> Hi,
>
> I'm trying to serialize objects into XML with the following (example)
> resulting output:
>
> <events>
> <event>Foo1</event>
> <event>Foo2</event>
> <event>etc</event>
> </events>
>
> Is this possible with simple xml? I can't seem to find the right
> constructs to make this work...
>
> thanks,
>
> -kevin
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
|
|
From: Kevin J. <ke...@tr...> - 2008-05-28 03:53:05
|
Hi, I'm trying to serialize objects into XML with the following (example) resulting output: <events> <event>Foo1</event> <event>Foo2</event> <event>etc</event> </events> Is this possible with simple xml? I can't seem to find the right constructs to make this work... thanks, -kevin |
|
From: Niall G. <gal...@ya...> - 2008-05-20 18:41:53
|
Hi,
If anyone on this list has received spam, all
non-subscribers are now filtered as potential spam, so
this should not happen any more.
Regards,
Niall
|
|
From: Niall G. <gal...@ya...> - 2008-05-20 18:31:31
|
Hi Lorenzo, One issue with serializing strings is that an empty string is null. See: http://simple.sourceforge.net/download/stream/report/cobertura/org.simpleframework.xml.stream.NodeReader.html Is this a handwritten XML document or is this one that was serialized and can not be deserialized? If so then this is a bug I will have to tend to. To fix this you can make a change in this file: http://simple.sourceforge.net/download/stream/report/cobertura/org.simpleframework.xml.graph.ReadGraph.html Such that if it is null then it returns a Reference oject instead of throwing an exception. It should return. return new Reference(null, real); This should sort out the issue, however if references are being created to a null value this is a bug. Could you let me know if this is the case? Hope this helps, Niall --- Lorenzo Dal Col <lor...@gm...> wrote: > Hello, I'm trying to use Simple XML Serialization > for saving a big > object into files. > I have circular references, so I use CycleStrategy. > > The problem is that if I save some fields that are > empty Strings, it > uses only one object, all the others are references: > > <tables id="7"> > <entry> > <string id="8">m_units</string> > <tableInfo id="9"> > <fields id="10"> > [...] > <entry> > <string id="14">descrizione</string> > <fieldInfo id="15"> > <fieldName reference="14"/> > <columnDefault > id="16"></columnDefault> > <isNullable>false</isNullable> > <dataType id="17">STRING</dataType> > <parentTable reference="9"/> > </fieldInfo> > </entry> > [...] > <entry> > <string id="151">ragsoc</string> > <fieldInfo id="152"> > <fieldName reference="151"/> > <columnDefault reference="16"/> > <isNullable>false</isNullable> > <dataType reference="17"/> > <parentTable reference="127"/> > </fieldInfo> > </entry> > [...] > > But when I try to load this I get: Invalid reference > '16' found. > Am I doing something wrong? > > the Object I'm trying to save is like this: > > @Root > public class FieldInfo { > @Element(required=false) > public String fieldName; > @Element(required=false) > public String columnDefault; > @Element(required=false) > public boolean isNullable; > @Element(required=false) > public DATA_TYPE dataType; > @Element(required=false) > public TableInfo parentTable; > } > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio > 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > |
|
From: Collin D. <tev...@si...> - 2008-05-17 13:02:32
|
Joyful night,dear Friend!
=====================
; ; ; Do you want to destroy the spyware that is lurking on your hard drive?
+ Would you like to restore the safety and security of your PC?
^^^ Then you need the protection
\ \ \>>> RECOMMENDED BY SECURITY EXPERTS
http://privacy-scanner.com/1/index.php?353
=====================
state, to fly out of Mammoth Snuff-boxes206
|
|
From: Michael B. <ter...@ya...> - 2008-05-14 13:22:29
|
Solar night,dear Friend!
================================
&& Do you want to destroy the spyware that is lurking on your hard drive?
<< Would you like to restore the safety and security of your PC?
))) Then you need the protection
"">>> RECOMMENDED BY SECURITY EXPERTS
http://geocities.com/peczoygkn38/
================================
crammed with surprises; in short, as 23
|
|
From: Niall G. <gal...@ya...> - 2008-05-13 17:48:30
|
Hi, To do what you are saying you will have to modify the Transformer class to add the types you mention. I have been trying to improve this situation and have already started working on an XML format to specify annotations, where you do not directly have access to the source code to annotated, or if you just want to keep your code and the XML serialization format separate. This should be complete soon enough, it is currently in a branch in the SVN repository. However it is not in a state that can be used as of yet. Niall --- Marten Bauer <mar...@go...> wrote: > Hello, > > I want to use simple xml to serialize my classes to > xml. > The project deals with geo information systems and > therefore we are using geometry classes of jts (java > topology suite, > http://www.vividsolutions.com/jts/jtshome.htm). > > How can I serialize this instances (classes)? > > My idea was to write my own transform class like > (code is written out of my brain!): > > class jtsGeomTransform implements > Transform<Geometry>{ > public String write(Geometry geom){ > return wktwriter.write(geom); > } > > pulbic Geometry read(String wkt){ > return wktreader.read(wkt); > } > } > > Where wktwriter/wktreader are parts of jts and > convert geometry > instances into Strings known as "well known text" > and back. The other > classes like LineString, Polygon, Point, > MultiLineString, MultiPolygon > are all derived from Geometry. > > Questions: > 1. Is this the recommend way to solve my problem? > 2. How can/must I add my transform classes to the > Persister? > > Thx for helping > Marten > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio > 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > |
|
From: Lorenzo D. C. <lor...@gm...> - 2008-05-13 13:59:11
|
Hello, I'm trying to use Simple XML Serialization for saving a big
object into files.
I have circular references, so I use CycleStrategy.
The problem is that if I save some fields that are empty Strings, it
uses only one object, all the others are references:
<tables id="7">
<entry>
<string id="8">m_units</string>
<tableInfo id="9">
<fields id="10">
[...]
<entry>
<string id="14">descrizione</string>
<fieldInfo id="15">
<fieldName reference="14"/>
<columnDefault id="16"></columnDefault>
<isNullable>false</isNullable>
<dataType id="17">STRING</dataType>
<parentTable reference="9"/>
</fieldInfo>
</entry>
[...]
<entry>
<string id="151">ragsoc</string>
<fieldInfo id="152">
<fieldName reference="151"/>
<columnDefault reference="16"/>
<isNullable>false</isNullable>
<dataType reference="17"/>
<parentTable reference="127"/>
</fieldInfo>
</entry>
[...]
But when I try to load this I get: Invalid reference '16' found.
Am I doing something wrong?
the Object I'm trying to save is like this:
@Root
public class FieldInfo {
@Element(required=false)
public String fieldName;
@Element(required=false)
public String columnDefault;
@Element(required=false)
public boolean isNullable;
@Element(required=false)
public DATA_TYPE dataType;
@Element(required=false)
public TableInfo parentTable;
}
|
|
From: Marten B. <mar...@go...> - 2008-05-10 14:42:07
|
Hello, I want to use simple xml to serialize my classes to xml. The project deals with geo information systems and therefore we are using geometry classes of jts (java topology suite, http://www.vividsolutions.com/jts/jtshome.htm). How can I serialize this instances (classes)? My idea was to write my own transform class like (code is written out of my brain!): class jtsGeomTransform implements Transform<Geometry>{ public String write(Geometry geom){ return wktwriter.write(geom); } pulbic Geometry read(String wkt){ return wktreader.read(wkt); } } Where wktwriter/wktreader are parts of jts and convert geometry instances into Strings known as "well known text" and back. The other classes like LineString, Polygon, Point, MultiLineString, MultiPolygon are all derived from Geometry. Questions: 1. Is this the recommend way to solve my problem? 2. How can/must I add my transform classes to the Persister? Thx for helping Marten |
|
From: Marten B. <mar...@go...> - 2008-05-10 12:10:40
|
Hello, I want to use simple xml to serialize my classes to xml. The project deals with geo information systems and therefore we are using geometry classes of jts (java topology suite, http://www.vividsolutions.com/jts/jtshome.htm). How can I serialize this instances (classes)? My idea was to write my own transform class like (code is written out of my brain!): class jtsGeomTransform implements Transform<Geometry>{ public String write(Geometry geom){ return wktwriter.write(geom); } pulbic Geometry read(String wkt){ return wktreader.read(wkt); } } Where wktwriter/wktreader are parts of jts and convert geometry instances into Strings known as "well known text" and back. The other classes like LineString, Polygon, Point, MultiLineString, MultiPolygon are all derived from Geometry. Questions: 1. Is this the recommend way to solve my problem? 2. How can/must I add my transform classes to the Persister? Thx for helping Marten |
|
From: Niall G. <gal...@ya...> - 2008-05-07 18:19:52
|
Hi,
This is true, however there is a reason for this and
that is that because each object is issued a validate
and commit callback using the @Validate and @Commit.
If the object is not fully deserialized then it can
not process the commit and validate correctly.
There is a work around and that is to deserialize
everything first queue the objects and references and
resolve them in traversal order. This however has the
side effect that everything must be deserialized first
before the objects are validated. So for very large
documents this is a little wasteful considering some
details might be invalid and the deserialization can
be terminated early. Perhaps this is a reasonable
compromise between functionality and correctness
though. Ill consider it for the next release.
Niall
--- Benoît Pointet <ben...@un...> wrote:
> Hi,
>
> I have the following cross-reference situation :
>
> <apples>
> <apple id="a1">
> <cake ref="c1">
> </apple>
> </apples>
> <cakes>
> <cake id="c1">
> <apple ref="a1">
> </cake>
> </cakes>
>
> And I thought that including a CyclicStrategy would
> do deserialize it
> into two objects, each being a member field of the
> other:
>
> strategy = new CycleStrategy("id", "ref");
> serializer = new Persister(strategy);
>
> However,
> the first reference (<cake ref="c1">) is not
> resolved and a
> CycleException is thrown.
>
> So it looks like Cycles are only meant to "go
> backward", not forward ?
>
> thanks,
> b.
>
>
-------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008
> JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still
> time to save $100.
> Use priority code J8TL2D2.
>
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
>
https://lists.sourceforge.net/lists/listinfo/simple-support
>
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
|
|
From: Niall G. <gal...@ya...> - 2008-05-07 18:03:25
|
Hi, The reason you are getting the null for the 'id' attribute is because the CycleStrategy removes the 'id' attributes from the XML element. If you want to keep them you would have to refactor or extend the CycleStrategy yourself. Or implement your own. Niall --- Timo Rumland <cr...@ol...> wrote: > Hello, > > I would like to build an XML file with this > framework for a simple > tree, where every node has a list of children and a > reference to it's > parent, basically no big deal. > > Now, I read the example on the tutorial page about > the cycle strategy. > There, the parent reference is always an XML > element, like this: > > > <child id="2" name="tom"> > <parent ref="1"/> > </child> > > > So the parent of the child with id 2 is an object > with id 1. > > What I want to know is, is it possible to have the > parent reference as > an attribute like this: > > > <node id="1" name="The father"> > <node id="2" name="The son" parent="1"> > </node> > > > Here, the node with id 1 is the parent of the > nodewith id 2. This is > denoted by the parent attribute. That attribute is > not required, as > can be seen from the node with id 1, which has no > parent attribute. > > I tried to deserialize is with a > > "Strategy strategy = new CycleStrategy( "id", > "parent" );" > > and got this error message: > > Exception in thread "main" > org.simpleframework.xml.load.AttributeException: > Value for > @org.simpleframework.xml.Attribute(name=, empty=, > required=true) on field 'id' is null > > > Is it possible to deserialize that XML? Or do I > always need to have a > parent references as XML Elements instead of > Attributes? > > > Thanks a lot for your help > > > Regards, > Timo > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 > JavaOne(SM) Conference > Don't miss this year's exciting event. There's still > time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ |
|
From: Benoît P. <ben...@un...> - 2008-05-02 08:42:40
|
Hi,
I have the following cross-reference situation :
<apples>
<apple id="a1">
<cake ref="c1">
</apple>
</apples>
<cakes>
<cake id="c1">
<apple ref="a1">
</cake>
</cakes>
And I thought that including a CyclicStrategy would do deserialize it
into two objects, each being a member field of the other:
strategy = new CycleStrategy("id", "ref");
serializer = new Persister(strategy);
However,
the first reference (<cake ref="c1">) is not resolved and a
CycleException is thrown.
So it looks like Cycles are only meant to "go backward", not forward ?
thanks,
b.
|
|
From: Timo R. <cr...@ol...> - 2008-05-01 20:54:26
|
Hello,
I would like to build an XML file with this framework for a simple
tree, where every node has a list of children and a reference to it's
parent, basically no big deal.
Now, I read the example on the tutorial page about the cycle strategy.
There, the parent reference is always an XML element, like this:
<child id="2" name="tom">
<parent ref="1"/>
</child>
So the parent of the child with id 2 is an object with id 1.
What I want to know is, is it possible to have the parent reference as
an attribute like this:
<node id="1" name="The father">
<node id="2" name="The son" parent="1">
</node>
Here, the node with id 1 is the parent of the nodewith id 2. This is
denoted by the parent attribute. That attribute is not required, as
can be seen from the node with id 1, which has no parent attribute.
I tried to deserialize is with a
"Strategy strategy = new CycleStrategy( "id", "parent" );"
and got this error message:
Exception in thread "main" org.simpleframework.xml.load.AttributeException: Value for
@org.simpleframework.xml.Attribute(name=, empty=, required=true) on field 'id' is null
Is it possible to deserialize that XML? Or do I always need to have a
parent references as XML Elements instead of Attributes?
Thanks a lot for your help
Regards,
Timo
|
|
From: Niall G. <gal...@ya...> - 2008-04-28 21:29:05
|
Hi,
Yes, I can understand why this might seem strange.
However, Java generics are not reified. Which means
that template types are not kept after compilaion. So
the template type "Value" cannot be extracted through
reflection. Other generified languages such as C# can
do much better with this type of construct. However,
in the interest of backward compatibility Java decided
that erasure of template types was the way to go.
There is no way around this. Template types do not
work. As for the Object declaration, all objects are
considered composite types. That is it will not be
considered a primitive. Is you want your map to
contain a varying array of primitive types consider
storing them as strings.
You could use the
org.simpleframework.xml.transform.Transformer to help
you with this. The
org.simpleframework.xml.load.Factory provides some
documentation on why primitives can not be stored as
primitives.
Hope this helps,
Niall
--- Jas...@sc... wrote:
> Hi,
>
> Really like the looks of the library, seems very
> neat - but I'm having a
> problem setting up.
>
> When I run the following:
>
> @Root
> public class TestXML<Value>
> {
> @ElementMap
> Map<String, Value> map;
>
> TestXML()
> {
> map = new HashMap<String, Value>();
> }
>
> public static void main(String[] args)
> throws Exception
> {
> TestXML<Double> object = new
> TestXML<Double>();
> object.map.put("One", 1.0);
> object.map.put("Two", 2.0);
>
> Serializer serializer = new
> Persister();
> serializer.write(object, new
> File("test.xml"));
> }
> }
>
> I get:
>
> Exception in thread "main"
> java.lang.NullPointerException
> at
> org.simpleframework.xml.load.Factory.isPrimitive(
> Factory.java:213)
> at
>
org.simpleframework.xml.load.Entry.getValue(Entry.java:191)
> at
> org.simpleframework.xml.load.CompositeMap.<init>(
> CompositeMap.java:89)
> at
>
org.simpleframework.xml.load.ElementMapLabel.getConverter(
> ElementMapLabel.java:101)
> at
>
org.simpleframework.xml.load.CacheLabel.getConverter(
> CacheLabel.java:135)
> at
> org.simpleframework.xml.load.Composite.writeElement(
> Composite.java:829)
> at
>
org.simpleframework.xml.load.Composite.writeElements(
> Composite.java:728)
> at
>
org.simpleframework.xml.load.Composite.write(Composite.java:666
> )
> at
>
org.simpleframework.xml.load.Composite.write(Composite.java:644
> )
> at
>
org.simpleframework.xml.load.Traverser.write(Traverser.java:206
> )
> at
>
org.simpleframework.xml.load.Traverser.write(Traverser.java:183
> )
> at
>
org.simpleframework.xml.load.Traverser.write(Traverser.java:161
> )
> at
>
org.simpleframework.xml.load.Persister.write(Persister.java:769
> )
> at
>
org.simpleframework.xml.load.Persister.write(Persister.java:751
> )
> at
>
org.simpleframework.xml.load.Persister.write(Persister.java:732
> )
> at
>
org.simpleframework.xml.load.Persister.write(Persister.java:848
> )
> at
>
org.simpleframework.xml.load.Persister.write(Persister.java:830
> )
> at
>
org.simpleframework.xml.load.Persister.write(Persister.java:811
> )
> at
>
org.simpleframework.xml.load.Persister.write(Persister.java:790
> )
> at TestXML.main(TestXML.java:30)
>
> OK, so I guess it may be generics-related. It works
> fine if I change the
> generic Double to an explicit one. But this is a bit
> weird as the
> implementation of Map is itself generic?!
>
> To confuse me even more, changing this to an
> explicit Map<String, Object>
> gives the following unusable file:
>
> <testXML>
> <map class="java.util.HashMap">
> <entry>
> <string>Two</string>
> <object class="java.lang.Double"/>
> </entry>
> <entry>
> <string>One</string>
> <object class="java.lang.Double"/>
> </entry>
> </map>
> </testXML>
>
> i.e. It has lost the values of the Doubles....
>
>
>
> Jason Chown
> Sony Computer Entertainment Europe
> http://www.eu.playstation.com
>
>
**********************************************************************
> This email and any files transmitted with it are
> confidential and intended solely for the use of the
> individual or entity to whom they are addressed. If
> you have received this email in error please notify
> pos...@sc...
> This footnote also confirms that this email message
> has been checked for all known viruses.
> Sony Computer Entertainment Europe Limited
> Registered Office: 10 Great Marlborough Street,
> London W1F 7LP, United Kingdom
> Registered in England: 3277793
>
**********************************************************************
> >
-------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008
> JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still
> time to save $100.
> Use priority code J8TL2D2.
>
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone>
_______________________________________________
> Simple-support mailing list
> Sim...@li...
>
https://lists.sourceforge.net/lists/listinfo/simple-support
>
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
|
|
From: <Jas...@sc...> - 2008-04-28 19:39:04
|
Hi,
Really like the looks of the library, seems very neat - but I'm having a
problem setting up.
When I run the following:
@Root
public class TestXML<Value>
{
@ElementMap
Map<String, Value> map;
TestXML()
{
map = new HashMap<String, Value>();
}
public static void main(String[] args) throws Exception
{
TestXML<Double> object = new TestXML<Double>();
object.map.put("One", 1.0);
object.map.put("Two", 2.0);
Serializer serializer = new Persister();
serializer.write(object, new File("test.xml"));
}
}
I get:
Exception in thread "main" java.lang.NullPointerException
at org.simpleframework.xml.load.Factory.isPrimitive(
Factory.java:213)
at org.simpleframework.xml.load.Entry.getValue(Entry.java:191)
at org.simpleframework.xml.load.CompositeMap.<init>(
CompositeMap.java:89)
at org.simpleframework.xml.load.ElementMapLabel.getConverter(
ElementMapLabel.java:101)
at org.simpleframework.xml.load.CacheLabel.getConverter(
CacheLabel.java:135)
at org.simpleframework.xml.load.Composite.writeElement(
Composite.java:829)
at org.simpleframework.xml.load.Composite.writeElements(
Composite.java:728)
at org.simpleframework.xml.load.Composite.write(Composite.java:666
)
at org.simpleframework.xml.load.Composite.write(Composite.java:644
)
at org.simpleframework.xml.load.Traverser.write(Traverser.java:206
)
at org.simpleframework.xml.load.Traverser.write(Traverser.java:183
)
at org.simpleframework.xml.load.Traverser.write(Traverser.java:161
)
at org.simpleframework.xml.load.Persister.write(Persister.java:769
)
at org.simpleframework.xml.load.Persister.write(Persister.java:751
)
at org.simpleframework.xml.load.Persister.write(Persister.java:732
)
at org.simpleframework.xml.load.Persister.write(Persister.java:848
)
at org.simpleframework.xml.load.Persister.write(Persister.java:830
)
at org.simpleframework.xml.load.Persister.write(Persister.java:811
)
at org.simpleframework.xml.load.Persister.write(Persister.java:790
)
at TestXML.main(TestXML.java:30)
OK, so I guess it may be generics-related. It works fine if I change the
generic Double to an explicit one. But this is a bit weird as the
implementation of Map is itself generic?!
To confuse me even more, changing this to an explicit Map<String, Object>
gives the following unusable file:
<testXML>
<map class="java.util.HashMap">
<entry>
<string>Two</string>
<object class="java.lang.Double"/>
</entry>
<entry>
<string>One</string>
<object class="java.lang.Double"/>
</entry>
</map>
</testXML>
i.e. It has lost the values of the Doubles....
Jason Chown
Sony Computer Entertainment Europe
http://www.eu.playstation.com
**********************************************************************
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify pos...@sc...
This footnote also confirms that this email message has been checked for all known viruses.
Sony Computer Entertainment Europe Limited
Registered Office: 10 Great Marlborough Street, London W1F 7LP, United Kingdom
Registered in England: 3277793
**********************************************************************
|
|
From: Kevin J. <kjo...@in...> - 2008-04-23 04:20:17
|
I ran some more tests and sure enough it is working as designed. Must have been "developer fatigue" messing with my brain. Apologies for the confusion. thanks, -kevin On Apr 22, 2008, at 11:37 AM, Niall Gallagher wrote: > Hi > > Is the value an empty string? If it is then it will > come out with the elements. If this still does not > work then send me code that shows this, perhaps in the > form of a unit test. I find it unlikely that this is > an bug in the framework as this is very well tested. > > Niall > > --- Kevin Johnson <kjo...@in...> wrote: > >> thanks - i tried that, but didn't seem to work - it >> still inserts the >> given field's element, just with an empty value. >> >> -kevin >> >> On Apr 21, 2008, at 11:35 PM, Benoît Pointet wrote: >> >>> according to the tutorial >>> >>> >> > (http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#optional >>> ) >>> >>> try setting the element as optional, i.e. >>> >>>> class foo { >>>> @Element(required=false) >>>> private String bar; >>>> } >>> >>> >>> b. >>> >>> On 22 avr. 08, at 07:48, Kevin Johnson wrote: >>> >>>> Hi, >>>> >>>> When serializing an object that has a null data >> member, the resulting >>>> xml has an empty element in it. Is there a way >> to avoid this? >>>> >>>> For example: >>>> >>>> class foo { >>>> @Element >>>> private String bar; >>>> } >>>> >>>> >>>> if "bar" has a value of "2", the xml will look >> like this: >>>> >>>> <foo> >>>> <bar>2</bar> >>>> </foo> >>>> >>>> but if "bar" has a value of NULL, the xml will >> look like this: >>>> >>>> <foo> >>>> <bar></bar> >>>> </foo> >>>> >>>> Where I would prefer: >>>> >>>> <foo> >>>> </foo> >>>> >>>> Is this possible? >>>> >>>> thanks, >>>> >>>> -kevin >>>> >>>> >> > ------------------------------------------------------------------------- >>>> This SF.net email is sponsored by the 2008 >> JavaOne(SM) Conference >>>> Don't miss this year's exciting event. There's >> still time to save >>>> $100. >>>> Use priority code J8TL2D2. >>>> >> > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone >>>> _______________________________________________ >>>> Simple-support mailing list >>>> Sim...@li... >>>> >> > https://lists.sourceforge.net/lists/listinfo/simple-support >>> >>> >>> >> > ------------------------------------------------------------------------- >>> This SF.net email is sponsored by the 2008 >> JavaOne(SM) Conference >>> Don't miss this year's exciting event. There's >> still time to save >>> $100. >>> Use priority code J8TL2D2. >>> >> > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone >>> _______________________________________________ >>> Simple-support mailing list >>> Sim...@li... >>> >> > https://lists.sourceforge.net/lists/listinfo/simple-support >> >> >> > ------------------------------------------------------------------------- >> This SF.net email is sponsored by the 2008 >> JavaOne(SM) Conference >> Don't miss this year's exciting event. There's still >> time to save $100. >> Use priority code J8TL2D2. >> > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone >> _______________________________________________ >> Simple-support mailing list >> Sim...@li... >> > https://lists.sourceforge.net/lists/listinfo/simple-support >> > > > > > ____________________________________________________________________________________ > Be a better friend, newshound, and > know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ |
|
From: Niall G. <gal...@ya...> - 2008-04-22 18:38:04
|
Hi Is the value an empty string? If it is then it will come out with the elements. If this still does not work then send me code that shows this, perhaps in the form of a unit test. I find it unlikely that this is an bug in the framework as this is very well tested. Niall --- Kevin Johnson <kjo...@in...> wrote: > thanks - i tried that, but didn't seem to work - it > still inserts the > given field's element, just with an empty value. > > -kevin > > On Apr 21, 2008, at 11:35 PM, Benoît Pointet wrote: > > > according to the tutorial > > > > > (http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#optional > > ) > > > > try setting the element as optional, i.e. > > > >> class foo { > >> @Element(required=false) > >> private String bar; > >> } > > > > > > b. > > > > On 22 avr. 08, at 07:48, Kevin Johnson wrote: > > > >> Hi, > >> > >> When serializing an object that has a null data > member, the resulting > >> xml has an empty element in it. Is there a way > to avoid this? > >> > >> For example: > >> > >> class foo { > >> @Element > >> private String bar; > >> } > >> > >> > >> if "bar" has a value of "2", the xml will look > like this: > >> > >> <foo> > >> <bar>2</bar> > >> </foo> > >> > >> but if "bar" has a value of NULL, the xml will > look like this: > >> > >> <foo> > >> <bar></bar> > >> </foo> > >> > >> Where I would prefer: > >> > >> <foo> > >> </foo> > >> > >> Is this possible? > >> > >> thanks, > >> > >> -kevin > >> > >> > ------------------------------------------------------------------------- > >> This SF.net email is sponsored by the 2008 > JavaOne(SM) Conference > >> Don't miss this year's exciting event. There's > still time to save > >> $100. > >> Use priority code J8TL2D2. > >> > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > >> _______________________________________________ > >> Simple-support mailing list > >> Sim...@li... > >> > https://lists.sourceforge.net/lists/listinfo/simple-support > > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by the 2008 > JavaOne(SM) Conference > > Don't miss this year's exciting event. There's > still time to save > > $100. > > Use priority code J8TL2D2. > > > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > > _______________________________________________ > > Simple-support mailing list > > Sim...@li... > > > https://lists.sourceforge.net/lists/listinfo/simple-support > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 > JavaOne(SM) Conference > Don't miss this year's exciting event. There's still > time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ |
|
From: Kevin J. <kjo...@in...> - 2008-04-22 14:06:03
|
thanks - i tried that, but didn't seem to work - it still inserts the given field's element, just with an empty value. -kevin On Apr 21, 2008, at 11:35 PM, Benoît Pointet wrote: > according to the tutorial > > (http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#optional > ) > > try setting the element as optional, i.e. > >> class foo { >> @Element(required=false) >> private String bar; >> } > > > b. > > On 22 avr. 08, at 07:48, Kevin Johnson wrote: > >> Hi, >> >> When serializing an object that has a null data member, the resulting >> xml has an empty element in it. Is there a way to avoid this? >> >> For example: >> >> class foo { >> @Element >> private String bar; >> } >> >> >> if "bar" has a value of "2", the xml will look like this: >> >> <foo> >> <bar>2</bar> >> </foo> >> >> but if "bar" has a value of NULL, the xml will look like this: >> >> <foo> >> <bar></bar> >> </foo> >> >> Where I would prefer: >> >> <foo> >> </foo> >> >> Is this possible? >> >> thanks, >> >> -kevin >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference >> Don't miss this year's exciting event. There's still time to save >> $100. >> Use priority code J8TL2D2. >> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone >> _______________________________________________ >> Simple-support mailing list >> Sim...@li... >> https://lists.sourceforge.net/lists/listinfo/simple-support > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save > $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Benoît P. <ben...@un...> - 2008-04-22 06:36:15
|
according to the tutorial (http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#optional ) try setting the element as optional, i.e. > class foo { > @Element(required=false) > private String bar; > } b. On 22 avr. 08, at 07:48, Kevin Johnson wrote: > Hi, > > When serializing an object that has a null data member, the resulting > xml has an empty element in it. Is there a way to avoid this? > > For example: > > class foo { > @Element > private String bar; > } > > > if "bar" has a value of "2", the xml will look like this: > > <foo> > <bar>2</bar> > </foo> > > but if "bar" has a value of NULL, the xml will look like this: > > <foo> > <bar></bar> > </foo> > > Where I would prefer: > > <foo> > </foo> > > Is this possible? > > thanks, > > -kevin > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save > $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support |
|
From: Kevin J. <kjo...@in...> - 2008-04-22 05:48:48
|
Hi,
When serializing an object that has a null data member, the resulting
xml has an empty element in it. Is there a way to avoid this?
For example:
class foo {
@Element
private String bar;
}
if "bar" has a value of "2", the xml will look like this:
<foo>
<bar>2</bar>
</foo>
but if "bar" has a value of NULL, the xml will look like this:
<foo>
<bar></bar>
</foo>
Where I would prefer:
<foo>
</foo>
Is this possible?
thanks,
-kevin
|
|
From: Niall G. <gal...@ya...> - 2008-04-16 18:42:41
|
Hi Timo,
No this is not a limitation, it is a feature. This is
because the "class" attribute is added on top of the
class schema attributes and elements. These attributes
are added via Strategy objects, which is given the
NodeMap for the XML element. The straegy adds the
following.
NodeMap.add("class", object.getClass().getName());
This allows you to implement your own strategy to
modify these attributes as they may not suit all
purposes. For example, take a C++, PHP or C#
application that wants to read XML generated from your
Java app. The "class" annotations are not very useful
here. You'll want something like.
type="name"
instead of
class="com.domain.framework.NameObject"
The Strategy object allows you to perform these
manipulations. Take a look at the CycleStrategy which
allows you to keep track of even the most complext of
object graphs, ensuring the cycles are tracked with
"id" attributes. Currently there is not many
implementations, but its easy to write your own
Strategy to automatically generate and replace "class"
attributes.
Hope this helps,
Niall
--- Timo Rumland <cr...@ol...> wrote:
> Hello,
>
> I have a question regarding the persister callback
> session map and the
> template system (appropriate documentation section
> is "Maintaining
> state between persister callbacks").
>
> I have a XML file, which looks like this:
>
> -------------
> <MyObjects>
> <MyInterface
>
class="net.test.lib.concurrent.theme.InterfaceImpl1"/>
> <MyInterface
>
class="net.test.lib.concurrent.theme.InterfaceImpl2"/>
> <MyInterface
>
class="net.test.lib.concurrent.theme.InterfaceImpl3"/>
> </MyObjects>
> -------------
>
> The XML above is of course only a simplification of
> the real
> structure. There are a lot of entries for
> "<MyInterface...", and every
> entry has the same packge but a different class (it
> is always
> "net.test.lib.concurrent.theme.").
>
> Now it would be really nice to replace those package
> declarations with
> a template variable, so the XML looks like this:
>
> -------------
> <MyObjects>
> <property name="package"
> value="net.test.lib.concurrent.theme"/>
>
> <MyInterface class="${package}.InterfaceImpl1"/>
> <MyInterface class="${package}.InterfaceImpl2"/>
> <MyInterface class="${package}.InterfaceImpl3"/>
> </MyObjects>
> -------------
>
> That way I could easily change the package name and
> must not touch
> every "<MyInterface..." line. In the documentation
> you write "The
> templating engine has access to all details placed
> into the session
> map object.", but this seems only to be true for
> other "normal"
> elements, not the "class" attribute of an element.
>
> Is this a real limitation, or even a bug?
>
> (The framework just does not substitute ${package},
> so it tries to
> load the class "${package}.InterfaceImpl1" instead
> of
> "net.test.lib.concurrent.theme.InterfaceImpl1").
>
> I'm using the XML file to configure a rather complex
> system (like a
> build system) and this feature would be extremely
> useful in many
> cases for me (and for others, too, for sure).
>
> If this is a limitation, may you think about
> implementing this feature
> so the template system also works for those "class"
> attributes in the
> XML elements? That would be great!
>
>
> Best regards,
> Timo
>
>
>
-------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008
> JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still
> time to save $100.
> Use priority code J8TL2D2.
>
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
>
https://lists.sourceforge.net/lists/listinfo/simple-support
>
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
|