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

📄 staxjobactionfactory.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 org.w3c.dom.Node;import org.w3c.dom.NamedNodeMap;import org.w3c.dom.NodeList;import com.ibm.staf.*;import java.util.Map;import java.util.TreeMap;import java.util.HashMap;import java.util.List;import java.util.ArrayList;import java.util.Iterator;/** * A factory class for creating STAXJobAction objects based on * information obtained by parsing an XML node from a DOM tree for a * &lt;job&gt; element. * *@see STAXJobAction */public class STAXJobActionFactory implements STAXActionFactory,                                             STAXListRequestHandler,                                             STAXJobManagementHandler{    static final String STAX_SUBJOB_EVENT = new String("SubJob");    static final String sSubjobInfoMapClassName = new String(        "STAF/Service/STAX/SubjobInfo");        /**      * Creates a new STAXJobActionFactory instance and registers     * with the STAX service to handle requests to LIST the active      * sub-jobs in a job and to manage a map of currently active     * sub-jobs for a job.     */    public STAXJobActionFactory(STAX staxService)    {        staxService.registerListHandler("SUBJOBS", this);        staxService.registerJobManagementHandler(this);        // Construct map-class for list subjob information        fSubjobInfoMapClass = new STAFMapClassDefinition(            sSubjobInfoMapClassName);        fSubjobInfoMapClass.addKey("jobID",          "Job ID");        fSubjobInfoMapClass.addKey("jobName",        "Job Name");        fSubjobInfoMapClass.addKey("startTimestamp", "Start Date-Time");        fSubjobInfoMapClass.addKey("function",       "Function");        fSubjobInfoMapClass.addKey("blockName",      "Block Name");    }    public String getDTDInfo()    {        return fDTDInfo;    }    public String getDTDTaskName()    {        return "job";    }    public STAXAction parseAction(STAX staxService, STAXJob job,                                  org.w3c.dom.Node root) throws STAXException    {        STAXJobAction subjob = new STAXJobAction();        subjob.setActionFactory(this);        NamedNodeMap rootAttrs = root.getAttributes();        for (int i = 0; i < rootAttrs.getLength(); ++i)        {            Node thisAttr = rootAttrs.item(i);            String errorInfo = "\n  Element: " + root.getNodeName() +                "  Attribute: " + thisAttr.getNodeName();                        if (thisAttr.getNodeName().equals("name"))            {                                subjob.setName(STAXUtil.parseAndCompileForPython(                    thisAttr.getNodeValue(), errorInfo));            }            else if (thisAttr.getNodeName().equals("clearlogs"))            {                                subjob.setClearlogs(STAXUtil.parseAndCompileForPython(                    thisAttr.getNodeValue(), errorInfo));            }            else if (thisAttr.getNodeName().equals("monitor"))            {                                subjob.setMonitor(STAXUtil.parseAndCompileForPython(                    thisAttr.getNodeValue(), errorInfo));            }            else if (thisAttr.getNodeName().equals("logtcelapsedtime"))            {                subjob.setLogTCElapsedTime(STAXUtil.parseAndCompileForPython(                    thisAttr.getNodeValue(), errorInfo));            }            else if (thisAttr.getNodeName().equals("logtcnumstarts"))            {                subjob.setLogTCNumStarts(STAXUtil.parseAndCompileForPython(                    thisAttr.getNodeValue(), errorInfo));            }            else if (thisAttr.getNodeName().equals("logtcstartstop"))            {                subjob.setLogTCStartStop(STAXUtil.parseAndCompileForPython(                    thisAttr.getNodeValue(), errorInfo));            }            else            {                throw new STAXInvalidXMLAttributeException(                    root.getNodeName() + ": " + thisAttr.getNodeName());            }        }        NodeList children = root.getChildNodes();        for (int i = 0; i < children.getLength(); ++i)        {            Node thisChild = children.item(i);            if (thisChild.getNodeType() == Node.COMMENT_NODE)            {                /* Do nothing */            }            else if (thisChild.getNodeType() == Node.ELEMENT_NODE)            {                if (thisChild.getNodeName().equals("job-file"))                {                    String machine = new String();                    NamedNodeMap attrs = thisChild.getAttributes();                    for (int j = 0; j < attrs.getLength(); ++j)                    {                        Node thisAttr = attrs.item(j);                        String errorInfo = "\n  Element: " +                            thisChild.getNodeName() + "  Attribute: " +                            thisAttr.getNodeName();                        if (thisAttr.getNodeName().equals("machine"))                        {                            machine = STAXUtil.parseAndCompileForPython(                                thisAttr.getNodeValue(), errorInfo);                        }                        else                        {                            throw new STAXInvalidXMLAttributeException(                                thisChild.getNodeName() + ": " +                                 thisAttr.getNodeName());                        }                    }                    subjob.setJobFile(handleChild(thisChild), machine);                }                else if (thisChild.getNodeName().equals("job-data"))                {                    String eval = new String();                    NamedNodeMap attrs = thisChild.getAttributes();                    for (int j = 0; j < attrs.getLength(); ++j)                    {                        Node thisAttr = attrs.item(j);                        String errorInfo = "\n  Element: " +                            thisChild.getNodeName() + "  Attribute: " +                            thisAttr.getNodeName();                        if (thisAttr.getNodeName().equals("eval"))                        {                            eval = STAXUtil.parseAndCompileForPython(                                thisAttr.getNodeValue(), errorInfo);                        }                        else                        {                            throw new STAXInvalidXMLAttributeException(                                thisChild.getNodeName() + ": " +                                 thisAttr.getNodeName());                        }                    }                    subjob.setJobData(handleChild(thisChild), eval);                }                else if (thisChild.getNodeName().equals("job-function"))                {                    String ifValue = new String();                    NamedNodeMap attrs = thisChild.getAttributes();                    for (int j = 0; j < attrs.getLength(); ++j)                    {                        Node thisAttr = attrs.item(j);                        String errorInfo = "\n  Element: " +                            thisChild.getNodeName() + "  Attribute: " +                            thisAttr.getNodeName();                        if (thisAttr.getNodeName().equals("if"))                        {                            ifValue = STAXUtil.parseAndCompileForPython(                                thisAttr.getNodeValue(), errorInfo);                        }                        else                        {                            throw new STAXInvalidXMLAttributeException(                                thisChild.getNodeName() + ": " +                                 thisAttr.getNodeName());                        }                    }                    subjob.setFunction(handleChild(thisChild), ifValue);                }                else if (thisChild.getNodeName().equals("job-function-args"))                {                    String ifValue = new String();                    String eval    = new String();                    NamedNodeMap attrs = thisChild.getAttributes();                    for (int j = 0; j < attrs.getLength(); ++j)                    {                        Node thisAttr = attrs.item(j);                        String errorInfo = "\n  Element: " +                            thisChild.getNodeName() + "  Attribute: " +                            thisAttr.getNodeName();                        if (thisAttr.getNodeName().equals("if"))                            ifValue = STAXUtil.parseAndCompileForPython(                                thisAttr.getNodeValue(), errorInfo);                        else if (thisAttr.getNodeName().equals("eval"))                            eval = STAXUtil.parseAndCompileForPython(                                thisAttr.getNodeValue(), errorInfo);                        else                            throw new STAXInvalidXMLAttributeException(                                thisChild.getNodeName() + ": " +                                 thisAttr.getNodeName());                    }                    subjob.setFunctionArgs(handleChild(thisChild),                                           eval, ifValue);                }                else if (thisChild.getNodeName().equals("job-script"))                {                    String ifValue = new String();                    String eval    = new String();                    NamedNodeMap attrs = thisChild.getAttributes();                    for (int j = 0; j < attrs.getLength(); ++j)                    {                        Node thisAttr = attrs.item(j);                        String errorInfo = "\n  Element: " +                            thisChild.getNodeName() + "  Attribute: " +                            thisAttr.getNodeName();                        if (thisAttr.getNodeName().equals("if"))                            ifValue = STAXUtil.parseAndCompileForPython(                                thisAttr.getNodeValue(), errorInfo);                        else if (thisAttr.getNodeName().equals("eval"))                            eval = STAXUtil.parseAndCompileForPython(                                thisAttr.getNodeValue(), errorInfo);                        else                            throw new STAXInvalidXMLAttributeException(                                thisChild.getNodeName() + ": " +                                 thisAttr.getNodeName());                    }                    subjob.setScripts(handleChild(thisChild), eval, ifValue);                }                else if (thisChild.getNodeName().equals("job-scriptfile") ||                         thisChild.getNodeName().equals("job-scriptfiles"))                {                    String ifValue  = new String();                    String machine = new String();                    NamedNodeMap attrs = thisChild.getAttributes();                    for (int j = 0; j < attrs.getLength(); ++j)                    {                        Node thisAttr = attrs.item(j);                        String errorInfo = "\n  Element: " +                            thisChild.getNodeName() + "  Attribute: " +                            thisAttr.getNodeName();                        if (thisAttr.getNodeName().equals("if"))                            ifValue = STAXUtil.parseAndCompileForPython(                                thisAttr.getNodeValue(), errorInfo);                        else if (thisAttr.getNodeName().equals("machine"))                            machine = STAXUtil.parseAndCompileForPython(                                thisAttr.getNodeValue(), errorInfo);                        else                            throw new STAXInvalidXMLAttributeException(                                thisChild.getNodeName() + ": " +                                 thisAttr.getNodeName());                    }                    subjob.setScriptFiles(handleChild(thisChild),                                           machine, ifValue);                }                else if (thisChild.getNodeName().equals("job-action"))                {                    String ifValue = new String();                    NamedNodeMap attrs = thisChild.getAttributes();                    for (int j = 0; j < attrs.getLength(); ++j)                    {                        Node thisAttr = attrs.item(j);                        String errorInfo = "\n  Element: " +                            thisChild.getNodeName() + "  Attribute: " +                            thisAttr.getNodeName();                                                if (thisAttr.getNodeName().equals("if"))                            ifValue = STAXUtil.parseAndCompileForPython(                                thisAttr.getNodeValue(), errorInfo);                        else                            throw new STAXInvalidXMLAttributeException(                                thisChild.getNodeName() + ": " +                                 thisAttr.getNodeName());                    }                                    NodeList jobActionChildren = thisChild.getChildNodes();                    STAXAction jobAction = null;                    for (int j = 0; j < jobActionChildren.getLength(); ++j)                    {                        Node jobActionChild = jobActionChildren.item(j);                        if (jobActionChild.getNodeType() == Node.COMMENT_NODE)                        {                            /* Do nothing */                        }                        else if (jobActionChild.getNodeType() ==                                  Node.ELEMENT_NODE)                        {                            if (jobAction != null)                            {                                throw new STAXInvalidXMLElementCountException(                                    thisChild.getNodeName());                            }                                                    STAXActionFactory factory =                                 staxService.getActionFactory(                                    jobActionChild.getNodeName());

⌨️ 快捷键说明

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