package org.osgeo.mapguide; import java.util.*; import java.lang.reflect.*; public class ObjectFactory { public static Object createObject(int id, long cptr, boolean ownCptr) { Constructor ctor = (Constructor)classMap.get(new Integer(id)); if(ctor == null) return null; try { return ctor.newInstance(new Object[] { new Long(cptr), new Boolean(ownCptr) }); } catch(Exception e) { e.printStackTrace(); return null; } } protected static Hashtable classMap; static { classMap = new Hashtable(); try { $CLASS_NAME_MAP_BODY$ } catch(Exception e) { e.printStackTrace(); } } private static Constructor getSWIGCtor(String className) throws ClassNotFoundException, Exception { Constructor swigCtor = null; String typeName = "org.osgeo.mapguide." + className; Class type = Class.forName(typeName); if (type == null) { throw new Exception("Could not find proxy class: " + typeName); } Constructor[] cons = type.getDeclaredConstructors(); for (int i = 0; i < cons.length; i++) { Class[] parameterTypes = cons[i].getParameterTypes(); if (parameterTypes.length == 2 && parameterTypes[0].equals(Long.TYPE) && parameterTypes[1].equals(Boolean.TYPE)) { swigCtor = cons[i]; swigCtor.setAccessible(true); //This ctor will be protected, so we need to make it accessible } } if (swigCtor == null) { throw new Exception("Could not find the expected internal SWIG constructor for class: " + className); } return swigCtor; } }