MethodCall Class
- public final class MethodCall
extends Operator
Implementation of the MethodCall operator. The MethodCall operator
is used to call an arbitrary Java method using the Java reflection API.
Two forms of method call are supported, static and instance level.
For static method calls Input 1 should be set to null and Inputs 2,3,4
are required.
For instance method calls Inputs 1 and 2 are required, inputs 3 and 4
are ignored.
Option 2 (method name) supports dynamic field resolution, therefore:
"out.println" will automatically resolve the method name to an instance field
with the name "out".
The examples below both invoke static methods. The first calls the static method "testMethod"
on the class "TestStaticMethod" located in the "qa" package. The argument to the method call
is a single string.
The second example is equivalent to: java.lang.System.out.println( "### Condition FALSE" )
new MethodCall( "qa", "TestStaticMethod", "testMethod", new Object[] { new String( "### Condition TRUE" ) } );
new MethodCall( "java.lang", "System", "out.println", new Object[] { new String( "### Condition FALSE" ) } ) );
Input 1: An Object (or Expression returning an Object) that is the target of the method call.
Input 2: A String or an Expression returning a String that is the method name to be invoked.
Input 3: A String or an Expression returning a String that is the name of the package for static method calls.
Input 4: A String or an Expression returning a String that is the name of the Class for static method calls.
Input 5-N1: Objects or Expressions returning Objects that serve as arguments to the method call.
Input N1+1-N2: Classes or Expressions returning Classes that identify the Method signature (optional, only required
to distinguish between polymorphic methods with the same number of arguments.
Returns: An Object that is the result of the method invocation.
-
Hierarchy
-
Object
ComplexExpressionImpl
Operator
MethodCall
-
All Implemented Interfaces
-
Cloneable
, Expression
, Serializable
public static final int |
-
MIN_SUBEXPRESSION_COUNT
- The minimum number of sub-expressions of a valid
MethodCall expression.
|
-
MethodCall()
|
-
MethodCall(
Object staticPackage, Object staticClassName, Object fieldAndMethodName, Object args, Object methodSignature)
- Allocates a
MethodCall object by associating a
static package name, a class name and a method name to be called.
|
-
MethodCall(
Object staticPackage, Object staticClassName, Object fieldAndMethodName, Object args)
- Allocates a
MethodCall object by associating a
static package name, a class name and a method name to be called.
|
-
MethodCall(
Object staticPackage, Object staticClassName, Object fieldAndMethodName)
- Allocates a
MethodCall object by associating a
static package name, a class name and a method name to be called.
|
-
MethodCall(
Object target, Object methodName, Object args, Object methodSignature)
- Allocates a
MethodCall object by associating a
target object, a method name, arguments to be passed to the method and
the method signature.
|
-
MethodCall(
Object target, Object methodName, Object args)
- Allocates a
MethodCall object by associating a
target object, a method name and arguments to be passed to the method call.
|
-
MethodCall(
Object target, Object methodName)
- Allocates a
MethodCall object by associating a
target object, a method name.
|
Methods from com.bea.p13n.expression.internal.ComplexExpressionImpl |
addListener, addSubExpression, clearCache, clone, createProxyExpression, equals, getCachedValue, getParent, getSource, getSubExpression, getSubExpressionCount, getUserData, hashCode, isCached, isCacheEnabled, isEqualitySubExpression, notifyListeners, removeAllSubExpressions, removeListener, removeSubExpression, removeSubExpression, setCachedValue, setCacheEnabled, setParent, setSource, setSubExpression, setUserData, toString, write |
Methods from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods from interface com.bea.p13n.expression.Expression |
accept , addListener , addSubExpression , clearCache , clone , getCachedValue , getParameterSignature , getParent , getSource , getSubExpression , getSubExpressionCount , getUserData , isCached , isCacheEnabled , removeAllSubExpressions , removeListener , removeSubExpression , removeSubExpression , setCachedValue , setCacheEnabled , setSource , setSubExpression , setUserData , write
|
MIN_SUBEXPRESSION_COUNT
public static final int MIN_SUBEXPRESSION_COUNT
- The minimum number of sub-expressions of a valid
MethodCall
expression.
MethodCall
public MethodCall()
MethodCall
public MethodCall(Object
staticPackage,
Object
staticClassName,
Object
fieldAndMethodName,
Object
[] args,
Object
[] methodSignature)
- Allocates a
MethodCall
object by associating a
static package name, a class name and a method name to be called.
MethodCall
public MethodCall(Object
staticPackage,
Object
staticClassName,
Object
fieldAndMethodName,
Object
[] args)
- Allocates a
MethodCall
object by associating a
static package name, a class name and a method name to be called.
MethodCall
public MethodCall(Object
staticPackage,
Object
staticClassName,
Object
fieldAndMethodName)
- Allocates a
MethodCall
object by associating a
static package name, a class name and a method name to be called.
MethodCall
public MethodCall(Object
target,
Object
methodName,
Object
[] args,
Object
[] methodSignature)
- Allocates a
MethodCall
object by associating a
target object, a method name, arguments to be passed to the method and
the method signature.
MethodCall
public MethodCall(Object
target,
Object
methodName,
Object
[] args)
- Allocates a
MethodCall
object by associating a
target object, a method name and arguments to be passed to the method call.
MethodCall
public MethodCall(Object
target,
Object
methodName)
- Allocates a
MethodCall
object by associating a
target object, a method name.
addArgumentsAndSignature(Object[], Object[]) Method
protected void addArgumentsAndSignature(Object
[] args,
Object
[] methodSignature)
Adds the given arguments and method signature as sub expressions.
Parameters
-
args
- An array of objects to be passed to the specified method.
-
methodSignature
- An array of objects containing information about the specified
getArgument(int) Method
public Object
getArgument(int index)
Returns an argument at the specified position in the method signature.
Parameters
-
index
- The position of the argument to be returned.
Returns
- An
Object
representing an argument at the specified
position.
getArgumentArray() Method
public Object
[] getArgumentArray()
Returns an array of Objects
representing the arguments
to a method.
Returns
- An array of objects that are passed to a method as arguments.
getArgumentCount() Method
public int getArgumentCount()
Returns number of arguments.
Returns
- The number of arguments.
getMethodName() Method
public Object
getMethodName()
Returns the method name that will be called on the target object.
Returns
- An
Object
representing a method name.
getMethodSignature(int) Method
public Object
getMethodSignature(int index)
Returns a parameter type of a method signature given the position.
Parameters
-
index
- The position of the parameter whose type has to be returned.
Returns
- An
Object
representing the type of the parameter.
getMethodSignatureArray() Method
public Class
[] getMethodSignatureArray()
Returns an array of Class
storing parameter types which represent
a method signature.
Returns
- An array of
Class
containing a method signature in terms of parameter types.
getMethodSignatureLength() Method
public int getMethodSignatureLength()
Returns the length of the method signature in terms of number of parameters
the method accepts.
Returns
- The length of the method signature.
getParameterSignature() Method
public Class
[] getParameterSignature()
Returns MethodCall
expression's constructor signature
Returns
- An array of
Class
containing parameter types.
getStaticClassName() Method
public Object
getStaticClassName()
Returns the Class object.
Returns
- An
Object
representing a Class.
getStaticPackageName() Method
public Object
getStaticPackageName()
Returns the static package name of a class on which a static method
can be called.
Returns
- An
Object
representing a static package name.
getTarget() Method
public Object
getTarget()
Returns the target object whose method has to be called.
Returns
- An
Object
.