abbot.script
Class Step

java.lang.Object
  extended byabbot.script.Step
All Implemented Interfaces:
Serializable, XMLConstants, XMLifiable
Direct Known Subclasses:
Annotation, Call, Comment, Event, 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. 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 a Constructor with the signature SampleStep(Resolver, Element, Map).

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface abbot.script.XMLConstants
TAG_ACTION, TAG_APPLETVIEWER, TAG_ARCHIVE, TAG_ARGS, TAG_ASSERT, 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_FILENAME, 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  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.
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)
           
 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()
          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.

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

Throws:
InvalidScriptException

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.

Throws:
InvalidScriptException

simpleClassName

protected String simpleClassName(Class cls)

toString

public String toString()
Return a description of this script step.


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-2004 Timothy Wall. All Rights Reserved.
Abbot is hosted on

SourceForge