Services Builder for Screens

com.attachmate.sc.ssa
Class DefaultController

java.lang.Object
  |
  +--com.attachmate.sc.ssa.DefaultController
All Implemented Interfaces:
IController

public class DefaultController
extends java.lang.Object
implements IController

Custom Steps Only
This class is the default controller for the IQAScreen.sendKeys. It can be extended for special Host or application needs. The typical developer does not interact with this class directly

It supports setting text on fields and performing the following actions:

KeyCommand
@AIDirectAccessConstants.ACTION_ALT
@BIDirectAccessConstants.ACTION_BACKSPACE
@CIDirectAccessConstants.CMD_CLEAR
@EIDirectAccessConstants.CMD_TRANSMIT
@HIDirectAccessConstants.CMD_HELP
@PIDirectAccessConstants.CMD_PRINT
@RIDirectAccessConstants.CMD_RESET
@TIDirectAccessConstants.ACTION_TAB
@1IDirectAccessConstants.CMD_F1
@2IDirectAccessConstants.CMD_F2
@3IDirectAccessConstants.CMD_F3
@4IDirectAccessConstants.CMD_F4
@5IDirectAccessConstants.CMD_F5
@6IDirectAccessConstants.CMD_F6
@7IDirectAccessConstants.CMD_F7
@8IDirectAccessConstants.CMD_F8
@9IDirectAccessConstants.CMD_F9
@aIDirectAccessConstants.CMD_F10
@bIDirectAccessConstants.CMD_F11
@cIDirectAccessConstants.CMD_F12
@dIDirectAccessConstants.CMD_F13
@eIDirectAccessConstants.CMD_F14
@fIDirectAccessConstants.CMD_F15
@gIDirectAccessConstants.CMD_F16
@hIDirectAccessConstants.CMD_F17
@iIDirectAccessConstants.CMD_F18
@jIDirectAccessConstants.CMD_F19
@kIDirectAccessConstants.CMD_F20
@lIDirectAccessConstants.CMD_F21
@mIDirectAccessConstants.CMD_F22
@nIDirectAccessConstants.CMD_F23
@oIDirectAccessConstants.CMD_F24
@uIDirectAccessConstants.CMD_ROLLDOWN
@vIDirectAccessConstants.CMD_ROLLUP
@xIDirectAccessConstants.CMD_PA1
@yIDirectAccessConstants.CMD_PA2
@zIDirectAccessConstants.CMD_PA3
@A@CIDirectAccessConstants.CMD_TEST
@A@JIDirectAccessConstants.ACTION_ERASE_INPUT
@A@HIDirectAccessConstants.CMD_SYSTEM_REQUEST
@A@QIDirectAccessConstants.CMD_ATTENTION


Field Summary
static java.lang.String ACTION_KEYS
          a list of single character commands used by sendkeys.
static int[] ACTION_LIST
          a list of commands and actions from IDirectActionConstants that match up with the sendkeys commands in ACTION_KEYS
protected static int BACKWARDS
          tabCursor constant for tabbing backwards
protected static int FORWARD
          tabCursor constant for tabbing forward
protected static java.lang.String MULTI_COMMAND
          a list of sendkey commands that are the prefix to combination commands.
protected static java.lang.String[] SUB_COMMANDS
          a list of command suffixes for each character in MULTI_COMMAND.
protected static int[][] SUBKEYS
          a list for character in the SUB_COMMANDS list.
 
Constructor Summary
DefaultController(com.attachmate.sc.ssa.IDirectAccess da)
           
 
Method Summary
protected  void execute(int command)
          Execute a command.
protected  int findCurrentField(IFieldData[] fields)
          Finds the field where the cursor is currently located.
 Point getCursorTrigger()
          Sets the cursor trigger.
 IPerformanceTool getPerformanceTool()
          Gets the current performance tool from the current controller.
 long getSettleTime()
          Gets the amount of time a read should wait for a settled read.
 long getTimeout()
          Gets the maximum amount of time a read should take.
 void performAction(java.lang.String commands)
          Convert the supplied array of commands into actions.
protected  void read()
          Read data from the host.
 void setCursorTrigger(Point p)
          Sets the cursor trigger.
 void setFieldText(java.lang.String text)
          Write the supplied text to where the cursor is sitting.
 void setPerformanceTool(IPerformanceTool tool)
          Sets the performance tools on the current controller.
 void setSettleTime(long milliseconds)
          Sets the amount of time a read should wait for a settled read.
 void setTimeout(long milliseconds)
          Sets the amount of time to perform a read
protected  void tabCursor(int direction)
          Move the cursor to the next unprotected field
protected  void write(int command)
          Send a command to the host.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORWARD

protected static final int FORWARD
tabCursor constant for tabbing forward

See Also:
Constant Field Values

BACKWARDS

protected static final int BACKWARDS
tabCursor constant for tabbing backwards

See Also:
Constant Field Values

ACTION_KEYS

public static final java.lang.String ACTION_KEYS
a list of single character commands used by sendkeys. This must be kept up to date with ACTION_LIST

See Also:
Constant Field Values

ACTION_LIST

public static final int[] ACTION_LIST
a list of commands and actions from IDirectActionConstants that match up with the sendkeys commands in ACTION_KEYS


MULTI_COMMAND

protected static final java.lang.String MULTI_COMMAND
a list of sendkey commands that are the prefix to combination commands.

See Also:
Constant Field Values

SUB_COMMANDS

protected static final java.lang.String[] SUB_COMMANDS
a list of command suffixes for each character in MULTI_COMMAND.


SUBKEYS

protected static final int[][] SUBKEYS
a list for character in the SUB_COMMANDS list. Use the actions and commands in IDirectAccessConstants.

Constructor Detail

DefaultController

public DefaultController(com.attachmate.sc.ssa.IDirectAccess da)
Method Detail

setFieldText

public void setFieldText(java.lang.String text)
                  throws ProtectedFieldException
Write the supplied text to where the cursor is sitting. The text will be trimmed to fit the field length.

Specified by:
setFieldText in interface IController
Parameters:
text - the String to write to the field
Throws:
ProtectedFieldException

performAction

public void performAction(java.lang.String commands)
                   throws com.attachmate.nav.engine.NavException,
                          java.io.IOException
Convert the supplied array of commands into actions. Any "AID" keys will be sent to the host. Actions will manipulate fields.

Specified by:
performAction in interface IController
Parameters:
commands - a String containing a list of commands.
Throws:
com.attachmate.nav.engine.CustomStepException
java.io.IOException
com.attachmate.nav.engine.NavException

setTimeout

public void setTimeout(long milliseconds)
Sets the amount of time to perform a read

Specified by:
setTimeout in interface IController
Parameters:
milliseconds - the maximum number of milliseconds the read should take.

getTimeout

public long getTimeout()
Gets the maximum amount of time a read should take.

Specified by:
getTimeout in interface IController
Returns:
the maximum amount of time in milliseconds.

setSettleTime

public void setSettleTime(long milliseconds)
Sets the amount of time a read should wait for a settled read. If the read returns with data before the time set, the timer is reset and another read is performed.

Specified by:
setSettleTime in interface IController
Parameters:
milliseconds - the amount of time to wait per read.

getSettleTime

public long getSettleTime()
Gets the amount of time a read should wait for a settled read. If the read returns with data before tthe time set, the timer is reset and another read is performed.

Specified by:
getSettleTime in interface IController
Returns:
the number of milliseconds to wait per read.

setCursorTrigger

public void setCursorTrigger(Point p)
Sets the cursor trigger. A settled read will exit when the host sets the cursor to this coordinate.

Specified by:
setCursorTrigger in interface IController
Parameters:
p - a Point containing the cursor coordinate to wait for. If it is set to (0,0), the read will rely on the timeout and settleTime for exiting the settled read.

getCursorTrigger

public Point getCursorTrigger()
Sets the cursor trigger. A settled read will exit when the host sets the cursor to this coordinate.

Specified by:
getCursorTrigger in interface IController
Returns:
a Point containing the cursor coordinate to wait for. If it is set to (0,0), the read will rely on the timeout and settleTime for exiting the settled read.

findCurrentField

protected int findCurrentField(IFieldData[] fields)
Finds the field where the cursor is currently located.

Parameters:
fields - an array containing all the screen's fields
Returns:
the field index where the cursor resides

tabCursor

protected void tabCursor(int direction)
Move the cursor to the next unprotected field

Parameters:
direction - either FORWARD or BACKWARDS

execute

protected void execute(int command)
                throws java.io.IOException,
                       com.attachmate.nav.engine.NavException
Execute a command. Performs a write and a settled read.

Parameters:
command - the command to execute on the write. This needs to be a IDirectAccessConstants CMD command.
Throws:
java.io.IOException
com.attachmate.nav.engine.NavException

write

protected void write(int command)
              throws java.io.IOException
Send a command to the host. Performs a write to the host using the commands (CMD_*) from IDirectAccessConstants

Parameters:
command - the command to send to the host.
Throws:
java.io.IOException

read

protected void read()
             throws java.io.IOException,
                    com.attachmate.nav.engine.NavException
Read data from the host. Performs a settled read. It uses the following pattern:
    try {
      read(timeout);
      while (onReadExit(status, bTimedOut)) { read(settleTime);}
    } catch (Timeout) { bTimedOut=true }
 

It uses the onReadExit() from IPerformanceTool to decide if another read is necessary.

Throws:
java.io.IOException
com.attachmate.nav.engine.NavException

setPerformanceTool

public void setPerformanceTool(IPerformanceTool tool)
Sets the performance tools on the current controller.

Specified by:
setPerformanceTool in interface IController
Parameters:
tool - a reference to an object that has implemented IPerformanceTool.

getPerformanceTool

public IPerformanceTool getPerformanceTool()
Gets the current performance tool from the current controller.

Specified by:
getPerformanceTool in interface IController
Returns:
a reference to the object that has been assigned to this controller.

Services Builder for Screens