EventHook.java

  1. /*
  2.  * EventHooke.java
  3.  *
  4.  * Created on May 26, 2007, 3:12:11 PM
  5.  *
  6.  * To change this template, choose Tools | Template Manager
  7.  * and open the template in the editor.
  8.  */

  9. package org.jruby.runtime;

  10. import org.jruby.runtime.builtin.IRubyObject;

  11. /**
  12.  *
  13.  * @author headius
  14.  * @author hooligan495
  15.  * Changed event hook to an enum that manages a collection of event handlers.
  16.  * There are now global event delgators for each event type.  If a component
  17.  * is interested in being notified of an event they should register a handler
  18.  * with that event.
  19.  * one of the motivations of implementing the EventHook in this way is that we
  20.  * needed to handle modifying line numbers to be one based (and the RETURN type
  21.  * ine number for ruby needs to be offset by 2).  If these rules ever change we
  22.  * can change them here.
  23.  *
  24.  */
  25. public abstract class EventHook {    
  26.     public void event(ThreadContext context, RubyEvent event, String file, int line, String name, IRubyObject type){
  27.         eventHandler(context, event.getName(), file, line + event.getLineNumberOffset(), name, type);
  28.     }
  29.    
  30.     public abstract void eventHandler(ThreadContext context, String eventName, String file, int line, String name, IRubyObject type);
  31.     public abstract boolean isInterestedInEvent(RubyEvent event);
  32. }