コード例 #1
0
ファイル: JATKInterpreter.java プロジェクト: xiaoyanit/ATK
  private Object runAction(SimpleNode node, Object data) {
    // visit children
    node.childrenAccept(this, data);

    // analyze the name part
    String functionName = node.getValue();

    if ((phoneInterface.getCnxStatus() != PhoneInterface.CNX_STATUS_AVAILABLE)
        || (mainLogger.isStopATK())) {

      Logger.getLogger(this.getClass()).debug("[" + this.getClass().getName() + "] Close JATK ");
      mainLogger.interrupt();
      return Boolean.FALSE;
    }
    // get variables
    Variable[] tablevariables = new Variable[stack.size()];
    tablevariables = stack.toArray(tablevariables);
    // empty stack
    while (!stack.empty()) stack.pop();

    // SEARCH function in action class and invoke it.
    Method[] functions = actions.getClass().getMethods();
    for (Method function : functions)
      if (function.getName().toLowerCase().equals("action" + functionName.toLowerCase())) {
        try {
          return function.invoke(actions, node, tablevariables);

        } catch (Exception e) {
          Logger.getLogger(this.getClass())
              .debug("erreur during execution of " + function.getName());
          e.printStackTrace();
        }
      }

    // we don't have found the function
    getMainLogger()
        .addErrorToDocumentLogger(
            functionName + " is not a valid function",
            node.getLineNumber(),
            internalState.getCurrentScript());
    return Boolean.FALSE;

    /*
     * Could not happens anymore due to control in actions class } catch
     * (ClassCastException ex) { mainLogger.addErrorToLog("Invalid given
     * argument", node .getLineNumber(), internalState.getCurrentScript());
     * ex.printStackTrace(); return Boolean.FALSE; }
     */
  }
コード例 #2
0
ファイル: JATKInterpreter.java プロジェクト: xiaoyanit/ATK
 /**
  * Constructor
  *
  * @param p phone tested
  * @param l logger used to store information
  * @param currentScript current script tested
  * @param logDir folder where result files are stored
  * @param includeDir folder where include file are stored
  */
 public JATKInterpreter(
     PhoneInterface p, ResultLogger l, String currentScript, String logDir, String includeDir) {
   internalState.setCurrentScript(currentScript);
   internalState.setLogDir(logDir + Platform.FILE_SEPARATOR);
   phoneInterface = p;
   mainLogger = l;
   mainLogger.setInterpreter(this);
   actions = new ActionToExecute(this);
 }