Beispiel #1
0
 private String ifParameter(String str) {
   List<String> temp = new ArrayList<String>();
   List<String> list = re.parameterName(str);
   for (int i = 0; i < list.size(); i++) {
     if (param.containsKey(list.get(i))) temp.add(param.get(list.get(i)));
     else temp.add(list.get(i));
   }
   return re.replaceIfParameter(str, temp);
 }
Beispiel #2
0
 private void executeLogicBlock(String index) throws DefinedException {
   ArrayList<String> blockList = logicBlock.get(String.valueOf(index));
   for (int i = 0; i < blockList.size(); i++) {
     if (logicTitle.containsKey(blockList.get(i))) {
       if (re.isIfCase(logicTitle.get(blockList.get(i)))) this.executeIfBlock(blockList.get(i));
       if (re.isForCase(logicTitle.get(blockList.get(i)))) this.executeForBlock(blockList.get(i));
     } else {
       excute.setParam(param);
       excute.setDescription(blockList.get(i));
       excute.setReplaceDesc(blockList.get(i));
       excute.excute();
     }
   }
 }
Beispiel #3
0
 private boolean logicConnector(String str, List<Boolean> temp) throws DefinedException {
   boolean result = false;
   String conn = re.getLogicConnector(str);
   if (conn != null) {
     try {
       if (conn.equals(Keyword.getKeyword("and"))) result = temp.get(0) && temp.get(1);
       if (conn.equals(Keyword.getKeyword("or"))) result = temp.get(0) || temp.get(1);
     } catch (Exception e) {
       throw new DefinedException("if title error, miss condition!");
     }
   } else result = temp.get(0);
   return result;
 }
Beispiel #4
0
 private boolean ifCondition(String str) throws DefinedException {
   List<String> conList = re.getIfCondition(str);
   List<Boolean> temp = new ArrayList<Boolean>();
   List<String> conditions = new ArrayList<String>();
   for (String con : conList) {
     String condition = this.ifParameter(con);
     conditions.add(condition);
     List<String> pName = re.parameterName(condition);
     String determine = re.getDetermine(condition);
     boolean b;
     try {
       b = pName.get(0).equals(pName.get(1));
     } catch (Exception e) {
       throw new DefinedException("if title error, miss condition parameter!");
     }
     if (determine.equals(Keyword.getKeyword("equals"))) temp.add(b);
     if (determine.equals(Keyword.getKeyword("notEquals"))) temp.add(!b);
   }
   str = re.replaceIfCondition(str, conditions);
   Log.commentStep(str);
   if (temp.size() == 0)
     throw new DefinedException(str + " if title error, miss condition parameter!");
   return this.logicConnector(str, temp);
 }
Beispiel #5
0
 public void executeForBlock(String index) throws DefinedException {
   String forName = logicTitle.get(index);
   Log.commentStep(forName);
   List<String> list = re.parameterName(forName);
   String variableName;
   int begin;
   int end;
   try {
     variableName = list.get(0);
     begin = Integer.valueOf(list.get(1));
     if (param.containsKey(list.get(1))) begin = Integer.valueOf(param.get(list.get(1)));
     end = Integer.valueOf(list.get(2));
     if (param.containsKey(list.get(2))) end = Integer.valueOf(param.get(list.get(2)));
   } catch (Exception e) {
     throw new DefinedException(forName + " for title error, miss parameter!");
   }
   for (int i = begin; i <= end; i++) {
     param.put(variableName, String.valueOf(i));
     this.executeLogicBlock(index);
   }
 }
Beispiel #6
0
 public void logicCaseCollect(String description) {
   if ((re.isIfCase(description) || re.isForCase(description)) && !re.isLogicBlock(description)) {
     logicTitle.put(String.valueOf(++logicIndex), description);
     int level = re.getLogicLevel(description);
     multiLogic.put(level + 1, logicIndex);
     logicFlag = true;
   }
   if ((!re.isIfCase(description) && !re.isForCase(description)) && re.isLogicBlock(description)) {
     int level = re.getLogicLevel(description);
     int index = multiLogic.get(level);
     if (logicBlock.containsKey(String.valueOf(index)))
       logicBlock.get(String.valueOf(index)).add(description);
     else {
       ArrayList<String> block = new ArrayList<String>();
       block.add(description);
       logicBlock.put(String.valueOf(index), block);
     }
   }
   if ((re.isIfCase(description) || re.isForCase(description)) && re.isLogicBlock(description)) {
     logicTitle.put(String.valueOf(++logicIndex), description);
     int level = re.getLogicLevel(description);
     multiLogic.put(level + 1, logicIndex);
     int index = multiLogic.get(level);
     if (logicBlock.containsKey(String.valueOf(index)))
       logicBlock.get(String.valueOf(index)).add(String.valueOf(logicIndex));
     else {
       ArrayList<String> block = new ArrayList<String>();
       block.add(String.valueOf(logicIndex));
       logicBlock.put(String.valueOf(index), block);
     }
   }
 }