This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Problem in using xstream annotations for complex java objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Problem in using xstream annotations for complex java objects" Watch "Problem in using xstream annotations for complex java objects" New topic
Author

Problem in using xstream annotations for complex java objects

Deeps Mistry
Ranch Hand

Joined: Jan 31, 2009
Posts: 189
Hi,

I have a java object - Entity.java



I want to convert Entity.java to xml in the following format -



I have done something like this -


How do i annotate location and country?

Thanks.



Deeps Mistry
Ranch Hand

Joined: Jan 31, 2009
Posts: 189
Deeps Mistry wrote:Hi,

I have a java object - Entity.java



I want to convert Entity.java to xml in the following format -



I have done something like this -


How do i annotate location and country?

Thanks.





Can anyone please help me out with this?

Thanks
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 583
    
    3
How do i annotate location and country?

With the layout given, you practically no need to annotate location. For country, you simply alias the variable to country.

Most of the tag names will fall in place because you make the variable names conducive to the intended output.

Or do I miss something you have not shown (apart from those getters or setters or constructors...)?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem in using xstream annotations for complex java objects
 
It's not a secret anymore!