public static Object convertProperty()

in src/com/vmware/vim25/mo/util/PropertyCollectorUtil.java [136:173]


	public static Object convertProperty(Object dynaPropVal) 
	{
		Object propertyValue = null;
		
		Class propClass = dynaPropVal.getClass();
		String propName = propClass.getName();
		if (propName.indexOf("ArrayOf") != -1) //Check the dynamic propery for ArrayOfXXX object 
		{ 	
			String methodName = propName.substring(propName.indexOf("ArrayOf") +"ArrayOf".length());
//			 If object is ArrayOfXXX object, then get the XXX[] by invoking getXXX() on the object. For Ex:
//			 ArrayOfManagedObjectReference.getManagedObjectReference() returns ManagedObjectReference[] array.
			try
			{
				Method getMethod = null; 
				try
				{
					getMethod = propClass.getMethod("get" + methodName, (Class[])null);
				} catch(NoSuchMethodException nsme)
				{
					getMethod = propClass.getMethod("get_" + methodName.toLowerCase(), (Class[])null);
	            }
				propertyValue = getMethod.invoke(dynaPropVal, (Object[])null);
			}catch(Exception e)
			{
				e.printStackTrace();
			}
		} 
        else if (dynaPropVal.getClass().isArray()) //Handle the case of an unwrapped array being deserialized.
        { 
        	propertyValue = dynaPropVal;
        } 
        else 
        {
        	propertyValue = dynaPropVal;
        } 
		
		return propertyValue;
	}