abbot.script
Class Call

java.lang.Object
  extended by abbot.script.Step
      extended by abbot.script.Call
All Implemented Interfaces:
XMLConstants, XMLifiable, Serializable
Direct Known Subclasses:
Action, Launch, PropertyCall

public class Call
extends Step

Class for script steps that want to invoke a method on a class. Subclasses may override getMethod and getTarget to customize behavior.

<call method="..." args="..." class="...">

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface abbot.script.XMLConstants
TAG_ACTION, TAG_APPLETVIEWER, TAG_ARCHIVE, TAG_ARGS, TAG_ASSERT, TAG_AWT, TAG_AWTTESTSCRIPT, TAG_BORDER_TITLE, TAG_CALL, TAG_CLASS, TAG_CLASSPATH, TAG_CODE, TAG_CODEBASE, TAG_COMMENT, TAG_COMPONENT, TAG_COUNT, TAG_DELEGATE, TAG_DESC, TAG_DOCBASE, TAG_EVENT, TAG_EXPR, TAG_FILENAME, TAG_FIXTURE, TAG_FORKED, TAG_HEIGHT, TAG_HORDER, TAG_ICON, TAG_ID, TAG_INDEX, TAG_INVERT, TAG_INVOKER, TAG_KEYCHAR, TAG_KEYCODE, TAG_KIND, TAG_LABEL, TAG_LAUNCH, TAG_METHOD, TAG_MODIFIERS, TAG_NAME, TAG_PARAMS, TAG_PARENT, TAG_POLL_INTERVAL, TAG_PROPERTY, TAG_ROOT, TAG_SAMPLE, TAG_SCRIPT, TAG_SEQUENCE, TAG_SLOW, TAG_STOP_ON_ERROR, TAG_STOP_ON_FAILURE, TAG_TAG, TAG_TERMINATE, TAG_TEXT, TAG_THREADED, TAG_TIMEOUT, TAG_TITLE, TAG_TRIGGER, TAG_TYPE, TAG_VALUE, TAG_VMARGS, TAG_VORDER, TAG_WAIT, TAG_WEIGHTED, TAG_WIDTH, TAG_WINDOW, TAG_X, TAG_Y
 
Constructor Summary
Call(Resolver resolver, Map attributes)
           
Call(Resolver resolver, String description, String className, String methodName, String[] args)
           
 
Method Summary
protected  Method disambiguateMethod(Method[] methods)
          Try to distinguish betwenn the given methods.
protected  Object evaluateParameter(Method m, String param, Class type)
           
protected  Object[] evaluateParameters(Method m, String[] params)
          Convert the String representation of the arguments into actual arguments.
 String[] getArgs()
          Deprecated. use getArguments().
 String[] getArguments()
          Return the arguments as an array of String.
protected  String getArgumentsDescription()
           
 Map getAttributes()
          Attributes to save in script.
 String getDefaultDescription()
          Return a reasonable default description for this script step.
 String getEncodedArguments()
          Convert our argument vector into a single String.
 Method getMethod()
          Return matching methods to be used for invocation.
 String getMethodName()
          Method name to save in script.
protected  Method[] getMethods()
          Return matching methods to be used for invocation.
protected  Object getTarget(Method m)
          Return the target of the invocation.
 Class getTargetClass()
          Get the class of the target of the method invocation.
 String getTargetClassName()
           
 String getUsage()
          Provide a usage String for this step.
 String getXMLTag()
          Define the XML tag to use for this script step.
protected  Object invoke()
          Make the target method invocation.
protected  Method resolveMethod(String name, Class cls, Class returnType)
          Look up the given method name in the given class with the requested return type, having the number of arguments in this step.
protected  Method[] resolveMethods(String name, Class cls, Class returnType)
          Look up all methods in the given class with the given name and return type, having the number of arguments in this step.
protected  void runStep()
          Implement the step's behavior here.
 void setArguments(String encodedArgs)
          Designate the arguments for this Call step.
 void setArguments(String[] args)
          Set the String representation of the arguments for this Call step.
 void setMethodName(String mn)
           
 void setTargetClassName(String cn)
           
 
Methods inherited from class abbot.script.Step
addAttributes, addContent, createAttributeMap, createStep, createStep, getDescription, getResolver, parseStepAttributes, resolveClass, resolveTester, run, setDescription, setScriptError, simpleClassName, toEditableString, toString, toXML, toXMLString, usage, usage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Call

public Call(Resolver resolver,
            Map attributes)

Call

public Call(Resolver resolver,
            String description,
            String className,
            String methodName,
            String[] args)
Method Detail

getDefaultDescription

public String getDefaultDescription()
Description copied from class: Step
Return a reasonable default description for this script step. This value is used in the absence of an explicit description.

Specified by:
getDefaultDescription in class Step

getUsage

public String getUsage()
Description copied from class: Step
Provide a usage String for this step.

Specified by:
getUsage in class Step

getXMLTag

public String getXMLTag()
Description copied from class: Step
Define the XML tag to use for this script step.

Specified by:
getXMLTag in class Step

getEncodedArguments

public String getEncodedArguments()
Convert our argument vector into a single String.


getArgumentsDescription

protected String getArgumentsDescription()

setArguments

public void setArguments(String[] args)
Set the String representation of the arguments for this Call step.


setArguments

public void setArguments(String encodedArgs)
Designate the arguments for this Call step. The format of this String is a comma-separated list of String representations. See the abbot.parsers package for supported String representations.

See Also:
for a description of the format., for the preferred method of indicating the argument list.

setMethodName

public void setMethodName(String mn)

getMethodName

public String getMethodName()
Method name to save in script.


getTargetClassName

public String getTargetClassName()

setTargetClassName

public void setTargetClassName(String cn)

getAttributes

public Map getAttributes()
Attributes to save in script.

Overrides:
getAttributes in class Step

getArgs

public String[] getArgs()
Deprecated. use getArguments().

Return the arguments as an array of String.


getArguments

public String[] getArguments()
Return the arguments as an array of String.


runStep

protected void runStep()
                throws Throwable
Description copied from class: Step
Implement the step's behavior here.

Specified by:
runStep in class Step
Throws:
Throwable

evaluateParameter

protected Object evaluateParameter(Method m,
                                   String param,
                                   Class type)
                            throws Exception
Throws:
Exception

evaluateParameters

protected Object[] evaluateParameters(Method m,
                                      String[] params)
                               throws Exception
Convert the String representation of the arguments into actual arguments.

Throws:
Exception

invoke

protected Object invoke()
                 throws Throwable
Make the target method invocation. This uses evaluateParameters to convert the String representation of the arguments into actual arguments. Tries all matching methods of N arguments.

Throws:
Throwable

getMethod

public Method getMethod()
                 throws ClassNotFoundException,
                        NoSuchMethodException
Return matching methods to be used for invocation.

Throws:
ClassNotFoundException
NoSuchMethodException

getMethods

protected Method[] getMethods()
                       throws ClassNotFoundException,
                              NoSuchMethodException
Return matching methods to be used for invocation.

Throws:
ClassNotFoundException
NoSuchMethodException

getTargetClass

public Class getTargetClass()
                     throws ClassNotFoundException
Get the class of the target of the method invocation. This is public to provide editors access to the class being used (for example, providing a menu of all available methods).

Throws:
ClassNotFoundException

getTarget

protected Object getTarget(Method m)
                    throws Throwable
Return the target of the invocation. The default implementation always returns null for static methods; it will attempt to instantiate a target for non-static methods.

Throws:
Throwable

resolveMethods

protected Method[] resolveMethods(String name,
                                  Class cls,
                                  Class returnType)
                           throws NoSuchMethodException
Look up all methods in the given class with the given name and return type, having the number of arguments in this step.

Throws:
NoSuchMethodException - if no matching method is found
See Also:
getArguments()

resolveMethod

protected Method resolveMethod(String name,
                               Class cls,
                               Class returnType)
                        throws NoSuchMethodException
Look up the given method name in the given class with the requested return type, having the number of arguments in this step.

Throws:
IllegalArgumentException - if not exactly one match exists
NoSuchMethodException
See Also:
getArguments()

disambiguateMethod

protected Method disambiguateMethod(Method[] methods)
Try to distinguish betwenn the given methods.

Throws:
IllegalArgumentException - indicating the appropriate target method can't be distinguished.


Copyright © 2002-2008 Timothy Wall. All Rights Reserved.
Abbot is hosted on

SourceForge