org.finra.jtaf.core.model.invocationtarget
Class Command

java.lang.Object
  extended by org.finra.jtaf.core.model.invocationtarget.InvocationTarget
      extended by org.finra.jtaf.core.model.invocationtarget.Command
Direct Known Subclasses:
AbstractContextCmd, Block, ExpectFailure, FailHere, IgnoreErrors, Invoke, Multipath, RandomGenerator, Repeat, ReplaceContext, StoreObjectInContextCmd, TryRecoverCleanup, VerifyException, VerifyObjectInContextCmd

public abstract class Command
extends InvocationTarget

Implements basic methods, but leaves execution phase abstract


Field Summary
 Interpreter interpreter
           
protected  boolean recordResult
           
 
Fields inherited from class org.finra.jtaf.core.model.invocationtarget.InvocationTarget
globalContext
 
Constructor Summary
Command(String name)
           
 
Method Summary
 void acceptInvocationTargetVisitor(Interpreter v)
          This is used by the interpreter so that the visitCommand method is called, allowing the interpreter to not have to know what kind of InvocationTarget it is executing.
 void clearContext()
          Used to clear the context.
protected  void deinitialize(IInvocationContext ctx)
          Optional method to deinitialize a command after execution.
protected abstract  void execute(IInvocationContext ctx)
          This method should be overridden by every Command object.
protected  void executeInvocation(Invocation child)
          Used by other commands to execute invocations in their bodies.
protected  boolean getBooleanOrDefault(String attributeName, boolean defaultValue)
          Get a boolean stored in the context or return a default value.
protected  IInvocationContext getContext()
          Internal method: Used to share the current Context between methods without having to pass it explicitly.
protected  float getFloatOrDefault(String attributeName, float defaultValue)
          Get a float stored in the context or return a default value.
protected  int getIntegerOrDefault(String attributeName, int defaultValue)
          Get an integer stored in the context or return a default value.
protected  Object getOptionalObject(String key)
          Grabs an Object from the Context.
protected  String getOptionalString(String attributeName)
          Get a string that was stored in the context as an optional parameter.
protected  boolean getRequiredBoolean(String attributeName)
          Get a boolean that was stored in the context as a required parameter.
protected  float getRequiredFloat(String attributeName)
          Get a float that was stored in the context as an required parameter.
protected  int getRequiredInteger(String attributeName)
          Get an integer that was stored in the context as an required parameter.
protected  Object getRequiredObject(String key)
          Get an object that was stored in the context as an required parameter.
protected  String getRequiredString(String attributeName)
          Get a string that was stored in the context as an required parameter.
protected  String getStringOrDefault(String attributeName, String defaultValue)
          Get a string stored in the context or return a default value.
protected  void initialize(IInvocationContext ctx)
          Optional method to initialize a command before execution
 void launch(IInvocationContext ctx, Interpreter interpreter)
          Sets up the context before executing the actual command.
protected  boolean recordResult()
          Used to check whether or not this command needs to have its details recorded in testStepDetails.
 
Methods inherited from class org.finra.jtaf.core.model.invocationtarget.InvocationTarget
addOptionalParameter, addProduction, addRequiredParameter, cleanGlobalContext, getAllParameters, getFromGlobalContext, getGlobalContext, getName, getOptionalParameters, getProductions, getRequiredParameters, getUsage, putToGlobalContext, setGlobalContext, setUsage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

recordResult

protected boolean recordResult

interpreter

public Interpreter interpreter
Constructor Detail

Command

public Command(String name)
        throws NameFormatException
Throws:
NameFormatException
Method Detail

getContext

protected final IInvocationContext getContext()
Internal method: Used to share the current Context between methods without having to pass it explicitly. The current Context is set automatically when launch() is called.

Returns:
the context of this method

launch

public final void launch(IInvocationContext ctx,
                         Interpreter interpreter)
                  throws Throwable
Sets up the context before executing the actual command. Also handles the updating of the TestStepDetails to record information on step execution.

Parameters:
ctx - - the current context when the command is being executed
interpreter - - the interpreter that is executing the command
Throws:
Throwable

initialize

protected void initialize(IInvocationContext ctx)
                   throws Throwable
Optional method to initialize a command before execution

Parameters:
ctx -
Throws:
Throwable

execute

protected abstract void execute(IInvocationContext ctx)
                         throws Throwable
This method should be overridden by every Command object.

Parameters:
ctx -
Throws:
Exception
Throwable

deinitialize

protected void deinitialize(IInvocationContext ctx)
                     throws Throwable
Optional method to deinitialize a command after execution.

Parameters:
ctx -
Throws:
Throwable

getOptionalObject

protected Object getOptionalObject(String key)
Grabs an Object from the Context.

Parameters:
key -
Returns:

getRequiredObject

protected Object getRequiredObject(String key)
Get an object that was stored in the context as an required parameter.

Parameters:
key - - key of object in context
Returns:
the object value

getRequiredInteger

protected final int getRequiredInteger(String attributeName)
Get an integer that was stored in the context as an required parameter.

Parameters:
attributeName - - key of object in context
Returns:
the integer value

getIntegerOrDefault

protected final int getIntegerOrDefault(String attributeName,
                                        int defaultValue)
Get an integer stored in the context or return a default value.

Parameters:
attributeName - - key of object in context
defaultValue - - the default value if the attributeName has no associated value in the context.
Returns:
the default value or the value from the context.

getRequiredFloat

protected final float getRequiredFloat(String attributeName)
Get a float that was stored in the context as an required parameter.

Parameters:
attributeName - - key of object in context
Returns:
the float value

getFloatOrDefault

protected final float getFloatOrDefault(String attributeName,
                                        float defaultValue)
Get a float stored in the context or return a default value.

Parameters:
attributeName - - key of object in context
defaultValue - - the default value if the attributeName has no associated value in the context.
Returns:
the default value or the value from the context.

getRequiredString

protected final String getRequiredString(String attributeName)
Get a string that was stored in the context as an required parameter.

Parameters:
attributeName - - key of object in context
Returns:
the string value

getStringOrDefault

protected final String getStringOrDefault(String attributeName,
                                          String defaultValue)
Get a string stored in the context or return a default value.

Parameters:
attributeName - - key of object in context
defaultValue - - the default value if the attributeName has no associated value in the context.
Returns:
the default value or the value from the context.

getOptionalString

protected final String getOptionalString(String attributeName)
Get a string that was stored in the context as an optional parameter.

Parameters:
attributeName - - key of object in context
Returns:
the string value

getRequiredBoolean

protected final boolean getRequiredBoolean(String attributeName)
Get a boolean that was stored in the context as a required parameter.

Parameters:
attributeName - - key of object in context
Returns:
the boolean value

getBooleanOrDefault

protected final boolean getBooleanOrDefault(String attributeName,
                                            boolean defaultValue)
Get a boolean stored in the context or return a default value.

Parameters:
attributeName - - key of object in context
defaultValue - - the default value if the attributeName has no associated value in the context.
Returns:
the default value or the value from the context.

acceptInvocationTargetVisitor

public final void acceptInvocationTargetVisitor(Interpreter v)
                                         throws Throwable
This is used by the interpreter so that the visitCommand method is called, allowing the interpreter to not have to know what kind of InvocationTarget it is executing.

Specified by:
acceptInvocationTargetVisitor in class InvocationTarget
Parameters:
v - - the interpreter executing this command
Throws:
Throwable

recordResult

protected boolean recordResult()
Used to check whether or not this command needs to have its details recorded in testStepDetails.

Returns:

executeInvocation

protected void executeInvocation(Invocation child)
                          throws Throwable
Used by other commands to execute invocations in their bodies.

Parameters:
child - - the command in the block
Throws:
Throwable

clearContext

public void clearContext()
Used to clear the context.



Copyright © 2014. All rights reserved.