org.onemind.commons.invoke
Class AbstractInvocable

java.lang.Object
  extended byorg.onemind.commons.invoke.AbstractInvocable
All Implemented Interfaces:
Invocable
Direct Known Subclasses:
ReflectionWrapperInvocable

public abstract class AbstractInvocable
extends java.lang.Object
implements Invocable

An invocable that contain a list of invocable functions to be invoke upon. In current implementation, it can only contains on function with the specific name (regardless of arg types) TODO: improve to allow multiple functions with same name (different args)

Version:
$Id: AbstractInvocable.java,v 1.1 2005/01/24 05:51:36 thlee Exp $ $Name: $
Author:
TiongHiang Lee (thlee@onemindsoft.org)

Constructor Summary
AbstractInvocable()
           
 
Method Summary
 void addFunction(InvocableFunction function)
          Add an function
 boolean canInvoke(java.lang.String functionName, java.lang.Object[] args)
          whether the function can be invoke with the arguments
 InvocableFunction getFunction(java.lang.String functionName, java.lang.Class[] argTypes)
          {@inheritDoc}
 InvocableFunction getFunction(java.lang.String functionName, java.lang.Object[] args)
          Get the function
 java.util.Collection getFunctions()
          Get all the functions
 java.lang.Object invoke(java.lang.String functionName, java.lang.Object[] args)
          invoke the function with the arguments provided
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractInvocable

public AbstractInvocable()
Method Detail

addFunction

public void addFunction(InvocableFunction function)
Add an function

Parameters:
function - the function

getFunction

public InvocableFunction getFunction(java.lang.String functionName,
                                     java.lang.Object[] args)
Get the function

Specified by:
getFunction in interface Invocable
Parameters:
functionName - the function name
args - the arguments
Returns:
the function, or null if the function cannot be found

getFunction

public InvocableFunction getFunction(java.lang.String functionName,
                                     java.lang.Class[] argTypes)
{@inheritDoc}


canInvoke

public boolean canInvoke(java.lang.String functionName,
                         java.lang.Object[] args)
whether the function can be invoke with the arguments

Specified by:
canInvoke in interface Invocable
Parameters:
functionName - the function name
args - the arguments
Returns:
true if can invoke

invoke

public java.lang.Object invoke(java.lang.String functionName,
                               java.lang.Object[] args)
                        throws java.lang.Exception
invoke the function with the arguments provided

Specified by:
invoke in interface Invocable
Parameters:
functionName - the function name
args - the arguments
Returns:
the object returns from the invocation
Throws:
java.lang.Exception - if there's problem invoking the function

getFunctions

public java.util.Collection getFunctions()
Get all the functions

Returns:
the functions


Copyright © 2004-2005 . All Rights Reserved.