commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ricardo Gladwell <>
Subject [betwixt] Making deserialise work like serialise (long)
Date Tue, 12 Jul 2005 14:47:15 GMT
Hi All,

I'm using an external XML syntax to read and write data for payment 
transactions. The format for specifying bank accounts is as follows:


Rather than nest the country-specific bank account within a generic bank 
account, I just have a shopper and bank account bean as follows:

public class Shopper {

   BankAccount bankAccount;

   public BankAccount getBankAccount() {..}
   public void setBankAccount(BankAccount ba) {..}


public abstract class BankAccount {...}

public class BritishBankAccount extends BankAccount {...}

To serialise this I have the following betwixt files:

# Shopper.betwixt
<?xml version="1.0" encoding="UTF-8" ?>
<info primitiveTypes="element">
   <element name="shopper">
     <element name="bankAccount" property="bankAccount" />

# BritishBankAccount.bwtwixt
<?xml version="1.0" encoding="UTF-8" ?>
<info primitiveTypes="element">
   <element name="bankAccount">
     <element name="bankAccount-GB">

When serializing this creates the nested bank account tags for the 
extenal XML representation without requiring an additional bean "layer" 
for the bank account and country-specific bank account. However, when 
deserialising with the above as standard, the bank account property of 
the shopper bean is set to null.

How can I simulate this behaviour for serialisation? That is, how do I 
force betwixt to interpret the bank account and generate an appropriate 
country specific bank account, placing it into the bank account property 
of the shopper, without having to create an additional bean for generic 
bank account to hold the country-specific bank account.

Phew, I hope that is clear!

Kind regards...

-- Ricardo Gladwell

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message