Alan Williams wrote:
> David Withers wrote:
> [snip]
> 
> Hello,
> 
>> After investigating some more I've found that although the XStream docs 
>> say "If a new field is added to the class, deserializing an old version 
>> will leave the field uninitialized", this is not the case. String fields 
>> are initialized to null, even if you set a default value for the field.
> 
> What is happening?  Are you saying that new fields are initialized to 
> null?  If so, isn't a possible workaround for this to alter the 
> configuration bean so that when you do a getX it checks if x is null 
> and, if so, sets it to a value?

If it's a new field that's not in the serialized file then yes, it's 
initialized to null, even though I'm setting a value when I declare the 
field, e.g. private String csvDelimiter = ",";

So yes, the workaround in this case is:

public String getCsvDelimiter() {
     return outputFormat == null ? "," : csvDelimiter;
}


>> If you add an enum field then an exception is thrown (which is the 
>> problem I'm hitting).
> 
> What is throwing the exception?

XStream. I'm guessing that it creates to object for the field and then 
sets the value from the serialized xml. However you can't create enums 
without knowing the value.

My only workaround for this is not to use an enum (or convert to/from an 
enum in the accessor methods).

>> Taverna is using an old version of XStream - 1.2.1 (November 2006). The 
>> docs on the website must refer to the latest version - 1.3.1 (December 
>> 2008), which would explain the discrepancy. Is updating XStream to the 
>> latest version an option, or does Taverna need to use version 1.2.1 for 
>> some reason?
> 
> Not that I know.  Have you tried changing Taverna to use XStream 1.3.1?

I'll try that today. If it works as the docs say then it should make 
backwards compatibility easier.

>> David.
> 
> Alan
> 
> 
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry® Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay 
> ahead of the curve. Join us from November 9-12, 2009. Register now!
> http://p.sf.net/sfu/devconf
> _______________________________________________
> taverna-hackers mailing list
> [email protected]
> Web site: http://www.taverna.org.uk
> Mailing lists: http://www.taverna.org.uk/taverna-mailing-lists/
> Developers Guide: http://www.mygrid.org.uk/tools/developer-information


-- 
David Withers
School of Computer Science, University of Manchester,
Oxford Road, Manchester, M13 9PL, UK.
+44 (0)161 275 0683

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
taverna-hackers mailing list
[email protected]
Web site: http://www.taverna.org.uk
Mailing lists: http://www.taverna.org.uk/taverna-mailing-lists/
Developers Guide: http://www.mygrid.org.uk/tools/developer-information

Reply via email to