Horus Doc || Java GUI Reference || Doxygen's quick Index  

CallableMethod Class Reference

A CallableMethod is a small shell around any method of a java.lang.Object that adds a "description" of the method and its arguments. More...

Inheritance diagram for CallableMethod::

CallableProperty List of all members.

Public Methods

 CallableMethod (String methodName)
 Construct a CallableMethod without arguments. More...

 CallableMethod (String methodName, String argType, String argName, String choiceType)
 Construct a CallableMethod with 1 argument. More...

 CallableMethod (String methodName, String argType1, String argName1, String choiceType1, String argType2, String argName2, String choiceType2)
 Construct a CallableMethod with 2 arguments. More...

 CallableMethod (String methodName, String argType1, String argName1, String choiceType1, String argType2, String argName2, String choiceType2, String argType3, String argName3, String choiceType3)
 Construct a CallableMethod with 3 arguments. More...

 CallableMethod (String methodName, String[] argTypes, String[] argNames, String[] choiceTypes)
 Construct a CallableMethod with n arguments. More...

String getMethodName ()
 Get the name of the method. More...

int getNumArgs ()
 Get the number of arguments of the method. More...

String[] getArgTypes ()
 Get the types of the arguments of the method. More...

String[] getArgNames ()
 Get the names of the arguments of the method. More...

String[] getChoiceTypes ()
 Get the choice types of the arguments of the method. More...

Object invoke (Object target, Object[] argVals)
 Invoke the method of the target object with the given argument values. More...


Detailed Description

A CallableMethod is a small shell around any method of a java.lang.Object that adds a "description" of the method and its arguments.

The description is typically used in a dialog box (e.g. JavaFuncDialog) to give the user some information and support for invocation of the Java method. The description consists of the name of the method, and for each parameter the type of the parameter, the name of the parameter, and a choiceType which is typically given to SaObjectChoice. The choiceType is used to build a list with parameter value suggestions.

The following argType's are supported: boolean, Boolean, java.lang.Boolean, byte, Byte, java.lang.Byte, short, Short, java.lang.Short, int, Integer, java.lang.Integer, float, Float, java.lang.Float, double, Double, java.lang.Double, String, java.lang.String, Color, java.awt.Color


Constructor & Destructor Documentation

CallableMethod::CallableMethod String    methodName [inline]
 

Construct a CallableMethod without arguments.

00042 {
00043     _methodName = methodName;
00044     _argTypes = new String[0];
00045     _argNames = new String[0];
00046     _choiceTypes = new String[0];
00047 }

CallableMethod::CallableMethod String    methodName,
String    argType,
String    argName,
String    choiceType
[inline]
 

Construct a CallableMethod with 1 argument.

00054 {
00055     _methodName = methodName;
00056     _argTypes = new String[1];
00057     _argTypes[0] = argType;
00058     _argNames = new String[1];
00059     _argNames[0] = argName;
00060     _choiceTypes = new String[1];
00061     _choiceTypes[0] = choiceType;
00062 }

CallableMethod::CallableMethod String    methodName,
String    argType1,
String    argName1,
String    choiceType1,
String    argType2,
String    argName2,
String    choiceType2
[inline]
 

Construct a CallableMethod with 2 arguments.

00070 {
00071     _methodName = methodName;
00072     _argTypes = new String[2];
00073     _argTypes[0] = argType1;
00074     _argTypes[1] = argType2;
00075     _argNames = new String[2];
00076     _argNames[0] = argName1;
00077     _argNames[1] = argName2;
00078     _choiceTypes = new String[2];
00079     _choiceTypes[0] = choiceType1;
00080     _choiceTypes[1] = choiceType2;
00081 }

CallableMethod::CallableMethod String    methodName,
String    argType1,
String    argName1,
String    choiceType1,
String    argType2,
String    argName2,
String    choiceType2,
String    argType3,
String    argName3,
String    choiceType3
[inline]
 

Construct a CallableMethod with 3 arguments.

00090 {
00091     _methodName = methodName;
00092     _argTypes = new String[3];
00093     _argTypes[0] = argType1;
00094     _argTypes[1] = argType2;
00095     _argTypes[2] = argType3;
00096     _argNames = new String[3];
00097     _argNames[0] = argName1;
00098     _argNames[1] = argName2;
00099     _argNames[2] = argName3;
00100     _choiceTypes = new String[3];
00101     _choiceTypes[0] = choiceType1;
00102     _choiceTypes[1] = choiceType2;
00103     _choiceTypes[2] = choiceType3;
00104 }

CallableMethod::CallableMethod String    methodName,
String    argTypes[],
String    argNames[],
String    choiceTypes[]
[inline]
 

Construct a CallableMethod with n arguments.

00111 {
00112     _methodName = methodName;
00113     _argTypes = argTypes;
00114     _argNames = argNames;
00115     _choiceTypes = choiceTypes;
00116 }


Member Function Documentation

String CallableMethod::getMethodName   [inline]
 

Get the name of the method.

00122 {
00123     return _methodName;
00124 }

int CallableMethod::getNumArgs   [inline]
 

Get the number of arguments of the method.

00130 {
00131     return _argTypes.length;
00132 }

String [] CallableMethod::getArgTypes   [inline]
 

Get the types of the arguments of the method.

00138 {
00139     return _argTypes;
00140 }

String [] CallableMethod::getArgNames   [inline]
 

Get the names of the arguments of the method.

00146 {
00147     return _argNames;
00148 }

String [] CallableMethod::getChoiceTypes   [inline]
 

Get the choice types of the arguments of the method.

00154 {
00155     return _choiceTypes;
00156 }

Object CallableMethod::invoke Object    target,
Object    argVals[]
[inline]
 

Invoke the method of the target object with the given argument values.

00162 {
00163     int n = getNumArgs();
00164     Class[] argClasses = new Class[n];
00165     for (int i=0 ; i<n ; i++) {
00166         argClasses[i] = getArgClass(_argTypes[i]);
00167     }
00168     Method jMethod = null;
00169     try {
00170         jMethod = target.getClass().getMethod(_methodName, argClasses);
00171         return jMethod.invoke(target, argVals);
00172     } catch (Exception ex) {
00173         ErrorStreamArea.println("CallableMethod: " + ex + ", method: " + jMethod);
00174         ex.printStackTrace();
00175         return null;
00176     }
00177 }


The documentation for this class was generated from the following file:
Generated on Mon Jan 27 15:11:13 2003 for JavaReference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001