net.xoetrope.optional.events
Class XEventProxy

java.lang.Object
  extended by net.xoetrope.optional.events.XEventProxy
All Implemented Interfaces:
java.lang.reflect.InvocationHandler, XEventAdapter

public class XEventProxy
extends java.lang.Object
implements java.lang.reflect.InvocationHandler, XEventAdapter

A proxy for a listener interface

Copyright (c) Xoetrope Ltd., 2002-2006. See license.txt for licensing details


Field Summary
protected  XuiEventHandler eventHandler
           
protected  java.lang.Class listenerClass
           
protected  long mask
           
protected  java.lang.Object proxy
           
 
Constructor Summary
XEventProxy(XuiEventHandler eh, long mask, java.lang.Class[] iface)
          Creates a new instance of XEventProxy
 
Method Summary
 java.lang.String getAddMethodName()
          Get the name of the adder method e.g. addActionListener
 long getEventMask()
          Get the event mask
 java.lang.String getListenerInterfaceName()
          Get the name of the listener e.g. java.awt.event.ActionListener
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
          Processes a method invocation on a proxy instance and returns the result.
 void setEventHandler(XuiEventHandler xeh)
          Set the current event handler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eventHandler

protected XuiEventHandler eventHandler

proxy

protected java.lang.Object proxy

mask

protected long mask

listenerClass

protected java.lang.Class listenerClass
Constructor Detail

XEventProxy

public XEventProxy(XuiEventHandler eh,
                   long mask,
                   java.lang.Class[] iface)
Creates a new instance of XEventProxy

Method Detail

invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Processes a method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with.

Specified by:
invoke in interface java.lang.reflect.InvocationHandler
Parameters:
proxy - the proxy instance that the method was invoked on
method - the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.
args - an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.
Returns:
the value to return from the method invocation on the proxy instance. If the declared return type of the interface method is a primitive type, then the value returned by this method must be an instance of the corresponding primitive wrapper class; otherwise, it must be a type assignable to the declared return type. If the value returned by this method is null and the interface method's return type is primitive, then a NullPointerException will be thrown by the method invocation on the proxy instance. If the value returned by this method is otherwise not compatible with the interface method's declared return type as described above, a ClassCastException will be thrown by the method invocation on the proxy instance.
Throws:
java.lang.Throwable - the exception to throw from the method invocation on the proxy instance. The exception's type must be assignable either to any of the exception types declared in the throws clause of the interface method or to the unchecked exception types java.lang.RuntimeException or java.lang.Error. If a checked exception is thrown by this method that is not assignable to any of the exception types declared in the throws clause of the interface method, then an UndeclaredThrowableException containing the exception that was thrown by this method will be thrown by the method invocation on the proxy instance.
See Also:
UndeclaredThrowableException

setEventHandler

public void setEventHandler(XuiEventHandler xeh)
Set the current event handler

Specified by:
setEventHandler in interface XEventAdapter
Parameters:
xeh - the event handler

getAddMethodName

public java.lang.String getAddMethodName()
Get the name of the adder method e.g. addActionListener

Specified by:
getAddMethodName in interface XEventAdapter
Returns:
the method name

getListenerInterfaceName

public java.lang.String getListenerInterfaceName()
Get the name of the listener e.g. java.awt.event.ActionListener

Specified by:
getListenerInterfaceName in interface XEventAdapter
Returns:
the listener name

getEventMask

public long getEventMask()
Get the event mask

Specified by:
getEventMask in interface XEventAdapter
Returns:
the mask e.g. AWTEvent.ACTION_MASK