Overview | Package | Class | Tree | Deprecated | Index | Help
| © 2005 BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.p13n.expression.operator
Class MethodCall

    java.lang.Object
      com.bea.p13n.expression.internal.ComplexExpressionImpl
          com.bea.p13n.expression.operator.Operator
              com.bea.p13n.expression.operator.MethodCall

All Implemented Interfaces:
  Cloneable, Expression, com.bea.p13n.expression.ExpressionEvents, Serializable

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.

See Also:
  Serialized Form

Field Summary
`static int` | `MIN_SUBEXPRESSION_COUNT` The minimum number of sub-expressions of a valid `MethodCall` expression.

Constructor Summary
`MethodCall()`
`MethodCall(Object target, Object methodName)` Allocates a `MethodCall` object by associating a target object, a method name.
`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)` 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, 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 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, Object[] args, Object[] methodSignature)` Allocates a `MethodCall` object by associating a static package name, a class name and a method name to be called.

Method Summary
`protected void` | `addArgumentsAndSignature(Object[] args, Object[] methodSignature)` Adds the given arguments and method signature as sub expressions.
`Object` | `getArgument(int index)` Returns an argument at the specified position in the method signature.
`Object[]` | `getArgumentArray()` Returns an array of `Objects` representing the arguments to a method.
`int` | `getArgumentCount()` Returns number of arguments.
`Object` | `getMethodName()` Returns the method name that will be called on the target object.
`Object` | `getMethodSignature(int index)` Returns a parameter type of a method signature given the position.
`Class[]` | `getMethodSignatureArray()` Returns an array of `Class` storing parameter types which represent a method signature.
`int` | `getMethodSignatureLength()` Returns the length of the method signature in terms of number of parameters the method accepts.
`Class[]` | `getParameterSignature()` Returns `MethodCall` expression's constructor signature
`Object` | `getStaticClassName()` Returns the Class object.
`Object` | `getStaticPackageName()` Returns the static package name of a class on which a static method can be called.
`Object` | `getTarget()` Returns the target object whose method has to be called.

Methods inherited from class com.bea.p13n.expression.operator.Operator
`leftHandSide, operand, rightHandSide`

Methods inherited from class 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 inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### MIN_SUBEXPRESSION_COUNT

    public static final int MIN_SUBEXPRESSION_COUNT

  The minimum number of sub-expressions of a valid `MethodCall` expression.

  See Also:
    Constant Field Values

Constructor Detail

### MethodCall

    public MethodCall()

### MethodCall

    public MethodCall(Object target,
                      Object methodName)

  Allocates a `MethodCall` object by associating a target object, a method name.

### 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)

  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,
                      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 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,
                      Object[] args,
                      Object[] methodSignature)

  Allocates a `MethodCall` object by associating a static package name, a class name and a method name to be called.

Method Detail

### addArgumentsAndSignature

    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

    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

    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

    public int getArgumentCount()

  Returns number of arguments.

  Returns:
    The number of arguments.

### getMethodName

    public Object getMethodName()

  Returns the method name that will be called on the target object.

  Returns:
    An `Object` representing a method name.

### getMethodSignature

    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

    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

    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

    public Class[] getParameterSignature()

  Returns `MethodCall` expression's constructor signature

  Returns:
    An array of `Class` containing parameter types.

### getStaticClassName

    public Object getStaticClassName()

  Returns the Class object.

  Returns:
    An `Object` representing a Class.

### getStaticPackageName

    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

    public Object getTarget()

  Returns the target object whose method has to be called.

  Returns:
    An `Object`.

Overview | Package | Class | Tree | Deprecated | Index | Help
| © 2005 BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2005 BEA Systems, Inc. All Rights Reserved