|
T-Plan Robot Enterprise 3.4 Build No. 3.4-20130322.1 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.tplan.robot.scripting.commands.AbstractCommandHandler
com.tplan.robot.scripting.commands.impl.AbstractFileResourceCommand
public abstract class AbstractFileResourceCommand
Base handler for any command allowing to read from and save to a file. It provides the basic infrastructure of opening, creating and closing files. To extend it:
contextShortcut short cut key,ARGUMENTS and PARAMS arrays with
the specific supported commands (you may take advantage of the addSupportedArgsAndParams() method),contextAttributes map with command description,contextAttributes map with command description,getParameterValues() method as necessary with GUI supported parameter values.
T-Plan Robot Enterprise, (C) 2009-2013 T-Plan Limited. All rights reserved.
| Field Summary | |
|---|---|
static String |
ARG_CLOSE
|
static String |
ARG_CREATE
|
static String |
ARG_OPEN
|
protected String[] |
ARGUMENTS
|
protected String |
CONTEXT_FILE_MAP
|
static String |
CONTEXT_FILE_RESOURCE_MAP
|
protected Map |
contextAttributes
|
protected KeyStroke |
contextShortcut
|
static int |
ERR_FAILED_TO_OPEN
|
static int |
ERR_FAILED_TO_SAVE
|
static int |
ERR_MAX
|
static String |
PARAM_ARGUMENT
|
protected static String |
PARAM_BEAN
|
static String |
PARAM_FILE
|
static String |
PARAM_ID
|
static String |
PARAM_OUTFILE
|
static String |
PARAM_SAVE
|
protected String[][] |
PARAMS
|
String |
VAR_FILE
|
String |
VAR_FILENAME
|
String |
VAR_OUTFILE
|
String |
VAR_OUTFILENAME
|
| Fields inherited from class com.tplan.robot.scripting.commands.AbstractCommandHandler |
|---|
ALT, CONTEXT_COMMAND_CALL_PARAMETER_MAP, CONTEXT_COMPILE_SINGLE_COMMAND_MODE, CONTEXT_LAST_WAIT_FACTOR, CONTEXT_WAIT_FACTOR_ERR_MSG_SHOWN, CTRL, PARAM_COUNT, PARAM_ONFAIL, PARAM_ONPASS, PARAM_WAIT, SHIFT, WINDOWS |
| Constructor Summary | |
|---|---|
AbstractFileResourceCommand()
|
|
| Method Summary | |
|---|---|
protected boolean |
addParamToArgumentArray(String param,
String argument)
Declare support of a parameter for an already existing argument. |
protected void |
addSupportedArgsAndParams(String[] arguments,
String[][] parameters)
Append an array of arguments and parameters to the default lists. |
boolean |
canRunWithoutConnection()
This method should return true if it can be executed even when the tool is not connected to a desktop. |
protected abstract void |
cleanUpAllVars(ScriptingContext ctx)
Clean up all variables created by the command. |
protected void |
cleanUpFileVars(ScriptingContext ctx)
|
protected void |
closeFileBean(AbstractFileBean bean,
boolean save)
|
protected abstract void |
create(AbstractFileBean bean,
OutputStream out)
|
protected abstract AbstractFileBean |
createBean()
Create a file bean. |
protected void |
defineFileVariables(AbstractFileBean bean,
ScriptingContext context)
|
int |
execute(List args,
Map values,
Map outputMap,
ScriptingContext context)
|
int |
execute(List args,
Map values,
Map outputMap,
ScriptingContext context,
String errorVar)
|
List |
getArguments(String command,
ScriptingContext context)
Get the list of supported arguments. |
abstract String[] |
getCommandNames()
Get command names. |
String |
getContextArgument()
Get the dummy command argument. |
Map |
getContextAttributes()
Get a map with context attributes. |
KeyStroke |
getContextShortcut()
Get preferred hot key for the GUI command wizard. |
protected abstract JFileChooser |
getFileChooser(String argument,
ScriptingContext context)
|
List |
getParameters(String command,
ScriptingContext context)
Get the list of supported parameters. |
List |
getParameterValues(String paramName,
String command,
ScriptingContext context)
Get values of a particular parameter. |
protected String |
getScriptPath(TestScriptInterpret interpret)
|
protected Map<String,AbstractFileBean> |
getUsedFiles(ScriptingContext context,
Class beanClass)
|
boolean |
isGlobalPrerequisity(String command)
This method should return true if the command needs to be executed prior to running part of a test script. |
protected abstract void |
load(AbstractFileBean bean,
InputStream in)
|
protected void |
removeVariables(String[] varnames,
ScriptingContext ctx)
|
protected abstract void |
save(AbstractFileBean bean,
OutputStream out)
|
void |
scriptEvent(ScriptEvent event)
Implementation of the ScriptListener interface. |
protected void |
updateRelativePath(String paramKey,
String dummyParamKey,
Map<String,Object> parameters,
TestScriptInterpret interpret)
|
void |
validate(List args,
Map values,
Map variableContainer,
ScriptingContext context)
Validate if the command complies with the command syntax.The command is already pre-parsed to a list of parameter names and a map of [name, value] pairs. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.tplan.robot.scripting.commands.CommandHandler |
|---|
addCommandListener, execute, getStablePopupMenuItems, removeCommandListener |
| Field Detail |
|---|
protected KeyStroke contextShortcut
public static final String ARG_OPEN
public static final String ARG_CREATE
public static final String ARG_CLOSE
protected String[] ARGUMENTS
public static final String PARAM_ARGUMENT
public static final String PARAM_ID
public static final String PARAM_FILE
public static final String PARAM_OUTFILE
protected static final String PARAM_BEAN
public static final String PARAM_SAVE
protected String[][] PARAMS
protected final String CONTEXT_FILE_MAP
public final String VAR_FILE
public final String VAR_FILENAME
public final String VAR_OUTFILE
public final String VAR_OUTFILENAME
protected Map contextAttributes
public static final int ERR_FAILED_TO_OPEN
public static final int ERR_FAILED_TO_SAVE
public static final int ERR_MAX
public static final String CONTEXT_FILE_RESOURCE_MAP
| Constructor Detail |
|---|
public AbstractFileResourceCommand()
| Method Detail |
|---|
protected abstract AbstractFileBean createBean()
protected abstract void cleanUpAllVars(ScriptingContext ctx)
removeVariables()
method to remove any variables it produces from the context.
ctx - a script context.
protected abstract void save(AbstractFileBean bean,
OutputStream out)
throws FileNotFoundException,
IOException
FileNotFoundException
IOException
protected abstract void create(AbstractFileBean bean,
OutputStream out)
throws FileNotFoundException,
IOException
FileNotFoundException
IOException
protected abstract void load(AbstractFileBean bean,
InputStream in)
throws FileNotFoundException,
IOException
FileNotFoundException
IOException
protected abstract JFileChooser getFileChooser(String argument,
ScriptingContext context)
public Map getContextAttributes()
getContextAttributes in interface CommandHandlergetContextAttributes in class AbstractCommandHandlerpublic String getContextArgument()
CommandHandler
getContextArgument in interface CommandHandlergetContextArgument in class AbstractCommandHandlerpublic KeyStroke getContextShortcut()
CommandHandler
getContextShortcut in interface CommandHandlergetContextShortcut in class AbstractCommandHandlerpublic boolean isGlobalPrerequisity(String command)
CommandHandlerThis method should return true if the command needs to be executed prior to running part of a test script.
Imagine a following situation. User creates a script:
Var PATH=/usr/java
Type {PATH}/bin/java
Press Enter
User then selects just the last two commands to be executed. It would of course fail because the PATH variable is not defined. If this method returns true, the command will be executed before running selected commands are executed.
isGlobalPrerequisity in interface CommandHandlerisGlobalPrerequisity in class AbstractCommandHandlercommand - a command with parameters to be processed.
public boolean canRunWithoutConnection()
canRunWithoutConnection in interface CommandHandlercanRunWithoutConnection in class AbstractCommandHandlerpublic abstract String[] getCommandNames()
CommandHandlerGet command names. A command name is the first word in a script line, e.g. "Type" or "Press". Though most commands have just one name, you may use this method to define any number of command aliases. You may even use one class to implement more commands if you want. In such a case you need to define more command names and implement a different behavior for each command.
Please note that command name parsing is NOT case sensitive. You don't have to define the names as e.g. { "MyCommand", "mycommand" }. Script parser will always parse the command name in a script and convert it to upper case using the String.toUpperCase(). Such a command name will be then used to look for a command implementation in the command table.
getCommandNames in interface CommandHandler
public void validate(List args,
Map values,
Map variableContainer,
ScriptingContext context)
throws SyntaxErrorException
CommandHandler
validate in interface CommandHandlerargs - a list of parameters.values - a map of [param, value] pairs resulted from parsing of the command.variableContainer - output map for values.context - execution context.
SyntaxErrorException - when the command doesn't meet the required syntax.
protected Map<String,AbstractFileBean> getUsedFiles(ScriptingContext context,
Class beanClass)
public int execute(List args,
Map values,
Map outputMap,
ScriptingContext context)
throws SyntaxErrorException
SyntaxErrorException
public int execute(List args,
Map values,
Map outputMap,
ScriptingContext context,
String errorVar)
throws SyntaxErrorException
SyntaxErrorException
protected void defineFileVariables(AbstractFileBean bean,
ScriptingContext context)
protected void cleanUpFileVars(ScriptingContext ctx)
protected void addSupportedArgsAndParams(String[] arguments,
String[][] parameters)
arguments - parameters -
protected boolean addParamToArgumentArray(String param,
String argument)
param - a parameter name.argument - already existing argument.
protected void removeVariables(String[] varnames,
ScriptingContext ctx)
protected void closeFileBean(AbstractFileBean bean,
boolean save)
throws FileNotFoundException,
IOException
FileNotFoundException
IOExceptionpublic void scriptEvent(ScriptEvent event)
scriptEvent in interface ScriptListenerevent -
public List getArguments(String command,
ScriptingContext context)
AdvancedCommandHandler
getArguments in interface AdvancedCommandHandlercommand - the current command.context - a context.
public List getParameters(String command,
ScriptingContext context)
AdvancedCommandHandler
getParameters in interface AdvancedCommandHandlercommand - the current conmmand text (complete).context - a context.
public List getParameterValues(String paramName,
String command,
ScriptingContext context)
AdvancedCommandHandler
getParameterValues in interface AdvancedCommandHandlerparamName - parameter name.command - the current conmmand text (complete).context - a context.
protected String getScriptPath(TestScriptInterpret interpret)
protected void updateRelativePath(String paramKey,
String dummyParamKey,
Map<String,Object> parameters,
TestScriptInterpret interpret)
|
T-Plan Robot Enterprise 3.4 Build No. 3.4-20130322.1 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||