/* * SettingsObject.java * * Created on July 19, 2006, 6:15 PM */ package Current.popups.Settings.Items; import java.io.Serializable; import java.lang.reflect.*; /** * * @author pat */ public class SettingsObject implements Serializable { protected Object set_obj; public SettingsObject(Object settings_object) { set_obj=settings_object; } public Object getObject() { return set_obj; } public String getName() { try { Method m=set_obj.getClass().getMethod("getTitle", new Class[0]); return (String)(m.invoke(set_obj, new Object[0])); } catch (Throwable T) { return set_obj.getClass().getName(); } } public Class getType() { return set_obj.getClass(); } public Object evalField(Field F) throws java.lang.IllegalAccessException { return F.get(set_obj); } public void setField(Field F, Object obj) throws java.lang.IllegalAccessException { F.set(set_obj, obj); //M.mcbSend(set_obj); } /** Copy the settings in obj over the settings object. * obj must be of the same type. */ public void copyFrom(Object obj) { if (set_obj.getClass().isInstance(obj)) { Field[] f=set_obj.getClass().getFields(); for (int i=0; i