simple-support Mailing List for Simple (Page 65)
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: Patrice <pat...@sm...> - 2009-04-21 18:26:55
|
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. |
|
From: <Nia...@ub...> - 2009-04-21 14:37:47
|
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: Zvika M. <zv...@ti...> - 2009-04-21 14:07:55
|
hi, I'm serializing an object graph containing many database-retrieved(hibernate) entities, and they all have pre-generated ids. Is there a way of letting Simple use the object's builtin (database) id's for creating object references? Also, is there a way of using CycleStrategy only for certain properties or property types, (using annotations or any other way)? many thanks, Zvika |
|
From: <Nia...@ub...> - 2009-04-21 12:38:52
|
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: Patrice B. <pat...@sm...> - 2009-04-21 12:17:51
|
Hi (& thanks), I'm getting a NoSuchMethodException (...) <init>(). Just like mentionned in *[Simple-support] Problem deserializing an inner class <http://sourceforge.net/mailarchive/message.php?msg_name=48AF5691.5040103%40znyx.com>* From: Alan Deikman <Alan.Deikman@zn...> - 2008-08-23 00:15 java.lang.NoSuchMethodException: com.test.Outer$Inner.<init>() at java.lang.Class.getConstructor0(Class.java:2706) I don't have my IDE at hand right now so I can't copy/paste, but that's the exception. An I see you answered "The inner class needs to be static. Otherwise it can not be instantiated reflectively." But none of the sample in tutorial have this "public static" attribute for inner classes. And when I do make it public static, I still get the same exception. Niall Gallagher a écrit : > Hi, > > So what exception are you getting? > > Niall > > --- On Tue, 4/21/09, Patrice Bertrand <pat...@sm...> wrote: > > >> From: Patrice Bertrand <pat...@sm...> >> Subject: [Simple-support] obligation of "static public class" ? >> To: sim...@li... >> Date: Tuesday, April 21, 2009, 1:22 AM >> Hello, >> I see some persons mention a similar problem: an >> exception occuring >> when reading a list of elements. And I >> read Niall answering "you must >> declare a 'static public class' for the embedded >> items. So I changed >> my code to have both outer and inner classes in same file, >> with inner >> class declared as static public class within the first >> class, like this: >> >> @Root >> public class PropertyList { >> >> @ElementList >> private List<Entry> list; >> >> @Attribute >> private String name; >> >> public String getName() { >> return name; >> } >> >> public List getProperties() { >> return list; >> } >> >> @Root >> public static class Entry { >> >> @Attribute >> private String key; >> >> @Element >> private String value; >> >> public String getName() { >> return name; >> } >> >> public String getValue() { >> return value; >> } >> } >> >> } >> >> >> (I take this from the tutorial page, but with a minor >> change to embed >> "Entry" into "PropertyList" and make it static.) >> >> However, I still get the same exception when >> reading. What is exactly >> this obligation of a "public static class" and is it >> possible to find >> the rules that apply. The tutorial is VERY >> well done, for giving a >> overview of the possibilities, but is it possible that the >> sample code >> that are in the tutorial would not work ? >> >> Sorry for this beginner's question. I did >> go through the archive >> trying to find the answer (although search function seems >> to be >> unavailable). >> >> >> ------------------------------------------------------------------------------ >> 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 >> >> > > > > |
|
From: Niall G. <gal...@ya...> - 2009-04-21 12:00:26
|
Hi,
So what exception are you getting?
Niall
--- On Tue, 4/21/09, Patrice Bertrand <pat...@sm...> wrote:
> From: Patrice Bertrand <pat...@sm...>
> Subject: [Simple-support] obligation of "static public class" ?
> To: sim...@li...
> Date: Tuesday, April 21, 2009, 1:22 AM
> Hello,
> I see some persons mention a similar problem: an
> exception occuring
> when reading a list of elements. And I
> read Niall answering "you must
> declare a 'static public class' for the embedded
> items. So I changed
> my code to have both outer and inner classes in same file,
> with inner
> class declared as static public class within the first
> class, like this:
>
> @Root
> public class PropertyList {
>
> @ElementList
> private List<Entry> list;
>
> @Attribute
> private String name;
>
> public String getName() {
> return name;
> }
>
> public List getProperties() {
> return list;
> }
>
> @Root
> public static class Entry {
>
> @Attribute
> private String key;
>
> @Element
> private String value;
>
> public String getName() {
> return name;
> }
>
> public String getValue() {
> return value;
> }
> }
>
> }
>
>
> (I take this from the tutorial page, but with a minor
> change to embed
> "Entry" into "PropertyList" and make it static.)
>
> However, I still get the same exception when
> reading. What is exactly
> this obligation of a "public static class" and is it
> possible to find
> the rules that apply. The tutorial is VERY
> well done, for giving a
> overview of the possibilities, but is it possible that the
> sample code
> that are in the tutorial would not work ?
>
> Sorry for this beginner's question. I did
> go through the archive
> trying to find the answer (although search function seems
> to be
> unavailable).
>
>
> ------------------------------------------------------------------------------
> 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
>
|
|
From: Patrice B. <pat...@sm...> - 2009-04-21 08:56:43
|
Hello,
I see some persons mention a similar problem: an exception occuring
when reading a list of elements. And I read Niall answering "you must
declare a 'static public class' for the embedded items. So I changed
my code to have both outer and inner classes in same file, with inner
class declared as static public class within the first class, like this:
@Root
public class PropertyList {
@ElementList
private List<Entry> list;
@Attribute
private String name;
public String getName() {
return name;
}
public List getProperties() {
return list;
}
@Root
public static class Entry {
@Attribute
private String key;
@Element
private String value;
public String getName() {
return name;
}
public String getValue() {
return value;
}
}
}
(I take this from the tutorial page, but with a minor change to embed
"Entry" into "PropertyList" and make it static.)
However, I still get the same exception when reading. What is exactly
this obligation of a "public static class" and is it possible to find
the rules that apply. The tutorial is VERY well done, for giving a
overview of the possibilities, but is it possible that the sample code
that are in the tutorial would not work ?
Sorry for this beginner's question. I did go through the archive
trying to find the answer (although search function seems to be
unavailable).
|
|
From: Timo R. <cr...@ol...> - 2009-04-20 15:57:59
|
Hello Niall, > It is very easy to do this with Simple. Check out the following in > the tutorial. > ... oh shame on me, I really should have read that part of the tutorial :) Great that this is possible with the Simple Framework. Again, Simple has what I need :) Thanks a lot for that. Regards, Timo |
|
From: <Nia...@ub...> - 2009-04-20 14:36:35
|
Hi, It is very easy to do this with Simple. Check out the following in the tutorial. http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php# loosemap This will allow you to create objects which will parse only the annotations present on the class, and basically ignore/skip the rest. Niall -----Original Message----- From: Timo Rumland [mailto:cr...@ol...] Sent: 19 April 2009 00:14 To: sim...@li... Subject: [Simple-support] Deserialize only parts of a xml file Hello Simple users (and dev :), I'm faced with a (so I think) very common problem with a large number of serialized objects. I have to list all those objects in a JTable, with a few columns only showing some attributes of the serialized objects (let's say a name, a date and an ID). Now the first and easiest way is, just iteratate over all serialized xml files, deserialize each of them, get the needed attributes (name, date and ID) and create a table entry for it, then go on with the next xml file. Since the xml files each contains a lot more data than just name/date/ID, deserializing each of them is not memory efficient nor performant. What I need is some kind of streaming/parsing technology. So my question is, can I use the Simple Framework to do this, or can Simple only be used to fully deserialize an object? If Simple can't help me here, can you suggest another framework (I'm working with Java 6) to achieve my goal? Thanks a lot for your help! Regards, Timo ------------------------------------------------------------------------ ------ 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. |
|
From: Timo R. <cr...@ol...> - 2009-04-18 23:13:48
|
Hello Simple users (and dev :), I'm faced with a (so I think) very common problem with a large number of serialized objects. I have to list all those objects in a JTable, with a few columns only showing some attributes of the serialized objects (let's say a name, a date and an ID). Now the first and easiest way is, just iteratate over all serialized xml files, deserialize each of them, get the needed attributes (name, date and ID) and create a table entry for it, then go on with the next xml file. Since the xml files each contains a lot more data than just name/date/ID, deserializing each of them is not memory efficient nor performant. What I need is some kind of streaming/parsing technology. So my question is, can I use the Simple Framework to do this, or can Simple only be used to fully deserialize an object? If Simple can't help me here, can you suggest another framework (I'm working with Java 6) to achieve my goal? Thanks a lot for your help! Regards, Timo |
|
From: Fabian K. <fab...@we...> - 2009-04-12 14:11:23
|
Hi List,
I created two classes which could be useful for others aswell:
First, an Annotation:
/**
* Use this annotation to indicate that your class can be transformed.
*
* @author Fabian Kürten
* @version 0.1
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface Transformable {
/**
* The transformers type.
*
* @return the type
*/
public Class<? extends Transform<?>> type();
}
And second, the TransformMatcher:
/**
* This Matcher looks for the {@link Transformable} annotation to create a
* suitable {@link Transform}.
*
* @see Transformable
* @author Fabian Kürten
* @version 0.1
*/
public class TransformMatcher
implements
Matcher {
private final Matcher delegate;
/**
* Creates the Matcher.
*/
public TransformMatcher() {
this.delegate = null;
}
/**
* Creates the Matcher with a delegate Matcher.
*
* @param delegate the delegate will be called if no match could be found
*/
public TransformMatcher(Matcher delegate) {
this.delegate = delegate;
}
public Transform match(Class type) throws Exception {
Class<?> type2 = type;
Transformable t = type2.getAnnotation(Transformable.class);
if (t != null) {
Class<?> transformerClass = t.type();
Transform<?> transformer = (Transform<?>) transformerClass.newInstance();
return transformer;
} // t != null
if (this.delegate != null) {
return this.delegate.match(type);
} else {
return null;
}
}
}
The usage is quite simple, you have to use the Matcher of course:
Serializer serializer = new Persister(new TransformMatcher());
and annotate your class:
@Root
@Transformable(type=full.package.name.MyTransform.class)
public final class MyClass
I hope someone finds this useful.
Fabian
|
|
From: Fabian K. <fab...@we...> - 2009-04-12 14:11:22
|
Hi Group, hi Niall,
(I composed this mail on 06.April, but sent it later)
I just tried to deserialize an *empty* double Array:
@Attribute
public double[] data;
<className data="" />
Now the problem is a
Exception in thread "main" java.lang.NumberFormatException: empty String
What happens is this:
ArrayTransform will first Transform the data to a String array using a
split around ",". This will create the String array { "" } (one empty
String).
Now ArrayTransform will try to convert this to doubles, which fails.
The other way works just fine, an empty double array will be converted
to "".
In my opinion the empty String should be converted to the empty array.
I agree though, that maybe for Strings this is not the perfect Solution.
However, currently new String[] {} and new String[] {""} produce the
same serialization, which can't be desired either.
Fabian
|
|
From: Niall G. <gal...@ya...> - 2009-04-02 19:22:05
|
Hi,
Thank you, I will look in to this.
Regards,
Niall
--- On Thu, 4/2/09, Fabian Kürten <fab...@we...> wrote:
> From: Fabian Kürten <fab...@we...>
> Subject: [Simple-support] Name clash Exception on Matcher
> To: sim...@li...
> Date: Thursday, April 2, 2009, 11:58 AM
> Hi Niall,
>
> I just got this:
>
> Name clash: The method match(Class<T>) of type new
> Matcher(){} has the
> same erasure as match(Class) of type Matcher but does not
> override it.
>
> After partly understanding it[1], I think you could just
> change
> public Transform match(Class type) throws Exception;
> to
> public <T> Transform<T> match(Class<T>
> type) throws Exception;
> or something similiar.
>
> As far as I understand this will keep compability to the
> current version
> but allows additionally to use generics.
>
> Fabian
>
> [1]
> http://stackoverflow.com/questions/502614/type-erasure-overriding-and-generics
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
|
|
From: Fabian K. <fab...@we...> - 2009-04-02 18:55:27
|
Hi Niall,
I just got this:
Name clash: The method match(Class<T>) of type new Matcher(){} has the
same erasure as match(Class) of type Matcher but does not override it.
After partly understanding it[1], I think you could just change
public Transform match(Class type) throws Exception;
to
public <T> Transform<T> match(Class<T> type) throws Exception;
or something similiar.
As far as I understand this will keep compability to the current version
but allows additionally to use generics.
Fabian
[1]
http://stackoverflow.com/questions/502614/type-erasure-overriding-and-generics
|
|
From: <Nia...@ub...> - 2009-04-01 15:05:41
|
Hi,
This is because T does not exist. In java the generic type T used to
parameterize MyMap disappears after compilation. It's a process called
erasure and it means that the type can not be acquired reflectively at
runtime. There is talk of Java 7 resolving this issue but for Java 5 and
6 you will not be able to execute the code you have provided.
Niall
-----Original Message-----
From: Joe [mailto:fis...@ya...]
Sent: 01 April 2009 15:45
To: sim...@li...
Subject: [Simple-support] can't serialize an object which uses
aparametrized hashmap
Hi,
the following code throws an exception.
But if i replace T by String, serialization is no problem.
Why the parametrized version doesn't work?
Version: 2.0.4
import java.io.File;
import java.util.HashMap;
import org.simpleframework.xml.ElementMap;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
public class MyMap<T>
{
@ElementMap
private HashMap<T, String> map = new HashMap<T, String>();
public static void main(String[] args)
{
try
{
serialize(new MyMap<String>());
System.out.println("done");
}
catch (Exception e)
{
e.printStackTrace();
}
}
private static void serialize(Object data) throws Exception
{
Serializer serializer = new Persister();
File xmlFile = new File("test.xml");
serializer.write(data, xmlFile);
}
}
------------------------------------------------------------------------
------
_______________________________________________
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.
|
|
From: Joe <fis...@ya...> - 2009-04-01 14:45:16
|
Hi,
the following code throws an exception.
But if i replace T by String, serialization is no problem.
Why the parametrized version doesn't work?
Version: 2.0.4
import java.io.File;
import java.util.HashMap;
import org.simpleframework.xml.ElementMap;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
public class MyMap<T>
{
@ElementMap
private HashMap<T, String> map = new HashMap<T, String>();
public static void main(String[] args)
{
try
{
serialize(new MyMap<String>());
System.out.println("done");
}
catch (Exception e)
{
e.printStackTrace();
}
}
private static void serialize(Object data) throws Exception
{
Serializer serializer = new Persister();
File xmlFile = new File("test.xml");
serializer.write(data, xmlFile);
}
}
|
|
From: <Nia...@ub...> - 2009-04-01 08:23:16
|
Hi, Just create the attribute with an @Attribute annotation. For example @Attribute(required=false) private String schemaLocation; In this way the attribute will match your annotated field and there will be no exception. Also, if you do not like this, you can implement a org.simpleframework.xml.core.Strategy to remove the "schemaLocation" attribute. Niall -----Original Message----- From: Fabian Kürten [mailto:fab...@we...] Sent: 31 March 2009 20:36 To: sim...@li... Subject: [Simple-support] xsi:schemaLocation Hi List, I have an XML file, similiar to this snippet: <root xmlns="http://www.domain.org/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.domain.org/namespace root.xsd"> When i try to deserialize it, I get the following exception: org.simpleframework.xml.core.AttributeException: Attribute 'schemaLocation' does not exist at line -1 at org.simpleframework.xml.core.Composite.readAttribute(Composite.java:424) [...] Is there a way to ignore this? Thanks, Fabian ------------------------------------------------------------------------------ _______________________________________________ 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. |
|
From: Fabian K. <fab...@we...> - 2009-03-31 19:33:10
|
Hi List, I have an XML file, similiar to this snippet: <root xmlns="http://www.domain.org/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.domain.org/namespace root.xsd"> When i try to deserialize it, I get the following exception: org.simpleframework.xml.core.AttributeException: Attribute 'schemaLocation' does not exist at line -1 at org.simpleframework.xml.core.Composite.readAttribute(Composite.java:424) [...] Is there a way to ignore this? Thanks, Fabian |
|
From: Timo R. <cr...@ol...> - 2009-03-31 08:10:09
|
Hello Niall, any info on when you have time to fix the tutorial page for the Opera browser (see my last mail in the mailinglist)? Thanks a lot Best regards, Timo |
|
From: N. N. <nju...@gm...> - 2009-03-31 04:00:57
|
how would one use SimpleXML to serialize/deserialize the following
prototypical example class? the basic premise is that the class delegates
some read-only properties to a subordinate class. the subordinate class, in
turn, must be initialized on instantiation (because its properties are
read-only).
i'd like to have the XML look something like <delegateProperty
propertyA="100" propertyB="200"/> (or as attributes) but can't figure out
how to appropriately annotate with SimpleXML. thanks for any help.
public class DelegatedProperty
{
public DelegatedProperty(int propertyA, int propertyB)
{
this.delegate = new Delegate(propertyA, propertyB);
}
public int getPropertyA()
{
return this.delegate.getA();
}
public int getPropertyB()
{
return this.delegate.getB();
}
private Delegate delegate = null;
}
|
|
From: Niall G. <gal...@ya...> - 2009-03-29 13:16:44
|
Hi,
Generics are not reified in Java, this means that the type is erased after compilation. So when you reflectively attempt to acquire the type there is a null pointer exception.
The is no workaround for this, its a limitation of the language unfortunately.
Niall
--- On Sun, 3/29/09, Fabian Kürten <fab...@we...> wrote:
> From: Fabian Kürten <fab...@we...>
> Subject: [Simple-support] Strange Nullpointer for ElementMap with generics?
> To: sim...@li...
> Date: Sunday, March 29, 2009, 5:28 AM
> Hi Group
>
> I just tried this:
>
> @Root
> public class MapTest<K, V> {
>
> @ElementMap
> public HashMap<K, V> data;
>
> public MapTest() {
> this.data = new
> HashMap<K, V>();
> }
>
> public static void main(String[] args)
> throws Exception {
> MapTest<String,
> Integer> mt = new MapTest<String, Integer>();
> mt.data.put("Eins",
> 1);
> mt.data.put("Vier",
> 4);
> mt.data.put("Drei",
> 3);
> Serializer serializer
> = new Persister();
> serializer.write(mt,
> System.out);
> }
> }
>
> Which failed like:
> Exception in thread "main" java.lang.NullPointerException
> at
> org.simpleframework.xml.core.Signature.getEntry(Signature.java:102)
> at
> org.simpleframework.xml.core.ElementMapLabel.getEntry(ElementMapLabel.java:196)
> at
> org.simpleframework.xml.core.Signature.getName(Signature.java:196)
> at
> org.simpleframework.xml.core.ElementMapLabel.getName(ElementMapLabel.java:214)
> at
> org.simpleframework.xml.core.CacheLabel.<init>(CacheLabel.java:119)
> at
> org.simpleframework.xml.core.LabelFactory.getInstance(LabelFactory.java:67)
> at
> org.simpleframework.xml.core.Scanner.process(Scanner.java:606)
> at
> org.simpleframework.xml.core.Scanner.scan(Scanner.java:539)
> at
> org.simpleframework.xml.core.Scanner.field(Scanner.java:498)
> at
> org.simpleframework.xml.core.Scanner.scan(Scanner.java:348)
> at
> org.simpleframework.xml.core.Scanner.<init>(Scanner.java:98)
> at
> org.simpleframework.xml.core.ScannerFactory.getInstance(ScannerFactory.java:67)
> at
> org.simpleframework.xml.core.Support.getScanner(Support.java:161)
> at
> org.simpleframework.xml.core.Support.getName(Support.java:223)
> at
> org.simpleframework.xml.core.Source.getName(Source.java:196)
> at
> org.simpleframework.xml.core.Traverser.getName(Traverser.java:262)
> at
> org.simpleframework.xml.core.Traverser.write(Traverser.java:185)
> at
> org.simpleframework.xml.core.Traverser.write(Traverser.java:168)
> at
> org.simpleframework.xml.core.Persister.write(Persister.java:921)
> at
> org.simpleframework.xml.core.Persister.write(Persister.java:903)
> at
> org.simpleframework.xml.core.Persister.write(Persister.java:884)
> at
> org.simpleframework.xml.core.Persister.write(Persister.java:1000)
> at
> org.simpleframework.xml.core.Persister.write(Persister.java:982)
> at
> org.simpleframework.xml.core.Persister.write(Persister.java:963)
> at MapTest.main(MapTest.java:25)
>
> I am quite sure the reason are the generics... anyone knows
> more about this?
>
> Fabian
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Simple-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simple-support
>
|
|
From: Fabian K. <fab...@we...> - 2009-03-29 12:26:14
|
Hi Group
I just tried this:
@Root
public class MapTest<K, V> {
@ElementMap
public HashMap<K, V> data;
public MapTest() {
this.data = new HashMap<K, V>();
}
public static void main(String[] args) throws Exception {
MapTest<String, Integer> mt = new MapTest<String, Integer>();
mt.data.put("Eins", 1);
mt.data.put("Vier", 4);
mt.data.put("Drei", 3);
Serializer serializer = new Persister();
serializer.write(mt, System.out);
}
}
Which failed like:
Exception in thread "main" java.lang.NullPointerException
at org.simpleframework.xml.core.Signature.getEntry(Signature.java:102)
at
org.simpleframework.xml.core.ElementMapLabel.getEntry(ElementMapLabel.java:196)
at org.simpleframework.xml.core.Signature.getName(Signature.java:196)
at
org.simpleframework.xml.core.ElementMapLabel.getName(ElementMapLabel.java:214)
at org.simpleframework.xml.core.CacheLabel.<init>(CacheLabel.java:119)
at
org.simpleframework.xml.core.LabelFactory.getInstance(LabelFactory.java:67)
at org.simpleframework.xml.core.Scanner.process(Scanner.java:606)
at org.simpleframework.xml.core.Scanner.scan(Scanner.java:539)
at org.simpleframework.xml.core.Scanner.field(Scanner.java:498)
at org.simpleframework.xml.core.Scanner.scan(Scanner.java:348)
at org.simpleframework.xml.core.Scanner.<init>(Scanner.java:98)
at
org.simpleframework.xml.core.ScannerFactory.getInstance(ScannerFactory.java:67)
at org.simpleframework.xml.core.Support.getScanner(Support.java:161)
at org.simpleframework.xml.core.Support.getName(Support.java:223)
at org.simpleframework.xml.core.Source.getName(Source.java:196)
at org.simpleframework.xml.core.Traverser.getName(Traverser.java:262)
at org.simpleframework.xml.core.Traverser.write(Traverser.java:185)
at org.simpleframework.xml.core.Traverser.write(Traverser.java:168)
at org.simpleframework.xml.core.Persister.write(Persister.java:921)
at org.simpleframework.xml.core.Persister.write(Persister.java:903)
at org.simpleframework.xml.core.Persister.write(Persister.java:884)
at org.simpleframework.xml.core.Persister.write(Persister.java:1000)
at org.simpleframework.xml.core.Persister.write(Persister.java:982)
at org.simpleframework.xml.core.Persister.write(Persister.java:963)
at MapTest.main(MapTest.java:25)
I am quite sure the reason are the generics... anyone knows more about this?
Fabian
|
|
From: Niall G. <gal...@ya...> - 2009-03-29 11:44:25
|
Hi This is currently not possible with the CycleStrategy. It would require some changes to how the deserialization and serialization process is performed. Niall --- On Fri, 3/27/09, Nuno Fachada <nfa...@is...> wrote: > From: Nuno Fachada <nfa...@is...> > Subject: [Simple-support] add forward references > To: sim...@li... > Date: Friday, March 27, 2009, 11:24 AM > Hi, > > Would it be possible for Simple to support forward > references, such as: > > <model> > <object1 id="obj1"> > <x>4</x> > <y>3</y> > </object1> > <object2 reference="obj1" /> > <object3 reference="obj4" /> > <object4 id="obj4"> > <x>2</x> > <y>1</y> > </object4> > </model> > > Using CyclicStrategy Simple allows that object2 references > object1; > however it's not currently possible for object3 to > reference object4. > Could this feature be implemented? Instead of firing the > exception when > the reference is not found, Simple could parse the all of > the XML and > then resolve references; then, if an invalid reference is > found, the > exception would be thrown. > > Thank you, > > Nuno Fachada > ISR - IST - Portugal > > > > ------------------------------------------------------------------------------ > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support > |
|
From: Quirino Z. <qu...@la...> - 2009-03-28 10:36:16
|
---------- Forwarded message ----------
From: Quirino Zagarese <the...@gm...>
Date: 2009/3/28
Subject: Allowing polymorphic collections serialization to match original
definitions
To: sim...@li...
Hi,
I'm trying to serialize a collection that may contain different types.
Now, simple resolves polymorphism using the class attribute.
I would be great if I could do something like this:
@Root
public class AZ{
@ElementList(inline=true,useroot=true)
private Collection<Letter> elements;
.....
public az(){
elements = new ArrayList();
// A and B implement Letter
elements.add(new A());
elements.add(new B());
.....
}
}
and obtain:
<AZ>
<A/>
<B/>
.....
</AZ>
instead of:
<AZ>
<Letter class="A"/>
<Letter class="B"/>
....
</AZ>
This could be very useful for all the tools that have to generate XUL like
XML.
In those cases you have an element that may contain from 0 to N elements and
you don't know a priori the type of each element(and of course you have to
serialize it with its name, not with the <interfacename
class="realclassname"/> technique).
Any thoughts?
Regards
--
Quirino Zagarese
LaszloItalia Founder (www.laszloitalia.org)
Software Development Manager - Galilaeus s.r.l.
--
Quirino Zagarese
LaszloItalia Founder (www.laszloitalia.org)
Software Development Manager - Galilaeus s.r.l.
|
|
From: Nuno F. <nfa...@is...> - 2009-03-27 19:00:51
|
Hi,
Would it be possible for Simple to support forward references, such as:
<model>
<object1 id="obj1">
<x>4</x>
<y>3</y>
</object1>
<object2 reference="obj1" />
<object3 reference="obj4" />
<object4 id="obj4">
<x>2</x>
<y>1</y>
</object4>
</model>
Using CyclicStrategy Simple allows that object2 references object1;
however it's not currently possible for object3 to reference object4.
Could this feature be implemented? Instead of firing the exception when
the reference is not found, Simple could parse the all of the XML and
then resolve references; then, if an invalid reference is found, the
exception would be thrown.
Thank you,
Nuno Fachada
ISR - IST - Portugal
|