Overview | Package | Class | Use | Tree | Serialized | Deprecated | Index | Help
| ABLE 2.3.0 07/13/2005 14:21:00
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.ibm.able
Class AbleMethodAdaptor

    java.lang.Object
      com.ibm.able.AbleMethodAdaptor

All Implemented Interfaces:
  AbleClearable, java.io.Serializable

Direct Known Subclasses:
  AbleUserDefinedFunction

public class AbleMethodAdaptor
extends java.lang.Object
implements AbleClearable, java.io.Serializable

An AbleMethodAdaptor is an encapsulated method that can be called to invoke a method and retrieve the method's value.

See Also:
  Serialized Form

Field Summary
`protected java.lang.String` | `myAdaptorName` The name of the method adaptor.
`protected java.lang.Class[]` | `myArgList` myArgList is a list of the classes in the argument list.
`protected java.lang.String[]` | `myArgListClassNames` A list of Strings, each of which is the class name of the type of the corresponding argument to be passed to the method when invoked.
`protected int` | `myArity` The number of arguments this adaptor expects.
`protected java.lang.Object` | `myDclMethodSource` myDclMethodSource is any arbitrary Class, Interface or object on which the method named in myMethodName is called.
`protected java.lang.reflect.Method` | `myMethod` myMethod is the method object in myMethodSource.
`protected java.lang.String` | `myMethodName` myMethodName is the name of an accessible method in myMethodSource.
`protected java.lang.Object` | `myMethodSource` myMethodSource is any arbitrary object on which the method named in myMethodName is called.
`protected java.lang.Object` | `myValue` The value returned by the method when it was last invoked.

Constructor Summary
`AbleMethodAdaptor(java.lang.String theAdaptorName, java.lang.Object theMethodSource, java.lang.reflect.Method theMethod)` Constructs an AbleMethodAdaptor with the specified name, and encapsulate the specified method of the specified object.
`AbleMethodAdaptor(java.lang.String theAdaptorName, java.lang.Object theMethodSource, java.lang.String theMethodName, java.lang.Class[] theMethodArgs)` Constructs an AbleMethodAdaptor with the specified name, and encapsulates the specified method of the specified object.

Method Summary
`void` | `clear()`
`static void` | `clear(java.util.Iterator udfs)`
`boolean` | `equalsNameArity(AbleMethodAdaptor theMethodAdaptor)` Indicates whether this method adaptor is equal to the given method adaptor based on the adaptor's names (case sensitive) and number of arguments.
`java.lang.String` | `getMethodName()` Returns the name of this method adaptor.
`java.lang.String` | `getName()` Returns the name of this method adaptor.
`java.lang.String` | `getNameWithArity()` Returns the name of this method adaptor appended with the expected number of arguments.
`java.lang.Class` | `getReturnType()` Returns the data type of the value returned from the associated method invocation.
`java.lang.Object` | `getValue()` Returns the value from the last method invocation.
`java.lang.Object` | `invoke(java.lang.Object[] theMethodArgs)` Call the encapsulated object method and save the result.
`void` | `setMethodSource(java.lang.Object source)` Change the method source object, provided it is an instance of the same class.
`java.lang.String` | `toString()` Returns a string describing the contents of the object.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### myAdaptorName

    protected java.lang.String myAdaptorName

  The name of the method adaptor. This name can be referenced by agents and rules.

### myValue

    protected transient java.lang.Object myValue

  The value returned by the method when it was last invoked. This can be null. If the method has never been invoked, the value is also null.

### myMethodSource

    protected java.lang.Object myMethodSource

  myMethodSource is any arbitrary object on which the method named in myMethodName is called. NOTE that this object must be serializable if this method adaptor is to be used in a serialized manner.

### myDclMethodSource

    protected java.lang.Object myDclMethodSource

  myDclMethodSource is any arbitrary Class, Interface or object on which the method named in myMethodName is called. NOTE that this object must be serializable if this method adaptor is to be used in a serialized manner.

### myMethodName

    protected java.lang.String myMethodName

  myMethodName is the name of an accessible method in myMethodSource.

### myMethod

    protected transient java.lang.reflect.Method myMethod

  myMethod is the method object in myMethodSource. This method is lazily recreated from myMethodName when necessary; for example, after deserialization.

### myArgListClassNames

    protected java.lang.String[] myArgListClassNames

  A list of Strings, each of which is the class name of the type of the corresponding argument to be passed to the method when invoked. There is a one-to-correspondence between this member and myArgList. In fact, myArgListClassNames is used to recreate myArgList after deserialization.

### myArgList

    protected transient java.lang.Class[] myArgList

  myArgList is a list of the classes in the argument list. This list is lazily recreated from myArgListClassNames when necessary; for example, after deserialization.

### myArity

    protected int myArity

  The number of arguments this adaptor expects.

  This could be figured out dynamically each time the arity is needed, but as the arity never changes, it is figured out just once, when the adaptor is created.

Constructor Detail

### AbleMethodAdaptor

    public AbleMethodAdaptor(java.lang.String theAdaptorName,
                             java.lang.Object theMethodSource,
                             java.lang.String theMethodName,
                             java.lang.Class[] theMethodArgs)
                      throws java.lang.NoSuchMethodException,
                             java.lang.SecurityException

  Constructs an AbleMethodAdaptor with the specified name, and encapsulates the specified method of the specified object. The method takes the specified number and types of arguments.

Parameters:
  `theAdaptorName` - The name of the method adaptor; it is this name that can be referenced by agents and from within rules.
  `theMethodSource` - The object whose method is invoked.
  `theMethodName` - The name of the method to invoke.
  `theMethodArgs` - A list of Class objects that represent the types of arguments required by the named method. Null implies an empty parameter array Class[]{}.
Throws:
  `java.lang.NoSuchMethodException` - If the method with argument list does not exist in source object object class
  `java.lang.SecurityException` - If method is not accessible.

### AbleMethodAdaptor

    public AbleMethodAdaptor(java.lang.String theAdaptorName,
                             java.lang.Object theMethodSource,
                             java.lang.reflect.Method theMethod)

  Constructs an AbleMethodAdaptor with the specified name, and encapsulate the specified method of the specified object. The method may or may not take arguments; this is determined by examining the given method object.

Parameters:
  `theAdaptorName` - The name of the method adaptor; it is this name that can be referenced by agents and from within rules.
  `theMethodSource` - The object whose method is invoked.
  `theMethod` - The method to invoke.

Method Detail

### invoke

    public java.lang.Object invoke(java.lang.Object[] theMethodArgs)
                            throws java.lang.reflect.InvocationTargetException,
                                   java.lang.IllegalAccessException,
                                   java.lang.NoSuchMethodException,
                                   java.lang.SecurityException

  Call the encapsulated object method and save the result.

  Parameters:
    `theMethodArgs` - An array of objects that are passed to the invoked method.
  Returns:
    An object representing the outcome of the call.
  Throws:
    `java.lang.NoSuchMethodException` - If the method or method signature is not defined in the source object.
    `java.lang.reflect.InvocationTargetException` - If an exception was thrown by the invoked method.
    `java.lang.SecurityException` - If the method is not public or otherwise accessible.
    `java.lang.IllegalAccessException` - If the method is not public or otherwise accessible.

### getName

    public java.lang.String getName()

  Returns the name of this method adaptor.

  Returns:
    The name of this method adaptor.

### getNameWithArity

    public java.lang.String getNameWithArity()

  Returns the name of this method adaptor appended with the expected number of arguments.

  Returns:
    The name of this method adaptor appended with a slash ("/") and the expected number of arguments or arity; for example, `foo/3`.

### getValue

    public java.lang.Object getValue()

  Returns the value from the last method invocation. This may be null if the method returned null or has never been invoked. If the method returns a Java primitive, the corresponding Java Object is returned; for example int->Integer.

  Returns:
    An object representing the outcome of the last method invocation.

### getReturnType

    public java.lang.Class getReturnType()

  Returns the data type of the value returned from the associated method invocation. If the method cannot be resolved, `Object.class` is returned. Primitives `boolean, double, float, int, or long` are converted to the corresponding Java Object

  Returns:
    The class representing the return type of the method.

### equalsNameArity

    public boolean equalsNameArity(AbleMethodAdaptor theMethodAdaptor)

  Indicates whether this method adaptor is equal to the given method adaptor based on the adaptor's names (case sensitive) and number of arguments.

  Returns:
    true if both adaptors have the same name and expect the same number of arguments. The names are compared taking case into account. The argument TYPES are not compared; just simply the number of arguments. If the names and number of arguments do not match, false is returned.

### getMethodName

    public java.lang.String getMethodName()

  Returns the name of this method adaptor.

  Returns:
    The name of this method adaptor.

### toString

    public java.lang.String toString()

  Returns a string describing the contents of the object.

  Returns:
    A String containing the current contents of the object.

### setMethodSource

    public void setMethodSource(java.lang.Object source)
                         throws AbleDataException

  Change the method source object, provided it is an instance of the same class.

  Throws:
    `AbleDataException` - Never. If the source type is invalid for the Method, then a run-time exception will be thrown by invoke(). Checking here is very very expensive.

### clear

    public static void clear(java.util.Iterator udfs)

  Parameters:
    `udfs` -

### clear

    public void clear()

  Specified by:
    `clear` in interface `AbleClearable`

Overview | Package | Class | Use | Tree | Serialized | Deprecated | Index | Help
| ABLE 2.3.0 07/13/2005 14:21:00
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

(C) Copyright IBM Corporation 1999, 2005