troubleshooting Question

Display contents of hetrogeneous objects in HashMap or DistributedMap.

Avatar of SHKR
SHKR asked on
11 Comments2 Solutions524 ViewsLast Modified:
I am trying to write a small util to display the contents of the objects in the HashMap/ DistributedMap. Please guide or provide some sample code to achieve this.

HashMap will have differnet types of objects and  writing if then else instanceof operator  code  block will be  cumbersome and need to make changes to the code for each class type added , I am looking to make this dynamic by configuring the class type and methodName and variable Names in XML files. I will add detail of the any  new classes in the XML file.
public  String displayObjectData(Object obj){
 	StringBuffer outPutJsp = new StringBuffer() ;
	String className = obj.getClass().getName();
	ClassType classType = null ;
		classType = (ClassType)classMap.get(className);
		outPutJsp.append("<table> <th> <td>cachInstanceName : ["+this.cachInstanceName +"]</td>" +
				 "<td>Object classType["+ className +"]"+
				 ",Object value["+ obj.toString() +"]</td>");
		/// this point we need create reference based on the class type and then cast and display the contents by calling the methods listed in classMap.
			///stuck here.
			return outPutJsp.toString();
Mick Barry
Java Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2010

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 2 Answers and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros