I have the following object:
Class Account{
String accountType;
String accountName;
String accountBalance;
etc.
}
The accountType attribute can have 1 of 15 possible values, e.g. "CURRENT",
"DEPOSIT" etc.
My query is, with castor we define the mapping of the attribute to the xml
tag at compilation time. This does not work so good in the class above as
the desired XML needs to look like:
<CURRENT> //The name of this element comes from the value of the
accountType attr., hence it could be 1 of 15 different names
<ACCOUNTNAME>Joe</ACCOUNTNAME>
<ACCOUNTBALANCE>12.12</ACCOUNTBALANCE>
</CURRENT>
In other words the element <CURRENT> that is created gets created at run
time based on the value of the accountType attribute. I don't think I can
achieve this with Castor but I was wondering if anyone out there knew of any
other way of achieving this rather than creating my own marshalling
component.
Thanks