History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XSTR-309
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Assignee: Unassigned
Reporter: David Blevins
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XStream

More Versatile Boolean conversion options

Created: 02/May/06 11:56 PM   Updated: 09/Nov/06 05:05 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.2.1

File Attachments: 1. Text File BetterBooleanConverter.patch (7 kb)



 Description  « Hide
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

{code:xml}
<perms>
  <readable>true</readable>
  <writable>false</writable>
</perms>
{code}

xstream.registerConverter(BooleanConverter.YES_NO);
{code:xml}
<perms>
  <readable>yes</readable>
  <writable>no</writable>
</perms>
{code}

xstream.registerConverter(BooleanConverter.BINARY);
{code:xml}
<perms>
  <readable>1</readable>
  <writable>0</writable>
</perms>
{code}

xstream.registerConverter(BooleanConverter.EMPTY_ELEMENT);

{code:xml}
<perms>
  <readable/>
</perms>
{code}

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.



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Joerg Schaible - 18/Oct/06 08:48 PM
David, I have committed now a version that omits the ConditionalConverter part, but at least the other stuff is working. Thanks for the patch!

Joerg Schaible - 09/Nov/06 05:05 PM
Closed as fixed for 1.2.1