Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Converting Back and Forth between different classes of different packages

Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a java noob question regarding class casting.

A few schemas were created in eclipse to define certain types. One of the types i will talk about is Address. A WSDL was created from these schemas and built into a package. From this, the main IMPL class was created which are the WSDL stub calls that the client will use to retrieve information. I have no control over the client other than the fact that it knows what functions are available and thats all the client knows about. It doesnt know nor is it supposed to know anything about the server side.

the WSDL Address class is something like:

An example of one of the functions created from the WSDL would be a certain function:

where the com.general.client.Address is what it expects to be returned back.

My Converter class is supposed to act as a bridge between client and server so that the server code never changes in the future, if any new functions are added to the schemas or if new schemas are created, thus new wsdl's. Converter, in this case, will use the argument 'id' and use that number to do whatever it needs to do to get the correct data that i need, in this case, it is an Address..that represents my own Address class( that i created with a different package name).

Because its my own definition of Address(with the same attributes) its going to have a different package name. Remember though that the IMPL class expects to be returned its own Address type(com.general.client.Address) and my Address class type is in the form of something like com.general.server.Address. So now I have address information based on the ID that i passed to my Converter constructor but that information is stored in my own Address class type. I need to use my converter class to take my own internal Address Class type and convert this back to the original IMPL class address type, because that's what it expects.

So in my converter class how, would i make the appropriate java method calls or casting class to convert my Address class type to the correct IMPL Address class type that it expects?

thanks everyone for your input in advance.

Posts: 69884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too difficult a subject for "beginning Java". Moving thread.
Posts: 67425
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Learningjava cww", please check your private messages for an important administrative matter. Again.
It's weird that we cook bacon and bake cookies. Eat this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic