Package: java.lang.reflect.* |
Product: JDK |
Release: 1.1 |
Related Links: |
General
Field
Method
|
Comment: |
ParamResource pr = new ParamResource(); String str = null; Class t = this.getClass(); /* Field[] f = t.getDeclaredFields(); for (int j = 0; j < f.length; j++) { dbg("fields: " + f[j]); } */ for (Enumeration e = pr.getKeys(); e.hasMoreElements();) { str = (String) e.nextElement(); dbg("" + str); try { Field field = t.getDeclaredField(str); dbg("FOUND FIELD: " + str + "==" + field.getType()); if (field.getType() == java.awt.Color.class) { dbg("COLOR" + field.get(this)); field.set(this, new Color(Integer.parseInt(getParameter(str, (String) pr.handleGetObject(str)), 16))); //field.set( this, new java.awt.Color(45,45,245) ); } else if (field.getType().getName().equals("int")) { dbg("INTEGER"); field.setInt(this, Integer.valueOf(getParameter(str, (String) pr.handleGetObject(str))).intValue()); } else if (field.getType().getName().equals("boolean")) { dbg("BOOLEAN"); field.setBoolean(this, Boolean.valueOf(getParameter(str, (String) pr.handleGetObject(str))).booleanValue()); } else if (field.getType() == java.lang.String.class) { dbg("String"); field.set(this, getParameter(str, (String) pr.handleGetObject(str))); } dbg("" + str + ": " + field.get(this)); } catch (Exception ee) { ee.printStackTrace(); } } |