Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General 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