⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 staxifaction.java

📁 Software Testing Automation Framework (STAF)的开发代码
💻 JAVA
字号:
/*****************************************************************************//* Software Testing Automation Framework (STAF)                              *//* (C) Copyright IBM Corp. 2002                                              *//*                                                                           *//* This software is licensed under the Common Public License (CPL) V1.0.     *//*****************************************************************************/package com.ibm.staf.service.stax;import java.util.List;import java.util.Iterator;import java.util.ArrayList;public class STAXIfAction implements STAXAction{    static final int INIT = 0;    static final int ACTION_CALLED = 1;    static final int COMPLETE = 2;    static final String INIT_STRING = "INIT";    static final String ACTION_CALLED_STRING = "ACTION_CALLED";    static final String COMPLETE_STRING = "COMPLETE";    static final String STATE_UNKNOWN_STRING = "UNKNOWN";    private STAXIfAction()    { /* Do Nothing */ }    public STAXIfAction(String ifExpression, STAXAction ifAction,                         List elseifs, STAXAction elseAction)    {        fIfExpression = ifExpression;        fIfAction = ifAction;        fElseifs = elseifs;        fElseAction = elseAction;    }    public String getIfExpression() { return fIfExpression; }    public String getStateAsString()    {        switch (fState)        {            case INIT:                return INIT_STRING;            case ACTION_CALLED:                return ACTION_CALLED_STRING;            case COMPLETE:                return COMPLETE_STRING;            default:                return STATE_UNKNOWN_STRING;        }    }    public String getInfo()    {        int msgLength = fIfExpression.length();        if (msgLength > 40)            return fIfExpression.substring(0, 40) + "...";        else            return fIfExpression;    }    public String getDetails()    {        return "State:" + getStateAsString() +               ";IfExpression:" + fIfExpression +               ";IfAction:" + fIfAction +               ";Elseifs:" + fElseifs +               ";ElseAction:" + fElseAction;    }    public void execute(STAXThread thread)    {        if (fState == INIT)        {            String expr = null;            try            {                expr = "<if expr=\"" + fIfExpression + "\">";                if (thread.pyBoolEval(fIfExpression))                {                    thread.pushAction(fIfAction.cloneAction());                }                else                {                       Iterator it = fElseifs.iterator();                    STAXElseIf elseif;                    boolean elseif_performed = false;                    while (it.hasNext() && !elseif_performed)                    {                        elseif = (STAXElseIf)it.next();                        expr = "<elseif expr=\"" + elseif.getExpression() +                               "\">";                        if (thread.pyBoolEval(elseif.getExpression()))                        {                            thread.pushAction(elseif.getAction().cloneAction());                            elseif_performed = true;                        }                    }                    if (! elseif_performed && fElseAction != null)                        thread.pushAction(fElseAction.cloneAction());                }                fState = ACTION_CALLED;            }            catch (STAXPythonEvaluationException e)            {                fState = COMPLETE;                thread.popAction();                thread.setSignalMsgVar("STAXPythonEvalMsg", expr, e);                thread.raiseSignal("STAXPythonEvaluationError");            }        }        else if (fState == ACTION_CALLED)        {            fState = COMPLETE;            thread.popAction();        }    }    public void handleCondition(STAXThread thread, STAXCondition cond)    {        fState = COMPLETE;        thread.popAction();    }    public STAXAction cloneAction()    {        STAXIfAction clone = new STAXIfAction();        clone.fIfExpression = fIfExpression;        clone.fIfAction = fIfAction;        clone.fElseifs = fElseifs;        clone.fElseAction = fElseAction;        return clone;    }    private int fState = INIT;    private String fIfExpression;    private STAXAction fIfAction = null;    private List fElseifs = null;    private STAXAction fElseAction = null;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -