FileDocCategorySizeDatePackage
GenericTemperatureAdapter.javaAPI DocExample2062Tue Jun 03 22:44:28 BST 1997BeansBook.Simulator

GenericTemperatureAdapter

public class GenericTemperatureAdapter extends Object implements TempChangeListener

Fields Summary
protected Object
theTarget
protected Class
theTargetClass
protected static final Class[]
paramClasses
protected Hashtable
mappingTable
Constructors Summary
public GenericTemperatureAdapter(Object target)

  
   // constructor
     
   
      theTarget = target;
      theTargetClass = target.getClass();
   
Methods Summary
public voidregisterEventHandler(Temperature tmp, java.lang.String methodName)

      Method mthd = theTargetClass.getMethod(methodName, paramClasses);
      tmp.addTempChangeListener(this);
      mappingTable.put(tmp, mthd);    
   
public voidtempChanged(TempChangedEvent evt)

      try
      {
         // invoke the registered method on the target
         Method mthd = (Method)mappingTable.get(evt.getSource());
         Object params[] = { evt };
         mthd.invoke(theTarget, params);
      }
      catch (IllegalAccessException e)
      {
         System.out.println(e);
      }
      catch (InvocationTargetException e)
      {
         System.out.println(e);
      }