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

📄 staximportaction.java

📁 Software Testing Automation Framework (STAF)的开发代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************//* 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 com.ibm.staf.*;import java.util.*;import org.python.core.*;import org.xml.sax.InputSource;import java.io.StringReader;import org.xml.sax.SAXNotRecognizedException;import org.xml.sax.SAXNotSupportedException;public class STAXImportAction implements STAXAction{    public static String kIgnore = "ignore";    public static String kError = "error";    public STAXImportAction()    { /* Do Nothing */ }    public STAXImportAction(String machine, String file, String mode)    {         fUnevalMachine = machine;        fMachine = machine;        fUnevalFile = file;        fFile = file;        fUnevalMode = mode;        fMode = mode;    }    public String getMachine() { return fMachine; }     public void setMachine(String machine)     {        fUnevalMachine = machine;         fMachine = machine;     }        public String getFile() { return fFile; }     public void setFile(String file)     {        fUnevalFile = file;         fFile = file;     }        public String getMode() { return fMode; }     public void setMode(String mode)    {        fUnevalMode = mode;         fMode = mode;     }        public String getImportInclude() { return fImportInclude; }    public void setImportInclude(String importInclude)    {        fUnevalImportInclude = importInclude;         fImportInclude = importInclude;     }    public String getImportExclude() { return fImportExclude; }    public void setImportExclude(String importExclude)    {        fUnevalImportExclude = importExclude;         fImportExclude = importExclude;     }        public String getInfo()    {        return fMachine + ":" + fFile + ":" + fMode + ":" + fImportExclude;    }        public String getDetails()    {        return "Location:" + fMachine +                ";File:" + fFile +                ";Mode:" + fMode +               ";Include:" + fImportInclude +               ";Exclude:" + fImportExclude;    }        public String getXMLInfo()    {        String xmlInfo = "";        xmlInfo = "<import machine=\"" + fMachine + "\"" +             " file=\"" + fFile + "\"" +            " mode=\"" + fMode + "\"" +            ">";                    if (!(fImportInclude.equals("")))        {            xmlInfo += "\n  <import-include>" + fImportInclude +                 "</import-include>";        }                if (!(fImportExclude.equals("")))        {            xmlInfo += "\n  <import-exclude>" + fImportExclude +                 "</import-exclude>";        }        xmlInfo += "\n</import>";                       return xmlInfo;    }        public void execute(STAXThread thread)    {            /* STAXResult will be set to a list containing:                           - None, or a list containing a STAXImportError object and a text                 string with details about the error.                            - A list of the successfully imported functions that were                  requested to be imported.                                - A list of the successfully imported functions that were                  required by other functions.                                - A list of the functions that were requested to be imported                  but already existed (so they were not imported).                                - A list of the functions that were required by other functions                 but already existsed (so they were not imported).                                - A list of the functions there were not requested to be                 imported and were not required by other functions.                                - A list of functions requested to be imported that were not                 found.           */                        fThread = thread;                fFunctionListDoesNotExist = new ArrayList();        fFunctionListNotRequestedNotRequired = new ArrayList();        fFunctionListImportedRequested = new ArrayList();        fFunctionListImportedRequired = new ArrayList();        fFunctionListExistingRequested = new ArrayList();        fFunctionListExistingRequired = new ArrayList();        try        {            String STAXResult = "";                        fMachine = fThread.pyStringEval(fUnevalMachine);            fFile = fThread.pyStringEval(fUnevalFile);            fMode = fThread.pyStringEval(fUnevalMode);                        if (!fMode.equalsIgnoreCase("error") &&                !fMode.equalsIgnoreCase("ignore"))            {                // Invalid mode                fThread.popAction();                String msg = getXMLInfo() + "\n" +                    "\n  Invalid import mode: " + fMode +                    "\n  Import mode must be 'error' or 'ignore'.";                String errorData = "[STAXImportModeError, r'" +                     "Invalid import mode: " + fMode + "']";                PyObject signalData = fThread.pyObjectEval(errorData);                fThread.pySetVar("STAXSignalData", signalData);                fThread.setSignalMsgVar("STAXImportErrorMsg", msg);                fThread.raiseSignal("STAXImportError");                return;            }            boolean emptyImportList = false;            boolean emptyExcludeList = false;            Object[] array;            Vector importList = new Vector();            Vector excludeList = new Vector();                        if (fUnevalImportInclude.equals(""))            {                emptyImportList = true;            }            else            {                List list = fThread.pyListEval(fUnevalImportInclude);                importList = new Vector(list);            }            if (fUnevalImportExclude.equals(""))            {                emptyExcludeList = true;            }            else            {                List list = fThread.pyListEval(fUnevalImportExclude);                excludeList = new Vector(list);            }                         STAXParser parser = new STAXParser(fThread.getJob().getSTAX());                        STAFResult copyResult = fThread.getJob().submitSync(                fMachine, "FS", "GET FILE " + fFile);                                       if (copyResult.rc != 0)                       {                String errorData = "";                                if (copyResult.rc == STAFResult.NoPathToMachine)                {                    errorData = "[STAXNoResponseFromMachine, r'" +                         "RC=" + copyResult.rc + " Result=" +                         copyResult.result + "']";                }                else                {                    errorData = "[STAXFileCopyError, r'" +                        "RC=" + copyResult.rc + " Result=" +                         copyResult.result + "']";                }                fThread.popAction();                                if (fMode.equals(kError))                {                    String msg = getXMLInfo() + "\n" +                        "\n RC    :" + copyResult.rc +                        "\n Result:" + copyResult.result;                    PyObject signalData =                         fThread.pyObjectEval(errorData);                    fThread.pySetVar("STAXSignalData", signalData);                    fThread.setSignalMsgVar("STAXImportErrorMsg", msg);                                fThread.raiseSignal("STAXImportError");                }                else                {                    // just set STAXResult with an error as first element                    String result = "[" + errorData + ",[],[],[],[],[],[]]";                    PyObject resultObject = fThread.pyObjectEval(result);                    fThread.pySetVar("STAXResult", resultObject);                }                                 return;            }                       STAXJob job = parser.parse(new InputSource(                new StringReader(copyResult.result)));                            fFunctionMap = job.getFunctionMap();            Set functionSet = fFunctionMap.keySet();            fThread.pyExec("import re");            // iterator through the imported xml file's functions            Iterator functionIterator = functionSet.iterator();            while (functionIterator.hasNext())            {                String nextFunction = (String)functionIterator.next();                                boolean includeMatch = false;                boolean excludeMatch = false;                                                if (emptyImportList)                {                    checkForMatch(fFunctionMap, nextFunction, excludeList);                }                else                {                    boolean included = false;                                        for (int im = 0; im < importList.size(); im++)                    {                        includeMatch = grepMatch(nextFunction,                            (importList.elementAt(im)).toString());                                                if (includeMatch)                        {                            included = checkForMatch(fFunctionMap,                                 nextFunction, excludeList);                        }                    }                                        if (!included && !(fFunctionListImportedRequired.                        contains(nextFunction)))                    {                        if (!(fFunctionListNotRequestedNotRequired.                            contains(nextFunction)))                        {                            fFunctionListNotRequestedNotRequired.add(                            nextFunction); 

⌨️ 快捷键说明

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