This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jaxb - xmladapter for rootElement?

 
dan volfman
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i need something that will act like an xmlAdapter, but will be defined on a xmlRootElement (rather than on a field).

the purpose is custom marshalling and unmarshalling of fields which will be determined by the fields values.
for example, if a field value is of a particular syntax, then the field will be changed while unmarshalling .

i have a lot of objects that are serialized to xml files, and a lot of fields that potentially could be changed, and thats why i'm looking for a solution at the rootElement level and not at the field level.

any suggestions?

thanks.
 
Blaise Doughan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can specify the @XmlJavaTypeAdapter annotation at the class level. This means that that any property of this particular class will automatically use the adapter. Unfortumately the adapter does not get activated when this object is the root object of the tree. In this case you need to call the adapter yourself.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic