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

📄 staxtimeractionfactory.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 STAXTimerActionFactory implements STAXActionFactory{    private static String fDTDInfo ="\n" +"<!--================= The Timer Element ============================ -->\n" +"<!--\n" +"     The timer element runs a task for a specified duration.\n" +"     If the task is still running at the end of the specified duration,\n" +"     then the RC variable is set to 1, else if the task ended before\n" +"     the specified duration, the RC variable is set to 0, else if the\n" +"     timer could not start due to an invalid duration, the RC variable\n" +"     is set to -1.\n" +"-->\n" +"<!ELEMENT timer     (%task;)>\n" +"<!-- duration is the maximum length of time to run the task.\n" +"       Time can be expressed in milliseconds, seconds, minutes,\n" +"       hours, days, weeks, or years.  It is evaluated via Python.\n" +"         Examples:  duration='50'    (50 milliseconds)\n" +"                    duration='90s'   (90 seconds)\n" +"                    duration='5m'    ( 5 minutes)\n" +"                    duration='36h'   (36 hours)\n" +"                    duration='3d'    ( 3 days)\n" +"                    duration='1w'    ( 1 week)\n" +"                    duration='1y'    ( 1 year)\n" +"-->\n" +"<!ATTLIST timer\n" +"          duration   CDATA        #REQUIRED\n" +">\n";    public String getDTDInfo()    {        return fDTDInfo;    }    public String getDTDTaskName()    {        return "timer";    }    public STAXAction parseAction(STAX staxService, STAXJob job,                                  org.w3c.dom.Node root) throws STAXException    {        String durationString = null;        STAXAction timerAction = 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("duration"))            {                durationString = 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 (timerAction != null)                {                    throw new STAXInvalidXMLElementCountException(                              thisChild.getNodeName());                }                STAXActionFactory factory =                     staxService.getActionFactory(thisChild.getNodeName());                if (factory == null)                {                    throw new STAXInvalidXMLElementException(                              thisChild.getNodeName());                }                timerAction = factory.parseAction(staxService, job, thisChild);            }            else            {                throw new STAXInvalidXMLNodeTypeException(                          Integer.toString(thisChild.getNodeType()));            }        }        return new STAXTimerAction(durationString, timerAction);    }}

⌨️ 快捷键说明

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