- Implement the first method,
isRecognized() , in the custom step adapter.
isRecognized() must return a Boolean value. The navigation engine uses the return value from this method to determine whether it should execute the custom step.
For this example, the isRecognized method of the custom step adapter must return a value of true if the host is on a vehicle screen, and false if it is not.
public boolean isRecognized() throws CustomStepException, NavException
{
boolean screenMatched = false;
String str = qaScreen.getField(1).getText();
if (str.indexOf(S_CAR) != -1 || str.indexOf(S_BOAT) != -1 || str.indexOf(S_TRUCK) != -1 || str.indexOf(S_CYCLE) != -1)
{
screenMatched = true;
}
return screenMatched;
}
To do this successfully, you must understand your host application and implement the following logic: if the contents of the first host field on the screen contains the word, "CAR," "TRUCK," "MOTORCYCLE," or "BOAT," then we are on a vehicle screen; otherwise, we are not.
Use the IQAScreen interface to retrieve the contents of the host fields, and Java to implement the logic.
- Implement the second method,
processData() , which gathers the desired host data from the current host screen and adds it to the task variable map.
Since the number of vehicle screens that will be encountered in a given task execution is unknown, you need to use the ITaskData interface support to populate table data. This will return a collection of data from the custom step. From each vehicle screen we want to return the vehicle type, model, and year, so we will define three columns in our table data output to represent the three pieces of information we want from each vehicle screen.
public void processData() throws CustomStepException, NavException
{
ITable table = taskData.getTable(S_TABLE);
if (table == null)
{
String[] columnNames = {S_TYPE, S_MODEL, S_YEAR};
table = taskData.createTable(columnNames);
}
String type = qaScreen.getField(12).getText().trim();
String model = qaScreen.getField(16).getText().trim();
String year = qaScreen.getField(20).getText().trim();
String[] row = {type, model, year};
table.addRow(row);
taskData.putTable(S_TABLE, table);
}
The processData() implementation in our custom step implementation defines the table, if it is the first time the step has been executed, or adds data to the existing table in the task variable map.
 |
You can examine the field layout to determine which host fields contain the desired data in the designer. |
- Implement the third and last method,
getTransitionAction() .
This method tells the navigation engine which AID key to send to the host to navigate to the next step in the task.
In this example, to navigate from any vehicle host screen we must send ENTER to the host, so that the getTransitionAction() method will return the String "@E," which is the HLLAPI equivalent of the ENTER AID key.
public String getTransitionAction() throws CustomStepException, NavException
{
return "@E";
}
|