Avatar of SHKR

asked on 

Display contents of hetrogeneous objects in HashMap or DistributedMap.

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();

Open in new window


Avatar of undefined
Last Comment

8/22/2022 - Mon