use of com.twinsoft.convertigo.beans.common.RegularExpression in project convertigo by convertigo.
the class JavelinConnector method waitAtScreenClass.
/**
* Waits for one of the screens described by the screen classes
* in the project to arrive. The method waits for all the screen classes
* except the current one. You can use waitAtScreenClass() method to synchronize
* your handler before returning "redetect", "accumulate" or "skip".
*
* @param context the Convertigo context.
* @param timeout the time (in ms) we have to wait for the screen class.
* @param hardDelay a delay (in ms) added after the screen class has arrived.
*
* @return true, if we the screen did arrive, false otherwise.
*/
public boolean waitAtScreenClass(Context context, int timeout, int hardDelay) throws EngineException {
if (javelin != null) {
try {
List<JavelinScreenClass> vScreenClasses = getAllScreenClasses();
List<Criteria> vCriterias;
List<Criteria> vAllCriterias = new ArrayList<Criteria>(128);
RegularExpression regularExpression;
FindString findString;
int j = 0;
ScreenClass lastDetectedScreenClass = (ScreenClass) context.lastDetectedObject;
for (ScreenClass screenClass : vScreenClasses) {
// Do not detect the current screen class
if ((lastDetectedScreenClass != null) && (screenClass.getName().equals(lastDetectedScreenClass.getName()))) {
Engine.logBeans.debug("(JavelinConnector) WaitAtScreenClass(): last detected screen class is " + lastDetectedScreenClass.getName());
continue;
}
vCriterias = screenClass.getLocalCriterias();
for (Criteria criteria : vCriterias) {
if (criteria instanceof FindString) {
findString = (FindString) criteria;
if ((findString.getX() == -1) || (findString.getX() == -1)) {
Engine.logBeans.debug("(JavelinConnector) Ignoring criteria \"" + findString.getString() + "\" at (" + findString.getX() + ", " + findString.getY() + ")");
} else {
Engine.logBeans.debug("(JavelinConnector) Adding a wait at ID:" + j + " \"" + findString.getString() + "\" at (" + findString.getX() + ", " + findString.getY() + ")");
javelin.waitAtId(j, findString.getString(), findString.getX(), findString.getY());
vAllCriterias.add(criteria);
j++;
}
} else if (criteria instanceof RegularExpression) {
regularExpression = (RegularExpression) criteria;
if ((regularExpression.getX() == -1) || (regularExpression.getX() == -1)) {
Engine.logBeans.debug("(JavelinConnector) Ignoring criteria \"" + regularExpression.getRegularExpression() + "\" at (" + regularExpression.getX() + ", " + regularExpression.getY() + ")");
} else {
Engine.logBeans.debug("(JavelinConnector) Adding a wait at ID:" + j + " \"" + regularExpression.getRegularExpression() + "\" at (" + regularExpression.getX() + ", " + regularExpression.getY() + ")");
javelin.waitAtId(j, regularExpression.getRegularExpression(), regularExpression.getX(), regularExpression.getY());
vAllCriterias.add(criteria);
j++;
}
}
}
}
j = javelin.waitTrigger(timeout);
javelin.deleteWaitAts();
Criteria criteria;
if (j != -1) {
criteria = (Criteria) vAllCriterias.get(j);
String string = "?";
int x = -1;
int y = -1;
if (criteria instanceof FindString) {
findString = (FindString) criteria;
string = findString.getString();
x = findString.getX();
y = findString.getY();
} else if (criteria instanceof RegularExpression) {
regularExpression = (RegularExpression) criteria;
string = regularExpression.getRegularExpression();
x = regularExpression.getX();
y = regularExpression.getY();
}
Engine.logBeans.debug("(JavelinConnector) WaitAtScreenClass(): found criteria ID:" + j + " \"" + string + "\" at (" + x + ", " + y + ")");
if (hardDelay > 0) {
javelin.waitSync(hardDelay);
}
return true;
}
Engine.logBeans.debug("(JavelinConnector) Automatic data stable event detection aborted because of timeout!");
return false;
} catch (Exception e) {
Engine.logBeans.error("Exception while trying to wait at screen class", e);
throw new EngineException("Unable to wait at screen class! See the emulator log for more details...", e);
}
} else {
throw new EngineException("Unable to call the waitAtScreenClass() function without a Javelin emulator!");
}
}
use of com.twinsoft.convertigo.beans.common.RegularExpression in project convertigo by convertigo.
the class JavelinConnector method waitNextPage.
/**
* Waits for a new page for the same screen class or a new screen class.
*
* The method wait for one of the screens described by the screen classes in the
* project to arrive. We wait for all the screen classes except the current one. In the
* case of a next page on the same screen class, waitNextPage() will monitor the cursor
* position. the method will return when the cursor position returns to the same position
* it was before calling waitNextPage().
*
* You can use waitNextPage() method to synchronize your handler before returning
* "redetect", "accumulate" or "skip".
*
* @param context the Convertigo context.
* @param timeout the time (in ms) we have to wait for the screen class.
* @param hardDelay a delay (in ms) added after the nextpage has arrived.
*
* @return true, if we the page did arrive, false otherwise.
*/
public boolean waitNextPage(Context context, String action, int timeout, int hardDelay) throws EngineException {
if (javelin != null) {
try {
List<JavelinScreenClass> vScreenClasses = getAllScreenClasses();
List<Criteria> vCriterias;
List<Criteria> vAllCriterias = new ArrayList<Criteria>(128);
RegularExpression regularExpression;
FindString findString;
javelin.deleteWaitAts();
ScreenClass lastDetectedScreenClass = (ScreenClass) context.lastDetectedObject;
// Set all screen class criterias observations
int j = 1;
for (ScreenClass screenClass : vScreenClasses) {
Engine.logBeans.debug("(JavelinConnector) Analyzing screen class \"" + screenClass.getName() + "\"");
// Do not detect the current screen class
if ((lastDetectedScreenClass != null) && (screenClass.getQName().equals(lastDetectedScreenClass.getQName()))) {
Engine.logBeans.debug("(JavelinConnector) Ignoring screen class \"" + screenClass.getName() + "\"");
continue;
}
vCriterias = screenClass.getLocalCriterias();
for (Criteria criteria : vCriterias) {
if (criteria instanceof RegularExpression) {
regularExpression = (RegularExpression) criteria;
if ((regularExpression.getX() == -1) || (regularExpression.getX() == -1)) {
Engine.logBeans.debug("(JavelinConnector) Ignoring criteria \"" + regularExpression.getRegularExpression() + "\" at (" + regularExpression.getX() + ", " + regularExpression.getY() + ")");
} else {
Engine.logBeans.debug("(JavelinConnector) Adding a wait at ID: " + j + " \"" + regularExpression.getRegularExpression() + "\" at (" + regularExpression.getX() + ", " + regularExpression.getY() + ")");
javelin.waitAtId(j, regularExpression.getRegularExpression(), regularExpression.getX(), regularExpression.getY());
vAllCriterias.add(criteria);
j++;
}
}
}
}
// Wait for the cursor to move out from the current location
int line = javelin.getCurrentLine();
int col = javelin.getCurrentColumn();
Engine.logBeans.debug("(JavelinConnector) WaitNextPage(): cursor is now in col: " + col + ", line: " + line);
javelin.waitCursorAtId(1, col, line, false);
javelin.doAction(action);
int ret = javelin.waitTrigger(timeout);
if (ret == -1) {
Engine.logBeans.debug("(JavelinConnector) WaitNextPage(): cursor did not move out in time");
return false;
}
// Set one more observation ID on the cursor position
Engine.logBeans.debug("(JavelinConnector) Adding a waitCursorAt at ID: " + 0 + " in col: " + col + ", line: " + line);
javelin.waitCursorAtId(0, col, line, true);
j = javelin.waitTrigger(timeout);
javelin.deleteWaitAts();
Criteria criteria;
if (j != -1) {
if (j < vAllCriterias.size()) {
criteria = (Criteria) vAllCriterias.get(j);
String string = "?";
int x = -1;
int y = -1;
if (criteria instanceof FindString) {
findString = (FindString) criteria;
string = findString.getString();
x = findString.getX();
y = findString.getY();
} else if (criteria instanceof RegularExpression) {
regularExpression = (RegularExpression) criteria;
string = regularExpression.getRegularExpression();
x = regularExpression.getX();
y = regularExpression.getY();
}
Engine.logBeans.debug("(JavelinConnector) WaitNextPage(): found criteria ID:" + j + " \"" + string + "\" at (" + x + ", " + y + ")");
} else {
Engine.logBeans.debug("(JavelinConnector) WaitNextPage(): cursor back in col: " + col + ", line: " + line);
}
if (hardDelay > 0) {
javelin.waitSync(hardDelay);
}
return true;
}
Engine.logBeans.debug("(JavelinConnector) WaitNextPage(): automatic data stable event detection aborted because of timeout!");
return false;
} catch (Exception e) {
Engine.logBeans.error("Exception while trying to wait next page", e);
throw new EngineException("Unable to wait for the next page! See the emulator log for more details...", e);
}
} else {
throw new EngineException("Unable to call the waitNextPage() function without a Javelin emulator!");
}
}
Aggregations