• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Query related to JaxB Unmarshalling : no setter methods in Unmarshalled java classes

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I'm trying to unmarshal an xml schema. I used the tool XJCFacade provided under JaxB package com.sun.tools.xjc.

After running the tool the autogenerated classes wont havesetters methods to corresponding properties.

My question is how am I supposed to set properties in respective instances of those autogenereated classes.

Should i add my own setter method or is there any other standard way to do this.

Hope I have made my doubt clear.

Please help...

-aravind
 
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. Please post a small sample schema that can be used to duplicate this behaviour.
 
aravind kanganar
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi below is PhoneDirectory.xsd which has request for phonenumbers associated with an userId and response giving corresponding phone numbers.

The unmarshalled class corresponding to the response element (PhoneNumberResponse.java) doesn't contailn any setter method. Instead it has one getPhoneNumber() method which return list of phone numbers.


 
R Srini
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Aravind. This is the PhoneNumberResponse element

The generated code is:
This is how it works when you have arrays/sequences in the schema. You use getPhoneNumber() to get the list and then use list.add() to add data. For non-sequence items, you should see the regular getters.
 
aravind kanganar
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay This solved my problem. Thanks alot Srini!
 
I don't get it. A whale wearing overalls? How does that even work? It's like a tiny ad wearing overalls.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic