
22/01/2010, 21:38
|
(Desactivado) | | Fecha de Ingreso: diciembre-2008 Ubicación: por ahi!!!
Mensajes: 113
Antigüedad: 16 años, 1 mes Puntos: 1 | |
Respuesta: Dar valor a atributos con Reflection si que se puede. seria algo asi.
setearValores(String nombreParametro, String valorParametro, Class tipoParametro){
Class c = tipoParametro;
Class[] parameterTypes = new Class[] { c };
Method method;
String value = valorParametro;
Object[] arguments = new Object[] { objetoParametro(value, tipoParametro) };
method = object.getClass().getMethod(nombreParametro, parameterTypes);
method.invoke(object, arguments);
} |