abbot.script
Class Step

java.lang.Object
  extended by abbot.script.Step
All Implemented Interfaces:
XMLConstants, XMLifiable, Serializable
Direct Known Subclasses:
Annotation, Call, Comment, Event, Expression, Sequence, Terminate

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

Provides access to one step (line) from a script. A Step is the basic unit of execution. Custom Step classes

All custom Step classes must supply a Constructor with the signature <init>(${link Resolver}, Map). If the step has contents (e.g. Sequence), then it should also provide a Constructor with the signature <init>(Resolver, Element, Map).

The XML tag for a given Step will be used to auto-generate the Step class name, e.g. the tag <aphrodite/> causes the parser to create an instance of class abbot.script.Aphrodite, using one of the Constructors described above.

All derived classes should include an entry in the schema, or validation must be turned off by setting the System property abbot.script.validate=false.

You can make the custom Aphrodite step do just about anything by overriding the runStep() method.

See the source for any Step implementation in this package for examples.

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
Step(Resolver resolver, Map attributes)
           
Step(Resolver resolver, String description)
           
 
Method Summary
protected  Element addAttributes(Element el)
          Add an attribute to the given XML Element.
protected  Element addContent(Element el)
          Override if the step actually has some contents.
protected static Map createAttributeMap(Element el)
          Convert the attributes in the given XML Element into a Map of name/value pairs.
static Step createStep(Resolver resolver, 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.
abstract  String getDefaultDescription()
          Return a reasonable default description for this script step.
 String getDescription()
           
 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)
          Only exposed so that Script may invoke it on load from disk.
 Class resolveClass(String className)
          Returns the Class corresponding to the given class name.
protected  ComponentTester resolveTester(String className)
          Look up an appropriate ComponentTester given an arbitrary Component-derived 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()
          Convert this Step into a String suitable for editing.
 String toString()
          Return a description of this script step.
 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)
Only exposed so that Script may invoke it on load from disk.


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.

Throws:
Throwable

runStep

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

Throws:
Throwable

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

public 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.


getResolver

public Resolver getResolver()

addContent

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


addAttributes

protected Element addAttributes(Element el)
Add an attribute to the given XML Element. Attributes are kept in alphabetical order.


toEditableString

public String toEditableString()
Convert this Step into a String suitable for editing. The default is the XML representation of the Step.

Specified by:
toEditableString in interface XMLifiable

toXMLString

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


toXML

public Element toXML()
Convert the object to XML.

Specified by:
toXML in interface XMLifiable

createStep

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

Throws:
InvalidScriptException
IOException

createAttributeMap

protected static Map createAttributeMap(Element el)
Convert the attributes in the given XML Element into a Map of name/value pairs.


createStep

public static Step createStep(Resolver resolver,
                              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.

Throws:
InvalidScriptException

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 ClassNotFoundException
Returns the Class corresponding to the given class name. Provides just-in-time classname resolution to ensure loading by the proper class loader.

Throws:
ClassNotFoundException

resolveTester

protected ComponentTester resolveTester(String className)
                                 throws ClassNotFoundException
Look up an appropriate ComponentTester given an arbitrary Component-derived 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.

Throws:
ClassNotFoundException - If the given class can't be found.
IllegalArgumentException - If the tester cannot be instantiated.


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

SourceForge