Details
-
Type: Improvement
-
Status: Closed
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.2.1
-
Component/s: None
-
Labels:None
Description
This patch adds new boolean conversion options that can be easily enabled via code like this:
class Perms {
boolean readable = true;
boolean writable = false;
}
xstream.registerConverter(BooleanConverter.TRUE_FALSE); // the default, same as before
<perms> <readable>true</readable> <writable>false</writable> </perms>
xstream.registerConverter(BooleanConverter.YES_NO);
<perms> <readable>yes</readable> <writable>no</writable> </perms>
xstream.registerConverter(BooleanConverter.BINARY);
<perms> <readable>1</readable> <writable>0</writable> </perms>
xstream.registerConverter(BooleanConverter.EMPTY_ELEMENT);
<perms> <readable/> </perms>
Note that the EMPTY_ELEMENT BooleanConverter requires the XSTR-308 (http://jira.codehaus.org/browse/XSTR-308) patch that allows a converter to say weather or not a tag should be written for the value.
David, I have committed now a version that omits the ConditionalConverter part, but at least the other stuff is working. Thanks for the patch!