abbot.script
Class Step

java.lang.Object
  |
  +--abbot.script.Step
All Implemented Interfaces:
Serializable, Tags, XMLifiable
Direct Known Subclasses:
Annotation, Call, Comment, Event, Sequence, Terminate

public abstract class Step
extends Object
implements Tags, XMLifiable, Serializable

Provides access to one step (line) from a script. A Step is the basic unit of execution. All derived classes should have a tag "sampleStep" with a corresponding class abbot.script.SampleStep. The class must supply at least a Constructor with the signature SampleStep(Resolver, Map). If the step has contents (e.g. Sequence), then it should also provide SampleStep(Resolver, Element, Map).

See Also:
Serialized Form

Fields inherited from interface abbot.script.Tags
TAG_ACTION, TAG_ARGS, TAG_ASSERT, TAG_AWTTESTSCRIPT, TAG_CALL, TAG_CLASS, TAG_CLASSPATH, TAG_COMMENT, TAG_COMPONENT, TAG_COUNT, TAG_DELEGATE, TAG_DESC, TAG_DOCBASE, TAG_EVENT, TAG_FILENAME, TAG_FORKED, TAG_HEIGHT, TAG_HORDER, TAG_ID, TAG_INDEX, TAG_INVERT, TAG_INVOKER, TAG_KEYCHAR, TAG_KEYCODE, TAG_KIND, TAG_LAUNCH, TAG_METHOD, TAG_MODIFIERS, TAG_NAME, TAG_PARAMS, TAG_PARENT, TAG_POLL_INTERVAL, TAG_PROPERTY, TAG_SAMPLE, TAG_SCRIPT, TAG_SEQUENCE, TAG_SLOW, TAG_STOP_ON_ERROR, TAG_STOP_ON_FAILURE, TAG_TAG, TAG_TERMINATE, TAG_THREADED, TAG_TIMEOUT, TAG_TITLE, TAG_TRIGGER, TAG_TYPE, TAG_VALUE, TAG_VMARGS, TAG_VORDER, TAG_WAIT, TAG_WIDTH, TAG_WINDOW, TAG_X, TAG_Y
 
Constructor Summary
Step(Resolver resolver, Map attributes)
           
Step(Resolver resolver, String description)
           
 
Method Summary
protected  org.jdom.Element addAttributes(org.jdom.Element el)
           
protected  org.jdom.Element addContent(org.jdom.Element el)
          Override if the step actually has some contents.
protected static Map createAttributeMap(org.jdom.Element el)
           
static Step createStep(Resolver resolver, org.jdom.Element el)
          Factory method, equivalent to a "fromXML" for step creation.
static Step createStep(Resolver resolver, String str)
          Create a new step from an in-line XML string.
 Map getAttributes()
          Attributes to save in script.
protected abstract  String getDefaultDescription()
          Return a reasonable default description for this script step.
 String getDescription()
           
 ComponentFinder getFinder()
           
 Resolver getResolver()
           
abstract  String getUsage()
          Provide a usage String for this step.
abstract  String getXMLTag()
          Define the XML tag to use for this script step.
protected  void parseStepAttributes(Map attributes)
           
protected  Component resolve(String name)
          Resolve the given name into a component.
 Class resolveClass(String className)
          Returns the Class corresponding to the given class name.
protected  ComponentTester resolveTester(String compClassName)
          Look up an appropriate ComponentTester given an arbitrary class.
 void run()
          Main run method.
protected abstract  void runStep()
          Implement the step's behavior here.
 void setDescription(String desc)
           
protected  void setScriptError(Throwable thr)
          For use by subclasses when an error is encountered during parsing.
protected  String simpleClassName(Class cls)
           
 String toEditableString()
          Provide an editable string representation of the object.
 String toString()
          Return a description of this script step.
 org.jdom.Element toXML()
          Convert the object to XML.
static String toXMLString(XMLifiable obj)
          Provide a one-line XML string representation.
protected  void usage()
          Throw an invalid script exception describing the proper script usage.
protected  void usage(String details)
          Store an invalid script exception describing the proper script usage.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Step

public Step(Resolver resolver,
            Map attributes)

Step

public Step(Resolver resolver,
            String description)
Method Detail

parseStepAttributes

protected final void parseStepAttributes(Map attributes)

run

public final void run()
               throws Throwable
Main run method. Should never be run on the event dispatch thread, although no check is explicitly done here.

runStep

protected abstract void runStep()
                         throws Throwable
Implement the step's behavior here.

getDescription

public String getDescription()

setDescription

public void setDescription(String desc)

getXMLTag

public abstract String getXMLTag()
Define the XML tag to use for this script step.

getUsage

public abstract String getUsage()
Provide a usage String for this step.

getDefaultDescription

protected abstract String getDefaultDescription()
Return a reasonable default description for this script step. This value is used in the absence of an explicit description.

setScriptError

protected void setScriptError(Throwable thr)
For use by subclasses when an error is encountered during parsing. Should only be used by the XML parsing ctors.

usage

protected void usage()
Throw an invalid script exception describing the proper script usage. This should be used by derived classes whenever parsing indicates invalid input.

usage

protected void usage(String details)
Store an invalid script exception describing the proper script usage. This should be used by derived classes whenever parsing indicates invalid input.

getAttributes

public Map getAttributes()
Attributes to save in script.

resolve

protected Component resolve(String name)
                     throws NoSuchReferenceException,
                            ComponentNotFoundException,
                            MultipleComponentsFoundException
Resolve the given name into a component.

getFinder

public ComponentFinder getFinder()

getResolver

public Resolver getResolver()

addContent

protected org.jdom.Element addContent(org.jdom.Element el)
Override if the step actually has some contents. In most cases, it won't.

addAttributes

protected org.jdom.Element addAttributes(org.jdom.Element el)

toEditableString

public String toEditableString()
Description copied from interface: XMLifiable
Provide an editable string representation of the object. Usually will be a String form of the XML, but may be something simpler if it doesn't make sense to provide the full XML.
Specified by:
toEditableString in interface XMLifiable

toXMLString

public static String toXMLString(XMLifiable obj)
Provide a one-line XML string representation.

toXML

public org.jdom.Element toXML()
Convert the object to XML.
Specified by:
toXML in interface XMLifiable

createStep

public static Step createStep(Resolver resolver,
                              String str)
                       throws InvalidScriptException
Create a new step from an in-line XML string.

createAttributeMap

protected static Map createAttributeMap(org.jdom.Element el)

createStep

public static Step createStep(Resolver resolver,
                              org.jdom.Element el)
                       throws InvalidScriptException
Factory method, equivalent to a "fromXML" for step creation. Looks for a class with the same name as the XML tag, with the first letter capitalized. For example, <call /> is abbot.script.Call.

simpleClassName

protected String simpleClassName(Class cls)

toString

public String toString()
Return a description of this script step.
Overrides:
toString in class Object

resolveClass

public Class resolveClass(String className)
                   throws InvalidScriptException
Returns the Class corresponding to the given class name. Provides just-in-time classname resolution to ensure loading by the proper class loader.

NOTE: only works if the app under test has already been launched.


resolveTester

protected ComponentTester resolveTester(String compClassName)
                                 throws InvalidScriptException
Look up an appropriate ComponentTester given an arbitrary class. If the class is derived from abbot.tester.ComponentTester, instantiate one; if it is derived from java.awt.Component, return a matching Tester. Otherwise return abbot.tester.ComponentTester.

The class is looked up based on the appropriate context for the Step.



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

SourceForge