This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes print java bean member variables and values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "print java bean member variables and values" Watch "print java bean member variables and values" New topic
Author

print java bean member variables and values

James Kesari
Greenhorn

Joined: May 18, 2006
Posts: 16
I have a requirement to print the member variables and their values of a java bean object. I am thinking of using reflection to perform this task.
But the challenge is, if one of the member variable happens to be another java bean then the member variable and values of that bean also needs to be printed.
I am not sure how I can verify if a particular member variable is a java object or not. More specifically, the difficult part is to differentiate between jdk java objects(like String, Boolean, etc.,) and the custom java objects.
Do you have any ideas in accomplishing this?

Thanks...
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Have you come across the class java.beans.XMLEncoder? It might do what you need already.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
James Kesari
Greenhorn

Joined: May 18, 2006
Posts: 16
This class is great. But the only problem is, if the bean object contains a collection object as its member variable then it does not drill down further.

any suggestions please?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: print java bean member variables and values
 
Similar Threads
Define: Static variable
New to EJB.. Session Bean
types of variables
Some doubts on - Mikalai Zaikin study material
Java Reflection Problem