1 19 20 package org.netbeans.modules.j2ee.sun.validation.util; 21 22 import java.lang.reflect.Constructor ; 23 24 30 31 public class ObjectFactory { 32 33 34 37 public static Object newInstance(String className){ 38 39 Utils utils = new Utils(); 40 return utils.createObject(className); 41 } 42 43 44 47 public static Object newInstance(String className, String argument){ 48 Class classObject = null; 49 Utils utils = new Utils(); 50 51 Class [] argumentTypes = new Class [] {String .class}; 52 Constructor constructor = 53 utils.getConstructor(className, argumentTypes); 54 55 Object [] argumentValues = new Object [] {argument}; 56 57 return utils.createObject(constructor, argumentValues); 58 } 59 60 61 64 public static Object newInstance(String className, Object argument){ 65 Class classObject = null; 66 Utils utils = new Utils(); 67 68 Class [] argumentTypes = new Class [] {Object .class}; 69 Constructor constructor = 70 utils.getConstructor(className, argumentTypes); 71 72 Object [] argumentValues = new Object [] {argument}; 73 74 return utils.createObject(constructor, argumentValues); 75 } 76 } 77 | Popular Tags |