public class Script extends Sequence implements Resolver
This takes a single filename as a constructor argument.
Use ScriptFixture and
ScriptTestSuite
to generate a suite by auto-generating a collection of Scripts.
StepRunner,
Fixture,
Launch,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
INTERPRETER |
protected static java.lang.String |
UNTITLED |
static java.lang.String |
UNTITLED_FILE |
(package private) static boolean |
validate |
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 and Description |
|---|
Script()
Deprecated.
Use an explicit
Hierarchy instead. |
Script(Hierarchy h) |
Script(Resolver parent,
java.util.Map attributes) |
Script(java.lang.String filename)
Deprecated.
Use an explicit
Hierarchy instead. |
Script(java.lang.String filename,
Hierarchy h)
Create a
Script from the given file. |
| Modifier and Type | Method and Description |
|---|---|
ComponentReference |
addComponent(java.awt.Component comp)
Add a new component reference for the given component.
|
void |
addComponentReference(ComponentReference ref)
Add a component reference directly, replacing any existing one with
the same ID.
|
(package private) ComponentReference |
addComponentReference(org.jdom.Element el)
Add a new component reference to the script.
|
org.jdom.Element |
addContent(org.jdom.Element el)
Save component references in addition to everything else.
|
void |
addStep(int index,
Step step)
Inserts a step at the given index in the sequence.
|
void |
addStep(Step step)
Adds a step to the end of the sequence.
|
void |
changeFile(java.io.File file)
Deprecated.
Use
setFile(File). |
void |
clear()
Set up a blank script, discarding any current state.
|
static int |
countLines(Sequence seq,
int index)
Return the number of XML lines in the given sequence that precede the
given index.
|
protected static java.util.Map |
createDefaultMap(java.lang.String filename) |
java.util.Map |
getAttributes()
Provide XML attributes for this Step.
|
ComponentReference |
getComponentReference(java.awt.Component comp)
Return the reference for the given component, or null if none yet
exists.
|
ComponentReference |
getComponentReference(java.lang.String name)
Convert the given reference ID into a component reference.
|
java.util.Collection |
getComponentReferences()
Returns a sorted collection of ComponentReferences.
|
java.lang.String |
getContext(Step step)
Return a meaningful description of where the Step came from.
|
java.lang.ClassLoader |
getContextClassLoader()
|
java.lang.String |
getDefaultDescription()
Return a default description for this
Script. |
java.io.File |
getDirectory()
All relative files should be accessed relative to this directory,
which is the directory where the script resides.
|
java.io.File |
getFile()
Return the file where this script is saved.
|
static java.io.File |
getFile(Step step)
Return the file which defines the given step.
|
java.lang.String |
getFilename()
Return the (possibly relative) path to this script.
|
protected java.lang.String |
getFullXMLString() |
Hierarchy |
getHierarchy()
Return the currently effective
Hierarchy of components. |
static int |
getLine(Step step)
Return the approximate line number of the given step.
|
java.lang.String |
getName() |
java.lang.Object |
getProperty(java.lang.String name)
Provide retrieval of values from temporary storage.
|
java.io.File |
getRelativeTo()
By default, all pathnames are relative to the current working
directory.
|
UIContext |
getUIContext() |
java.lang.String |
getUsage()
Returns a string describing the proper XML usage for this class.
|
java.lang.String |
getVMArgs() |
java.lang.String |
getXMLTag()
Define the XML tag to use for this script step.
|
boolean |
hasLaunch()
Return whether this
Script is launchable. |
boolean |
hasTerminate() |
boolean |
isAWTMode() |
boolean |
isDirty()
Has this script changed since the last save.
|
boolean |
isForked() |
static boolean |
isScript(java.io.File file)
Return whether the given file looks like a valid AWT script.
|
boolean |
isSlowPlayback() |
void |
load()
Read the script from the currently set file.
|
void |
load(java.io.Reader reader)
Loads the XML test script.
|
protected void |
parseAttributes(java.util.Map map)
Parse XML attributes for the Script.
|
protected void |
parseChild(org.jdom.Element el) |
static java.io.File |
resolveRelativeReferences(java.io.File file)
It turns out that getAbsolutePath doesn't remove any relative path
entries such as ..
|
protected void |
runStep(StepRunner runner)
Process each event in our list, using the given runner.
|
void |
save()
Write the script to file.
|
void |
save(java.io.Writer writer)
Write the current state of the script to file.
|
void |
setAWTMode(boolean awt) |
void |
setFile(java.io.File file)
Set the file system basis for this script object.
|
void |
setForked(boolean fork) |
void |
setHierarchy(Hierarchy h) |
void |
setProperty(java.lang.String name,
java.lang.Object value)
Provide temporary storage of String values.
|
void |
setRelativeTo(java.io.File dir)
Indicate that when invoking toXML, a path relative to the given one
should be shown.
|
void |
setSlowPlayback(boolean slow) |
void |
setStep(int index,
Step step)
Replaces the step at the given index.
|
void |
setVMArgs(java.lang.String args) |
java.lang.String |
toEditableString()
Only thing directly editable on a script is its file path.
|
createChildrenFromReader, createSequenceFromString, getStep, indexOf, parseChildren, removeStep, removeStep, runStep, size, stepsaddAttributes, createAttributeMap, createStep, createStep, getDescription, getResolver, resolveClass, resolveTester, run, setDescription, setScriptError, simpleClassName, toString, toXML, toXMLString, usage, usagepublic static final java.lang.String INTERPRETER
static boolean validate
public static final java.lang.String UNTITLED_FILE
protected static final java.lang.String UNTITLED
public Script()
Hierarchy instead.public Script(java.lang.String filename)
Hierarchy instead.Script from the given filename. Uses the
default Hierarchy.public Script(Hierarchy h)
public Script(java.lang.String filename,
Hierarchy h)
Script from the given file.public Script(Resolver parent, java.util.Map attributes)
protected static java.util.Map createDefaultMap(java.lang.String filename)
public void setHierarchy(Hierarchy h)
public java.lang.String getName()
public void setForked(boolean fork)
public boolean isForked()
public void setVMArgs(java.lang.String args)
public java.lang.String getVMArgs()
public boolean isSlowPlayback()
public void setSlowPlayback(boolean slow)
public boolean isAWTMode()
public void setAWTMode(boolean awt)
public java.io.File getFile()
public void changeFile(java.io.File file)
setFile(File).public void setFile(java.io.File file)
public void save(java.io.Writer writer)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String toEditableString()
toEditableString in interface XMLifiabletoEditableString in class Sequencepublic boolean isDirty()
public void save()
throws java.io.IOException
java.io.IOExceptionprotected void parseAttributes(java.util.Map map)
parseAttributes in class Stepprotected void parseChild(org.jdom.Element el)
throws InvalidScriptException
parseChild in class SequenceInvalidScriptExceptionpublic void load(java.io.Reader reader)
throws InvalidScriptException,
java.io.IOException
reader - Provides the script dataInvalidScriptExceptionjava.io.IOExceptionpublic void addStep(int index,
Step step)
Sequencepublic void addStep(Step step)
Sequencepublic void setStep(int index,
Step step)
public void load()
throws java.io.IOException
java.io.IOExceptionprotected java.lang.String getFullXMLString()
public java.lang.String getXMLTag()
Steppublic org.jdom.Element addContent(org.jdom.Element el)
addContent in class Sequencepublic java.lang.String getFilename()
public java.util.Map getAttributes()
getAttributes in class Stepprotected void runStep(StepRunner runner) throws java.lang.Throwable
Sequencepublic void clear()
public java.lang.String getUsage()
Sequencepublic java.lang.String getDefaultDescription()
Script.getDefaultDescription in class Sequencepublic boolean hasLaunch()
Script is launchable.public UIContext getUIContext()
UIContext responsible for setting up
a UI context for this script, or
null if the script has no UI to speak of.public java.lang.ClassLoader getContextClassLoader()
getContextClassLoader in interface ResolverThread.getContextClassLoader()public boolean hasTerminate()
public java.io.File getRelativeTo()
public void setRelativeTo(java.io.File dir)
public static java.io.File resolveRelativeReferences(java.io.File file)
file - The input file to tidy up.java.lang.IllegalArgumentException - If the number of ".." entries outnumber
those of the normal path entries.public static boolean isScript(java.io.File file)
public java.io.File getDirectory()
getDirectory in interface Resolverpublic java.util.Collection getComponentReferences()
getComponentReferences in interface Resolverpublic void addComponentReference(ComponentReference ref)
addComponentReference in interface Resolverpublic ComponentReference addComponent(java.awt.Component comp)
addComponent in interface ResolverComponentReference addComponentReference(org.jdom.Element el) throws InvalidScriptException
InvalidScriptExceptionpublic ComponentReference getComponentReference(java.awt.Component comp)
getComponentReference in interface Resolverpublic ComponentReference getComponentReference(java.lang.String name)
getComponentReference in interface Resolverpublic void setProperty(java.lang.String name,
java.lang.Object value)
ResolversetProperty in interface Resolverpublic java.lang.Object getProperty(java.lang.String name)
ResolvergetProperty in interface Resolverpublic Hierarchy getHierarchy()
Hierarchy of components.getHierarchy in interface Resolverpublic java.lang.String getContext(Step step)
getContext in interface Resolverpublic static java.io.File getFile(Step step)
public static int getLine(Step step)
public static int countLines(Sequence seq, int index)
Abbot is hosted on