XML to POJOs Advantages - @Converter
One of the poorest things in XML binding is when the binding framework generates classes from your XSD where you would have used a normal JDK class. For example, consider the following:
<schedule>
<appointment>
<date>
<day>3</day>
<month>4</month>
<year>2005</year>
</date>
<desc>Meet Omer and Tal</desc>
</appointment>
<appointment>
<date>
<day>23</day>
<month>12</month>
<year>2005</year>
</date>
<desc>Joanna is coming</desc>
</appointment>
</schedule>
Surely I wouldn't want it to create a class for the <date> element, but for it to use the Calendar (javadoc) class!
Well, that's exactly what @Converter
does. The X2J framework provides you with an Assigner
interface, which will receive all the XML elements related to the parsing of the member annotated with @Converter
, and will be responsible to assign the values derived from the XML into the non X2J-annotated Java class.
Related Topics
XML to POJOs Advantages - Repeating Types
Possible advantages of X2J - Primary Keys
0 Comments:
Post a Comment
<< Home