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

📄 staxloopactionfactory.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 org.w3c.dom.Node;import org.w3c.dom.NamedNodeMap;import org.w3c.dom.NodeList;public class STAXLoopActionFactory implements STAXActionFactory{    private static String fDTDInfo ="\n" +"<!--================= The Loop Element ============================= -->\n" +"<!--\n" +"     The loop element performs a task a specified number of times,\n" +"     allowing specification of an upper and lower bound with an\n" +"     increment value and where the index counter is available to\n" +"     sub-tasks.  Also, while and/or until expressions can be\n" +"     specified.\n" +"-->\n" +"<!ELEMENT loop       (%task;)>\n" +"<!-- var      is the name of a variable which will contain the loop\n" +"              index variable.  It is a literal.\n" +"     from     is the starting value of the loop index variable.\n" +"              It must evaluate to an integer value via Python.\n" +"     to       is the maximum value of the loop index variable\n" +"              It must evaluate to an integer value via Python.\n" +"     by       is the increment value for the loop index variable\n" +"              It must evaluate to an integer value via Python.\n" +"     while    is an expression that must evaluate to a boolean value\n" +"              and is performed at the top of each loop.  If it\n" +"              evaluates to false, it breaks out of the loop.\n" +"     until    is an expression that must evaluate to a boolean value\n" +"              and is performed at the bottom of each loop.  If it\n" +"              evaluates to false, it breaks out of the loop.\n" +"-->\n" +"<!ATTLIST loop\n" +"          var        CDATA    #IMPLIED\n" +"          from       CDATA    '1'\n" +"          to         CDATA    #IMPLIED\n" +"          by         CDATA    '1'\n" +"          while      CDATA    #IMPLIED\n" +"          until      CDATA    #IMPLIED\n" +">\n";    public String getDTDInfo()    {        return fDTDInfo;    }    public String getDTDTaskName()    {        return "loop";    }    public STAXAction parseAction(STAX staxService, STAXJob job,                                  org.w3c.dom.Node root) throws STAXException    {        String indexvar   = null;        String from       = null;        String to         = null;        String by         = null;        String in_while   = null;        String until      = null;        STAXAction loopAction = null;        NamedNodeMap attrs = root.getAttributes();        for (int i = 0; i < attrs.getLength(); ++i)        {            Node thisAttr = attrs.item(i);            String errorInfo = "\n  Element: " + root.getNodeName() +                               "  Attribute: " + thisAttr.getNodeName();            if (thisAttr.getNodeName().equals("var"))            {                indexvar = thisAttr.getNodeValue();            }            else if (thisAttr.getNodeName().equals("from"))            {                from = STAXUtil.parseAndCompileForPython(                    thisAttr.getNodeValue(), errorInfo);            }            else if (thisAttr.getNodeName().equals("to"))            {                to = STAXUtil.parseAndCompileForPython(                    thisAttr.getNodeValue(), errorInfo);            }             else if (thisAttr.getNodeName().equals("by"))            {                by = STAXUtil.parseAndCompileForPython(                    thisAttr.getNodeValue(), errorInfo);            }            else if (thisAttr.getNodeName().equals("while"))            {                in_while = STAXUtil.parseAndCompileForPython(                    thisAttr.getNodeValue(), errorInfo);            }             else if (thisAttr.getNodeName().equals("until"))            {                until = 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 (loopAction != null)                {                    throw new STAXInvalidXMLElementCountException(                              thisChild.getNodeName());                }                STAXActionFactory factory =                     staxService.getActionFactory(thisChild.getNodeName());                if (factory == null)                {                    throw new STAXInvalidXMLElementException(                              thisChild.getNodeName());                }                loopAction = factory.parseAction(staxService, job, thisChild);            }            else            {                throw new STAXInvalidXMLNodeTypeException(                          Integer.toString(thisChild.getNodeType()));            }        }        return new STAXLoopAction(indexvar, from, to, by, in_while,                                   until, loopAction);    }}

⌨️ 快捷键说明

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