Ver Mensaje Individual
  #2 (permalink)  
Antiguo 22/01/2010, 21:38
megajandro
(Desactivado)
 
Fecha de Ingreso: diciembre-2008
Ubicación: por ahi!!!
Mensajes: 113
Antigüedad: 15 años, 4 meses
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);
}