[messages] [Developers] Problem with SequenceEncoder

Tim McCarron timothy.mccarron at sbcglobal.net
Tue Mar 8 16:04:15 MST 2011

Search for the discussion where setting values to null or "" was discussed.
There is a reason and method to the madness, beyond me but deeper than what
you think I suspect.

Also it was never intended for you to leave the initial value of a DP empty
even though it lets you do this. The easy fix of course would be to put a
value in there and you'd get no bug :)

-----Original Message-----
From: messages-bounces at vassalengine.org
[mailto:messages-bounces at vassalengine.org] On Behalf Of bobd
Sent: Tuesday, March 08, 2011 3:52 PM
To: messages at vassalengine.org
Subject: [messages] [Developers] Problem with SequenceEncoder

Hi folks,

I created a DynamicProperty with an empty initial value and this causes
an IllegalStateException in Decorator.setState when you try to reload
the module.

I have logged this as bug 3465 with an explanation of how it happens
before searching for similar bugs (sorry) and discovered that there are
quite a few.

This bug is simple to fix, setting the initial value to "" rather than
null will mean that SequenceEncoder will handle it properly.

But there is an underlying problem, Decorator.getState() uses
SequenceEncoder to serializes the state in a maner such that if
myGetState() returns null only one token is created. 
Decorator.setState() on the other hand always requires two tokens.

The general problem seems to be that if a SequenceEncoder is created
with an initial value and that value is null then the first token will
not be created

i.e.  (new SequenceEncoder(nullString, delim)).append(valueString);     
         // creates one token
SequenceEncoder(delim)).append(nullString).append(valueString);   //
creates two tokens
I think that the first behaviour is wrong.


Read this topic online here:
messages mailing list
messages at vassalengine.org

More information about the messages mailing list